Пример #1
0
def test_xor():
    b_null = Bits()
    b_0 = Bits.from_bitstring("0")
    b_1 = Bits.from_bitstring("1")
    
    assert b_null.xor(b_null) == []
    assert b_0.xor(b_0) == [0]
    assert b_1.xor(b_0) == [1]
    assert b_0.xor(b_1) == [1]
    assert b_1.xor(b_1) == [0]

    b_00101 = Bits.from_bitstring("00101")
    b_11110 = Bits.from_bitstring("11110")
    assert b_00101.xor(b_11110) == [1, 1, 0, 1, 1]
Пример #2
0
def test_from_bitstring():
    assert str(Bits.from_bitstring("")) == ""
    assert str(Bits.from_bitstring("1")) == "1"
    assert str(Bits.from_bitstring("11010100010")) == "11010100010"
    assert str(Bits.from_bitstring("110 10100010")) == "11010100010"
    assert str(Bits.from_bitstring("110 1010 0010")) == "11010100010"
    assert str(Bits.from_bitstring("110,1010,0010")) == "11010100010"
    assert str(Bits.from_bitstring("0b11010100010")) == "11010100010"