Skip to main content

bloom_test.go

bloom_test.go - Overview

This file contains unit tests for the Bloom filter implementation, covering functionalities like reserving, adding, and checking the existence of elements in the filter. It also includes tests for creating, retrieving, and deep copying Bloom filters, as well as setting and checking bits within the filter's bitset.

Detailed Documentation

TestBloomFilter

Purpose: Tests the basic operations of a Bloom filter, including BFRESERVE, BFADD, and BFEXISTS.

Parameters:

  • t (*testing.T): Testing object for running the test.

Returns:

  • None

TestGetOrCreateBloomFilter

Purpose: Tests the functionality of getting or creating a Bloom filter in the store.

Parameters:

  • t (*testing.T): Testing object for running the test.

Returns:

  • None

TestUpdateIndexes

Purpose: Tests the updating of indexes within the Bloom filter options.

Parameters:

  • t (*testing.T): Testing object for running the test.

Returns:

  • None

TestBloomOpts

Purpose: Tests the creation of Bloom filter options from string arguments, including validation of error rate and capacity.

Parameters:

  • t (*testing.T): Testing object for running the test.

Returns:

  • None

TestIsBitSet

Purpose: Tests the isBitSet function, which checks if a bit is set at a given index in a byte slice.

Parameters:

  • t (*testing.T): Testing object for running the test.

Returns:

  • None

TestSetBit

Purpose: Tests the setBit function, which sets a bit at a given index in a byte slice.

Parameters:

  • t (*testing.T): Testing object for running the test.

Returns:

  • None

TestBloomDeepCopy

Purpose: Tests the DeepCopy method of the Bloom struct, ensuring that a new, independent copy of the Bloom filter is created.

Parameters:

  • t (*testing.T): Testing object for running the test.

Returns:

  • None

Getting Started Relevance