Skip to content

fs-index: Split unit tests by two categories of hash functions #83

@kirillt

Description

@kirillt

In #79 we've entroduced for_each_type! macro allowing us to iterate through different types of ResourceId implementations and use the corresponding hash function.

Now, we could define two broad categories of "cryptographic" and "fast" hash functions another macro wrappers, so we can simply add new functions into one of the two categories, and the test cases will work with new functions automatically without necessity to update them manually.

This will allow us to describe invariants in generic terms, not specific functions:

fn test_no_collisions_with_cryptographic_hashing() {
    for_cryptographic_hashing! {
        // setup a folder without duplicates
        // index it
        assert_eq!(index.collisions, 0);
    }
}

On the other hand, we are still free to create custom test cases for one or two specific functions, these test cases will not be run excessively for functions that are not involved

fn test_no_collisions_with_cryptographic_hashing() {
    for_each_hashing!(take_first_byte, take_last_byte) {
        // setup a folder without duplicates
        // index it
        assert_eq!(index.keys.size(), 8); //synthetic example
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions