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

!6822 Add a case of calling afterRemoval before calling clear

Merge pull request !6822 from jiangkai43/master
......@@ -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 () {
......
......@@ -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() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册