Skip to content

Commit

Permalink
fix foo/moo indexes collisions in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
folkvir committed May 26, 2024
1 parent c5e4636 commit 502999e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
6 changes: 0 additions & 6 deletions src/topk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,7 @@ export class MinHeap {
* @return Index of the element or -1 if it is not in the heap
*/
public indexOf(value: string): number {
// TODO optimize
return this._content.findIndex(heapElement => heapElement.value === value)
// const index = sortedIndexBy(this._content, {value, frequency: 0}, heapElement => heapElement.value)
// if (this._content[index] !== undefined && this._content[index].value === value) {
// return index
// }
// return -1
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/cuckoo-filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect, test } from '@jest/globals'
import { CuckooFilter, randomInt } from '../src/index'
import Global from './global'

Check failure on line 3 in tests/cuckoo-filter.test.ts

View workflow job for this annotation

GitHub Actions / ubuntu_build (18)

'Global' is defined but never used

Check failure on line 3 in tests/cuckoo-filter.test.ts

View workflow job for this annotation

GitHub Actions / ubuntu_build (19)

'Global' is defined but never used

Check failure on line 3 in tests/cuckoo-filter.test.ts

View workflow job for this annotation

GitHub Actions / ubuntu_build (20)

'Global' is defined but never used

Check failure on line 3 in tests/cuckoo-filter.test.ts

View workflow job for this annotation

GitHub Actions / ubuntu_build (21)

'Global' is defined but never used

Check failure on line 3 in tests/cuckoo-filter.test.ts

View workflow job for this annotation

GitHub Actions / ubuntu_build (18)

'Global' is defined but never used

Check failure on line 3 in tests/cuckoo-filter.test.ts

View workflow job for this annotation

GitHub Actions / ubuntu_build (22)

'Global' is defined but never used

Check failure on line 3 in tests/cuckoo-filter.test.ts

View workflow job for this annotation

GitHub Actions / ubuntu_build (19)

'Global' is defined but never used

Check failure on line 3 in tests/cuckoo-filter.test.ts

View workflow job for this annotation

GitHub Actions / ubuntu_build (20)

'Global' is defined but never used

Check failure on line 3 in tests/cuckoo-filter.test.ts

View workflow job for this annotation

GitHub Actions / ubuntu_build (21)

'Global' is defined but never used

Check failure on line 3 in tests/cuckoo-filter.test.ts

View workflow job for this annotation

GitHub Actions / ubuntu_build (22)

'Global' is defined but never used

const seed = Global.seed(__filename)
const seed = 3413317110537724n // Global.seed(__filename)

test('should compute the fingerprint and indexes for an element', () => {
const filter = new CuckooFilter(15, 3, 2, 1)
Expand Down Expand Up @@ -137,7 +137,7 @@ test('should remove exisiting elements from the filter', () => {
})

test('should fail to remove elements that are not in the filter', () => {
const filter = new CuckooFilter(15, 3, 1)
const filter = new CuckooFilter(128, 8, 4)
filter.seed = seed
filter.add('foo')
expect(filter.remove('moo')).toBe(false)
Expand All @@ -151,7 +151,7 @@ test('should return True when an element may be in the filter', () => {
})

test('should return False when an element is definitively not in the filter', () => {
const filter = new CuckooFilter(15, 3, 1)
const filter = new CuckooFilter(128, 8, 4)
filter.seed = seed
filter.add('foo')
expect(filter.has('moo')).toBe(false)
Expand Down

0 comments on commit 502999e

Please sign in to comment.