diff --git a/commonlibrary/ets_utils/util2_lib_standard/src/main/js/test/util.test.js b/commonlibrary/ets_utils/util2_lib_standard/src/main/js/test/util.test.js index 6d3f8bd0b6de320d7c759f26c207c264e57b1183..b5715d03de1f92af2b73b8aab7bc7f78fb885b11 100644 --- a/commonlibrary/ets_utils/util2_lib_standard/src/main/js/test/util.test.js +++ b/commonlibrary/ets_utils/util2_lib_standard/src/main/js/test/util.test.js @@ -3303,6 +3303,41 @@ describe('LRUCacheTest', function () { that.put(1,8) expect(arr[2]).assertEqual(8) }) + + /** + * @tc.name: testLRUCacheAfterRemoval008 + * @tc.desc: Executes subsequent operations after a value is deleted. + */ + it('testLRUCacheAfterRemoval008', 0, function () { + var arrk = []; + var arrv = []; + class ChildLRUCache extends util.LRUCache + { + constructor(capacity) + { + super(capacity); + } + afterRemoval(isEvict, key, value, newValue) + { + if (isEvict === false) + { + arrk = Array.from(key); + arrv = Array.from(value); + } + } + } + var that = new ChildLRUCache(3); + that.put(1,2) + that.put(3,10) + that.put(2,8) + that.clear(); + expect(arrk[0]).assertEqual(1) + expect(arrk[1]).assertEqual(3) + expect(arrk[2]).assertEqual(2) + expect(arrv[0]).assertEqual(2) + expect(arrv[1]).assertEqual(10) + expect(arrv[2]).assertEqual(8) + }) }) describe('FunctionTest', function () { diff --git a/commonlibrary/ets_utils/util_lib_standard/src/main/js/test/util.test.js b/commonlibrary/ets_utils/util_lib_standard/src/main/js/test/util.test.js index ded7da5dab35386b8a03cf3ad254a79ea5bf1146..ff0d90c511d364c153f7573cbe531520db6bc30e 100644 --- a/commonlibrary/ets_utils/util_lib_standard/src/main/js/test/util.test.js +++ b/commonlibrary/ets_utils/util_lib_standard/src/main/js/test/util.test.js @@ -4731,6 +4731,41 @@ describe('LruBufferFunTest', function () { that.put(1,8) expect(arr[2]).assertEqual(8) }) + + /** + * @tc.name: testLruBufferAfterRemoval008 + * @tc.desc: Executes subsequent operations after a value is deleted. + */ + it('testLruBufferAfterRemoval008', 0, function () { + var arrk = []; + var arrv = []; + class ChildLruBuffer extends util.LruBuffer + { + constructor(capacity) + { + super(capacity); + } + afterRemoval(isEvict, key, value, newValue) + { + if (isEvict === false) + { + arrk = Array.from(key); + arrv = Array.from(value); + } + } + } + var that = new ChildLruBuffer(3); + that.put(1,2) + that.put(3,10) + that.put(2,8) + that.clear(); + expect(arrk[0]).assertEqual(1) + expect(arrk[1]).assertEqual(3) + expect(arrk[2]).assertEqual(2) + expect(arrv[0]).assertEqual(2) + expect(arrv[1]).assertEqual(10) + expect(arrv[2]).assertEqual(8) + }) }) describe('TypesTest', function() {