@@ -241,3 +241,48 @@ test(`should not return an error when inserting and asking for ${max.toString()}
241241 const currentrate = falsePositive / tries
242242 expect ( currentrate ) . toBeCloseTo ( rate , rate )
243243} )
244+
245+ test ( 'issue#(https://github.com/Callidon/bloom-filters/issues/68)' , ( ) => {
246+ const items = [
247+ 'https://www.youtube.com/watch?v=HJjxN05ewEc' ,
248+ 'https://www.youtube.com/watch?v=BZNUo7orS3k' ,
249+ 'https://www.youtube.com/watch?v=SD-McWZz_pk' ,
250+ 'https://www.youtube.com/watch?v=De4QjH9fpgo' ,
251+ 'https://www.youtube.com/watch?v=Hzko-cjHhTg' ,
252+ 'https://www.youtube.com/watch?v=vqR-8lgOmBE' ,
253+ 'https://www.youtube.com/watch?v=j6u0LH67YLk' ,
254+ 'https://www.youtube.com/watch?v=B2z8ikGLRh8' ,
255+ 'https://www.youtube.com/watch?v=N3ftBeP16TA' ,
256+ 'https://www.youtube.com/watch?v=38RBRPwODUk' ,
257+ 'https://www.youtube.com/watch?v=Ry8nSUfX6fY' ,
258+ 'https://www.youtube.com/watch?v=-KrYohUJvYw' ,
259+ 'https://www.youtube.com/watch?v=zRpl7Pr0fs4' ,
260+ 'https://www.youtube.com/watch?v=uYYiypp6WaY' ,
261+ 'https://www.youtube.com/watch?v=EPap21FBGbE' ,
262+ 'https://www.youtube.com/watch?v=zN2_0WC7UfU' ,
263+ 'https://www.youtube.com/watch?v=DNVwnkgTzbY' ,
264+ ]
265+
266+ const errorRate = 0.04 // 4 % error rate
267+
268+ const round = 100000
269+ let c_false = 0
270+
271+ const filter = CuckooFilter . from ( items , errorRate )
272+ for ( let i = 0 ; i < round ; i ++ ) {
273+ let val = filter . has ( 'https://www.youtube.com/watch?v=HJjxN05ewEc' )
274+ if ( ! val ) {
275+ c_false ++
276+ }
277+
278+ val = filter . has ( 'https://www.youtube.com/watch?v=38RBRPwODUk' )
279+ if ( ! val ) {
280+ c_false ++
281+ }
282+ val = filter . has ( 'https://www.youtube.com/watch?v=-KrYohUJvYw' )
283+ if ( ! val ) {
284+ c_false ++
285+ }
286+ }
287+ expect ( c_false ) . toEqual ( 0 )
288+ } )
0 commit comments