def test_add(): a = Binary(123) b = Binary(345) c = Binary(468) assert a + b == c assert a.is_binary(a) assert a.is_binary(a + b)
def test_is_binary(): Bin = Binary() assert Bin.is_binary('10101') assert Bin.is_binary('0') assert not Bin.is_binary('102') assert not Bin.is_binary('1af0') assert not Bin.is_binary(10)
def test_mod_add(): a = Binary(234) b = Binary(345) c = Binary(500) d = Binary(579) assert a % b != c assert a % b != d d.set_size(len(b)) assert a % b == d assert a.is_binary(a) assert b.is_binary(b) assert c.is_binary(c) assert d.is_binary(d)