Skip to main content

bloom_test.go

bloom_test.go - Overview

This file contains tests for the bloom filter implementation in the y package. It includes tests for basic bloom filter functionality, false positive rates, and the hash function used by the bloom filter.

Detailed Documentation

(Filter) String() string

  • Purpose: This method converts a Filter (which is a []uint32) into a string representation where each bit of each uint32 is represented by '1' or '.'.
  • Parameters: None
  • Returns: A string representing the bloom filter.

TestSmallBloomFilter(t *testing.T)

  • Purpose: Tests the bloom filter with a small set of keys ("hello", "world") and verifies its MayContainKey method.
  • Parameters:
    • t: *testing.T - Testing object for running tests.
  • Returns: None

TestBloomFilter(t *testing.T)

  • Purpose: Tests the bloom filter with a larger set of keys and checks the false positive rate.
  • Parameters:
    • t: *testing.T - Testing object for running tests.
  • Returns: None

TestHash(t *testing.T)

  • Purpose: Tests the Hash function with a set of predefined strings and expected hash values.
  • Parameters:
    • t: *testing.T - Testing object for running tests.
  • Returns: None

Getting Started Relevance