2
0
mirror of https://github.com/sharkdp/bat synced 2024-11-18 15:26:16 +00:00
bat/tests/no_duplicate_extensions.rs

33 lines
1.0 KiB
Rust
Raw Normal View History

2020-03-15 13:14:01 +00:00
use std::collections::HashSet;
use bat::assets::HighlightingAssets;
2020-03-15 13:14:01 +00:00
#[test]
fn no_duplicate_extensions() {
const KNOWN_EXCEPTIONS: &[&str] = &[
2020-03-15 13:14:01 +00:00
// The '.h' extension currently appears in multiple syntaxes: C, C++, Objective C,
// Objective C++
"h",
// In addition to the standard JavaScript syntax in 'Packages', we also ship the
// 'Javascript (Babel)' syntax.
"js",
// The "Ruby Haml" syntax also comes with a '.sass' extension. However, we make sure
// that 'sass' is mapped to the 'Sass' syntax.
"sass",
];
let assets = HighlightingAssets::from_binary();
2020-03-15 13:14:01 +00:00
let mut extensions = HashSet::new();
2020-03-21 19:01:36 +00:00
for syntax in assets.syntaxes() {
2020-03-15 13:14:01 +00:00
for extension in &syntax.file_extensions {
assert!(
KNOWN_EXCEPTIONS.contains(&extension.as_str()) || extensions.insert(extension),
"File extension / pattern \"{}\" appears twice in the syntax set",
extension
);
}
}
}