You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

2 months ago
  1. import stormpy
  2. class TestBitvector:
  3. def test_init_default(self):
  4. bit = stormpy.BitVector()
  5. assert bit.size() == 0
  6. assert bit.number_of_set_bits() == 0
  7. def test_init_length(self):
  8. bit = stormpy.BitVector(10)
  9. assert bit.size() == 10
  10. assert bit.number_of_set_bits() == 0
  11. bit = stormpy.BitVector(5, True)
  12. assert bit.size() == 5
  13. assert bit.number_of_set_bits() == 5
  14. def test_init_vector(self):
  15. bit = stormpy.BitVector(5, [2, 3])
  16. assert bit.size() == 5
  17. assert bit.number_of_set_bits() == 2
  18. assert bit.get(0) is False
  19. assert bit.get(1) is False
  20. assert bit.get(2) is True
  21. assert bit.get(3) is True
  22. assert bit.get(4) is False
  23. def test_init_bitvector(self):
  24. bit = stormpy.BitVector(7, [0, 6])
  25. bit2 = stormpy.BitVector(bit)
  26. assert bit == bit2
  27. assert bit2.get(0) is True
  28. assert bit2.get(6) is True
  29. def test_negate(self):
  30. bit = stormpy.BitVector(7, [0, 6])
  31. bit2 = stormpy.BitVector(bit)
  32. bit = ~bit
  33. assert bit.get(0) is False
  34. assert bit.get(6) is False
  35. for i in range(bit.size()):
  36. assert bit.get(i) is not bit2.get(i)