Exemple #1
0
    def test_register_set_second_byte(self) -> None:
        r = MIIRegister(3, 4)
        r.set_byte(1, 0xCC)
        assert len(r.as_bytes()) == 2
        assert r.as_bytes()[0] == 0
        assert r.as_bytes()[1] == 0xCC
        assert r.get_byte(0) == r.as_bytes()[0]
        assert r.get_byte(1) == r.as_bytes()[1]

        assert r.as_number() == 0xCC00
        assert r.as_number(signed=True) == -13312
Exemple #2
0
    def test_register_set_both_bytes(self) -> None:
        r = MIIRegister(3, 4)
        r.set_byte(0, 0xCC)
        r.set_byte(1, 0xDD)
        assert len(r.as_bytes()) == 2
        assert r.as_bytes()[0] == 0xCC
        assert r.as_bytes()[1] == 0xDD
        assert r.get_byte(0) == r.as_bytes()[0]
        assert r.get_byte(1) == r.as_bytes()[1]

        assert r.as_number() == 0xDDCC
Exemple #3
0
    def test_register_set_first_byte(self) -> None:
        r = MIIRegister(3, 4)
        r.set_byte(0, 100)
        assert len(r.as_bytes()) == 2
        assert r.as_bytes()[0] == 100
        assert r.as_bytes()[1] == 0
        assert r.get_byte(0) == r.as_bytes()[0]
        assert r.get_byte(1) == r.as_bytes()[1]

        assert r.as_number() == 100
        assert r.as_number(signed=True) == 100