aboutsummaryrefslogtreecommitdiff
path: root/test/long_mode/regspec.rs
blob: f92ec893088af69f4335ebcffe8d50c2ad91095f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use yaxpeax_x86::long_mode::{register_class, RegSpec};
use std::collections::{BTreeMap, HashMap};

#[test]
fn test_ord() {
    let _: BTreeMap<RegSpec, u64> = BTreeMap::new();
}

#[test]
fn test_hash() {
    let _: HashMap<RegSpec, u64> = HashMap::new();
}

#[test]
fn test_labels() {
    assert_eq!(RegSpec::rip().name(), "rip");
    assert_eq!(RegSpec::eip().name(), "eip");
    assert_eq!(RegSpec::rflags().name(), "rflags");
    assert_eq!(RegSpec::rbp().name(), "rbp");
    assert_eq!(RegSpec::gs().name(), "gs");
    assert_eq!(RegSpec::al().name(), "al");
}

#[test]
fn test_bank_names() {
    assert_eq!(RegSpec::al().class().name(), "byte");
    assert_eq!(RegSpec::r8b().class().name(), "rex-byte");
    assert_eq!(RegSpec::ax().class().name(), "word");
    assert_eq!(RegSpec::eax().class().name(), "dword");
    assert_eq!(RegSpec::rax().class().name(), "qword");
    assert_eq!(RegSpec::fs().class().name(), "segment");
    assert_eq!(RegSpec::eflags().class().name(), "eflags");
    assert_eq!(RegSpec::rflags().class().name(), "rflags");
    assert_eq!(RegSpec::eip().class().name(), "eip");
    assert_eq!(RegSpec::rip().class().name(), "rip");
    assert_eq!(RegSpec::st0().class().name(), "x87-stack");
    assert_eq!(RegSpec::mm0().class().name(), "mmx");
    assert_eq!(RegSpec::xmm0().class().name(), "xmm");
    assert_eq!(RegSpec::ymm0().class().name(), "ymm");
    assert_eq!(RegSpec::zmm0().class().name(), "zmm");
}

// this should compile.
#[test]
fn match_bank_kind() {
    match RegSpec::al().class() {
        register_class::X => {
            panic!("al is an xmm register? don't think so");
        }
        register_class::B => {
            println!("al is a byte register");
        }
        other => {
            panic!("unknown register kind: {:?}", other);
        }
    }
}