Beispiel #1
0
 def test_can_bool(self):
     assert bool(U32(100)) is True
     assert bool(U32(0)) is False
Beispiel #2
0
 def test_can_invert(self):
     assert ~U32(100) == 0xffffff9b
Beispiel #3
0
 def test_can_truth(self):
     if U32(100):
         pass
     else:
         assert False, "U32(100) should be considered true"
Beispiel #4
0
 def test_can_pos(self):
     assert +U32(100) == U32(100)
Beispiel #5
0
 def test_can_abs(self):
     assert abs(U32(100)) == U32(100)
     assert abs(-U32(100)) == U32(100)
Beispiel #6
0
 def test_can_set_value_via_method(self):
     n = U32()
     assert '0x0' in n.__repr__()
     n.set(100)
     assert '0x64' in n.__repr__()
Beispiel #7
0
 def test_can_neg(self):
     assert -U32(100) == U32(100)
Beispiel #8
0
 def test_can_multiply(self):
     assert U32(10) * U32(5) == U32(50)
Beispiel #9
0
 def test_can_divide(self):
     assert U32(50) / U32(5) == U32(10)
Beispiel #10
0
 def test_can_sub(self):
     assert U32(100) - U32(0) == U32(100)
     assert U32(100) - U32(90) == U32(10)
Beispiel #11
0
 def test_can_sub_number_under_zero(self):
     assert U32(10) - U32(100) == U32(90)
Beispiel #12
0
 def test_can_add(self):
     assert U32(100) + U32(0) == U32(100)
     assert U32(10) + U32(90) == U32(100)
Beispiel #13
0
 def test_can_chr(self):
     assert U32(100).__chr__() == chr(ord('d'))
Beispiel #14
0
 def test_eq_values_are_eq(self):
     assert U32(100) == U32(100)
Beispiel #15
0
 def test_can_compare(self):
     assert U32(100) > U32(99)
     assert U32(99) < U32(100)
     assert U32(100) == U32(100)
Beispiel #16
0
 def test_can_mod(self):
     assert U32(100) % U32(10) == U32(0)
     assert U32(9) % U32(2) == U32(1)
Beispiel #17
0
 def test_can_pass_in_value_via_init(self):
     assert '0x64' in U32(100).__repr__()
Beispiel #18
0
 def test_negative_numbers_are_converted_to_positive(self):
     assert '0x64' in U32(-100).__repr__()