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 40a48a51afadbbb2ca1f7607a35b255e74d857b3..6d3f8bd0b6de320d7c759f26c207c264e57b1183 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 @@ -3249,6 +3249,60 @@ describe('LRUCacheTest', function () { ChildLRUCache.getInstance().afterRemoval(true,'abc','ab','string') expect(arr[2]).assertEqual('string') }) + + /** + * @tc.name: testLRUCacheAfterRemoval006 + * @tc.desc: Executes subsequent operations after a value is deleted. + */ + it('testLRUCacheAfterRemoval006', 0, function () { + var arr = []; + class ChildLRUCache extends util.LRUCache + { + constructor(capacity) + { + super(capacity); + } + afterRemoval(isEvict, key, value, newValue) + { + if (isEvict === true) + { + arr = [key, value]; + } + } + } + var that = new ChildLRUCache(2); + that.put(1,2) + that.put(3,10) + that.put('abc',20) + expect(arr[1]).assertEqual(20) + }) + + /** + * @tc.name: testLRUCacheAfterRemoval007 + * @tc.desc: Executes subsequent operations after a value is deleted. + */ + it('testLRUCacheAfterRemoval007', 0, function () { + var arr = []; + class ChildLRUCache extends util.LRUCache + { + constructor(capacity) + { + super(capacity); + } + afterRemoval(isEvict, key, value, newValue) + { + if (isEvict === false) + { + arr = [key, value, newValue]; + } + } + } + var that = new ChildLRUCache(3); + that.put(1,2) + that.put(3,10) + that.put(1,8) + expect(arr[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 3fd89089e267a6047d396f2f9710e4455ce2fa3d..ded7da5dab35386b8a03cf3ad254a79ea5bf1146 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 @@ -4677,6 +4677,60 @@ describe('LruBufferFunTest', function () { ChildLruBuffer.getInstance().afterRemoval(true,'abc','ab','string') expect(arr[2]).assertEqual('string') }) + + /** + * @tc.name: testLruBufferAfterRemoval006 + * @tc.desc: Executes subsequent operations after a value is deleted. + */ + it('testLruBufferAfterRemoval006', 0, function () { + var arr = []; + class ChildLruBuffer extends util.LruBuffer + { + constructor(capacity) + { + super(capacity); + } + afterRemoval(isEvict, key, value, newValue) + { + if (isEvict === true) + { + arr = [key, value]; + } + } + } + var that = new ChildLruBuffer(2); + that.put(1,2) + that.put(3,10) + that.put('abc',20) + expect(arr[1]).assertEqual(20) + }) + + /** + * @tc.name: testLruBufferAfterRemoval007 + * @tc.desc: Executes subsequent operations after a value is deleted. + */ + it('testLruBufferAfterRemoval007', 0, function () { + var arr = []; + class ChildLruBuffer extends util.LruBuffer + { + constructor(capacity) + { + super(capacity); + } + afterRemoval(isEvict, key, value, newValue) + { + if (isEvict === false) + { + arr = [key, value, newValue]; + } + } + } + var that = new ChildLruBuffer(3); + that.put(1,2) + that.put(3,10) + that.put(1,8) + expect(arr[2]).assertEqual(8) + }) }) describe('TypesTest', function() {