提交 781a388a 编写于 作者: J jiangkai43

The afterRemoval function is called when the cache size is larger than the maxsize

https://gitee.com/openharmony/xts_acts/issues/I62XQRSigned-off-by: Njiangkai43 <jiangkai43@huawei.com>
上级 9fff85af
......@@ -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 () {
......
......@@ -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() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册