def test_construct_source(elements):
    """
    GIVEN elements
    WHEN HashMap is constructed with the elements as the source
    THEN each element is contained in the underlying data structure.
    """
    test_hash_set = hash_set.HashSet(source=elements)

    for element in elements:
        assert test_hash_set._hash_map.exists(element)
def test_construct_capacity():
    """
    GIVEN capacity
    WHEN HashSet is constricted with the capacity
    THEN the underlying HashMap is constructed with the capacity.
    """
    capacity = 32

    test_hash_set = hash_set.HashSet(capacity)

    assert test_hash_set._hash_map.capacity == capacity
def test_clone_capacity(capacity):
    """
    GIVEN capacity
    WHEN HashMap is constructed with the capacity and cloned
    THEN the cloned HashSet's underlying HashMap has the capacity.
    """
    test_hash_set = hash_set.HashSet(capacity)

    cloned_hash_set = test_hash_set.clone()

    assert cloned_hash_set._hash_map.capacity == capacity
def test_iter(elements):
    """
    GIVEN elements
    WHEN the hash set is constructed with the elements and iterated over
    THEN the elements are returned.
    """
    test_hash_set = hash_set.HashSet(source=elements)

    element_set = set(iter(test_hash_set))
    assert len(element_set) == len(elements)
    for element in elements:
        assert element in element_set
def test_clone_elements(elements):
    """
    GIVEN elements
    WHEN the hash set is constructed with the elements and cloned
    THEN the cloned set has all elements.
    """
    test_hash_set = hash_set.HashSet(source=elements)

    cloned_hash_set = test_hash_set.clone()

    element_set = set(iter(cloned_hash_set))
    assert len(element_set) == len(elements)
    for element in elements:
        assert element in element_set
def empty_set():
    """Return empty HashSet."""
    return hash_set.HashSet()