未验证 提交 f3959092 编写于 作者: O openharmony_ci 提交者: Gitee

!6677 The afterRemoval function is called when the cache size is larger than...

!6677 The afterRemoval function is called when the cache size is larger than the maxsize【monthly_20221018】
Merge pull request !6677 from jiangkai43/cherry-pick-1669280433
......@@ -3253,6 +3253,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 () {
......
......@@ -4683,6 +4683,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() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册