Skip to content

Commit

Permalink
Add compile-fail test for equivalent UniCase keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobo1239 committed Aug 22, 2016
1 parent af56be4 commit 711515a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions phf_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ optional = true
[dev-dependencies.phf]
path = "../phf"
version = "=0.7.16"

[dev-dependencies.compiletest_rs]
version = "0.2"
10 changes: 10 additions & 0 deletions phf_macros/tests/compile-fail-unicase/equivalent-keys.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![feature(plugin)]
#![plugin(phf_macros)]

extern crate phf;
extern crate unicase;

static MAP: phf::Map<UniCase<&'static str>, isize> = phf_map!( //~ ERROR duplicate key UniCase("FOO")
UniCase("FOO") => 42, //~ NOTE one occurrence here
UniCase("foo") => 42, //~ NOTE one occurrence here
);
26 changes: 26 additions & 0 deletions phf_macros/tests/compiletest.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
extern crate compiletest_rs as compiletest;

use std::path::PathBuf;

#[allow(dead_code)]
fn run_mode(directory: &'static str, mode: &'static str) {
let mut config = compiletest::default_config();
let cfg_mode = mode.parse().ok().expect("Invalid mode");

config.mode = cfg_mode;
config.target_rustcflags = Some("-L target/debug/".to_owned());
config.src_base = PathBuf::from(format!("tests/{}", directory));

compiletest::run_tests(&config);
}

// #[test]
// fn compile_test() {
// run_mode("compile-fail", "compile-fail");
// }

#[cfg(feature = "unicase_support")]
#[test]
fn compile_test_unicase() {
run_mode("compile-fail-unicase", "compile-fail");
}

0 comments on commit 711515a

Please sign in to comment.