Sha256: 077acb050d0efabdcc0964eb739f6ba29dd4079d281379993f743a1035b16a61

Contents?: true

Size: 1.3 KB

Versions: 107

Compression:

Stored size: 1.3 KB

Contents

#[macro_use]
extern crate macros;

use std::collections::HashMap;

#[test]
fn test_empty() {
    let expected: HashMap<usize, usize> = HashMap::new();
    let computed: HashMap<usize, usize> = hashmap!();
    assert_eq!(computed, expected);
}

#[test]
#[ignore]
fn test_no_trailing_comma() {
    let mut expected = HashMap::new();
    expected.insert(1, "one");
    expected.insert(2, "two");
    assert_eq!(hashmap!(1 => "one", 2 => "two"), expected);
}

#[test]
#[ignore]
fn test_trailing_comma() {
    let mut expected = HashMap::new();
    expected.insert('h', 89);
    expected.insert('a', 1);
    expected.insert('s', 19);
    expected.insert('h', 8);
    assert_eq!(
        hashmap!(
            'h' => 89,
            'a' => 1,
            's' => 19,
            'h' => 8,
        ),
        expected
    );
}

#[test]
#[ignore]
fn test_nested() {
    let mut expected = HashMap::new();
    expected.insert("non-empty", {
        let mut subhashmap = HashMap::new();
        subhashmap.insert(23, 623);
        subhashmap.insert(34, 21);
        subhashmap
    });
    expected.insert("empty", HashMap::new());
    assert_eq!(
        hashmap!(
            "non-empty" => hashmap!(
                23 => 623,
                34 => 21
            ),
            "empty" => hashmap!()
        ),
        expected
    );
}

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.179 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.178 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.177 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.176 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.175 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.174 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.173 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.172 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.171 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.170 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.169 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.167 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.166 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.165 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.164 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.163 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.162 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.161 tracks/rust/exercises/macros/tests/macros.rs
trackler-2.2.1.160 tracks/rust/exercises/macros/tests/macros.rs