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

Add helper tests for missing enum variants #49

Open
FreezyLemon opened this issue Apr 27, 2024 · 0 comments
Open

Add helper tests for missing enum variants #49

FreezyLemon opened this issue Apr 27, 2024 · 0 comments

Comments

@FreezyLemon
Copy link
Contributor

FreezyLemon commented Apr 27, 2024

Often, there are enums in the ffmpeg crate that have From<AVEnum> for Enum implementations (and vice versa). These will automatically show missing variants due to non-exhaustive match statements whenever a new FFmpeg version is released.

However, there are some enums where this doesn't work. Those could (and should) have a test, hidden behind a feature flag, to check whether the match statement on the AVEnum is exhaustive. Rough draft:

#[cfg(all(test, feature = "check-enums"))]
mod dev_test {
    fn exhaustive_av_option_type(x: AVOptionType) {
        match x {
            // all variants
        }
    }
}

(AVOptionType is a random example, it currently has an exhaustive match statement in its API). I think bitflags structs mostly benefit from this.

If someone starts adding these, they might aswell add these for all known enums while they're at it (and offload them to a separate test-only file). That would make it easy to just run cargo check -F check-enum or something whenever preparing for a new FFmpeg version.

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