Exemplo n.º 1
0
        public void SetTest()
        {
            int capacity = 1; // TODO: 初始化为适当的值
            LRUCacheSolution target = new LRUCacheSolution(capacity); // TODO: 初始化为适当的值
            int key = 0; // TODO: 初始化为适当的值
            int value = 0; // TODO: 初始化为适当的值
            target.Set(key, value);
            Assert.AreEqual(value, target.Get(key));

            key = 0;
            value = 1;
            target.Set(key, value);
            Assert.AreEqual(value, target.Get(key));

            key = 1;
            value = 2;
            target.Set(key, value);
            Assert.AreEqual(value, target.Get(key));
            Assert.AreEqual(-1, target.Get(0));

            key = 2;
            value = 7;
            target.Set(key, value);
            Assert.AreEqual(-1, target.Get(1));
        }
Exemplo n.º 2
0
 public void GetTest()
 {
     int capacity = 1; // TODO: 初始化为适当的值
     LRUCacheSolution target = new LRUCacheSolution(capacity); // TODO: 初始化为适当的值
     int key = 0; // TODO: 初始化为适当的值
     int expected = -1; // TODO: 初始化为适当的值
     int actual;
     actual = target.Get(key);
     Assert.AreEqual(expected, actual);
 }
Exemplo n.º 3
0
        public void LRUCacheTest()
        {
            var solution = new LRUCacheSolution(1);
            solution.Set(1, 2);
            int excepted = 2;
            int actual = solution.Get(1);
            Assert.AreEqual(excepted, actual);

            actual = solution.Get(0);
            Assert.AreEqual(-1, actual);
        }
Exemplo n.º 4
0
 public void LRUCacheSolutionConstructorTest()
 {
     int capacity = 0; // TODO: 初始化为适当的值
     LRUCacheSolution target = new LRUCacheSolution(capacity);
 }