From de37fa8f002eccea37b0c2ef1c1ef7ba606aff87 Mon Sep 17 00:00:00 2001 From: KAMADA Ken'ichi Date: Wed, 14 Dec 2016 22:08:51 +0900 Subject: [PATCH] Test if a constant variable can be used in the match arm. --- src/tag.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/tag.rs b/src/tag.rs index 66e75e4..2a5bdc1 100644 --- a/src/tag.rs +++ b/src/tag.rs @@ -306,3 +306,24 @@ generate_well_known_tag_constants!( (InteroperabilityIndex, 0x1, "Interoperability identification"), ); + +#[cfg(test)] +mod tests { + use tag; + use super::*; + + // This test checks if Tag constants can be used in patterns. + #[test] + fn tag_constant_in_pattern() { + // Destructuring, which will always work. + match Tag(Context::Tiff, 0x132) { + Tag(Context::Tiff, 0x132) => {}, + _ => panic!("failed to match Tag"), + } + // Matching against a constant. Test if this compiles. + match Tag(Context::Tiff, 0x132) { + tag::DateTime => {}, + _ => panic!("failed to match Tag"), + } + } +}