Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed Jun 14, 2023
1 parent 46c9ada commit d4a7e97
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fifo_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ describe("FIFOMap", () => {
assertFalse(cache.has(1));
assertEquals(cache.size, 0);
});

it("delete should delete item and return boolean", () => {
const cache = new FIFOMap(1);

cache.set(0, 0);

assert(cache.delete(0));
assertFalse(cache.has(0));
assertFalse(cache.delete(0));
});
});

describe("FIFOSet", () => {
Expand Down
6 changes: 6 additions & 0 deletions lfu_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ describe("LFUMap", () => {
assertEquals(cache.get(3), 3);
});

it("should return false if the key is not exist", () => {
const cache = new LFUMap(0);

assertFalse(cache.delete(0));
});

it("should update if the key is duplicated", () => {
const cache = new LFUMap(2);

Expand Down
16 changes: 16 additions & 0 deletions lifo_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ describe("LIFOMap", () => {
assertFalse(cache.has(1));
assertEquals(cache.size, 0);
});

it("delete should delete item and return boolean", () => {
const cache = new LIFOMap(1);

cache.set(0, 0);

assert(cache.delete(0));
assertFalse(cache.has(0));
assertFalse(cache.delete(0));
});
});

describe("LIFOSet", () => {
Expand Down Expand Up @@ -182,6 +192,12 @@ describe("LIFOSet", () => {
assertEquals(cache.size, 0);
});

it("should return false if the key is not exist", () => {
const cache = new LIFOSet(0);

assertFalse(cache.delete(0));
});

it("clear should clear all values", () => {
const cache = new LIFOSet(2);

Expand Down
10 changes: 10 additions & 0 deletions lru_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ describe("LRUMap", () => {
assertFalse(cache.has(1));
assertEquals(cache.size, 0);
});

it("delete should delete item and return boolean", () => {
const cache = new LRUMap(1);

cache.set(0, 0);

assert(cache.delete(0));
assertFalse(cache.has(0));
assertFalse(cache.delete(0));
});
});

describe("LRUSet", () => {
Expand Down

0 comments on commit d4a7e97

Please sign in to comment.