Skip to content

Commit

Permalink
Add an index test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Apr 11, 2015
1 parent 0cc37b2 commit f51f449
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions phf_macros/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,17 @@ mod ordered_map {
assert_eq!(None, MAP.get_index(&*"xyz".to_string()));
}

#[test]
fn test_index() {
static MAP: phf::OrderedMap<&'static str, isize> = phf_ordered_map!(
"foo" => 5,
"bar" => 6,
);
assert_eq!(Some((&"foo", &5)), MAP.index(0));
assert_eq!(Some((&"bar", &6)), MAP.index(1));
assert_eq!(None, MAP.index(2));
}

#[test]
fn test_entries() {
static MAP: phf::OrderedMap<&'static str, i32> = phf_ordered_map!(
Expand Down Expand Up @@ -442,6 +453,17 @@ mod ordered_set {
assert_eq!(None, SET.get_index(&*"xyz".to_string()));
}

#[test]
fn test_index() {
static MAP: phf::OrderedSet<&'static str> = phf_ordered_set!(
"foo",
"bar",
);
assert_eq!(Some(&"foo"), MAP.index(0));
assert_eq!(Some(&"bar"), MAP.index(1));
assert_eq!(None, MAP.index(2));
}

#[test]
fn test_iter() {
static SET: phf::OrderedSet<&'static str> = phf_ordered_set! {
Expand Down

0 comments on commit f51f449

Please sign in to comment.