Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kirillt opened this issue Jul 22, 2024 · 0 comments
Open

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

kirillt opened this issue Jul 22, 2024 · 0 comments

Comments

@kirillt
Copy link
Member

kirillt commented Jul 22, 2024

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
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant