Skip to content

Commit

Permalink
test: Add SpinValue test
Browse files Browse the repository at this point in the history
  • Loading branch information
m-laniakea committed Nov 19, 2019
1 parent 97c3e33 commit a006552
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/test_spin_value.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import unittest

import stspin

from stspin.constants import (
SpinValue
)


class TestUtility(unittest.TestCase):

def testSpinValue(self) -> None:
with self.assertRaises(AssertionError):
SpinValue(-1)

self.assertEqual(SpinValue(1), SpinValue(1))
self.assertEqual(SpinValue(8), SpinValue(0) | SpinValue(8))
self.assertEqual(SpinValue(0xFF), SpinValue(0xF0) | SpinValue(0x0F))

self.assertEqual(SpinValue(22) == SpinValue(0o26), True)

self.assertEqual(f'{SpinValue(22)}', '22')

self.assertEqual(SpinValue(22), 22)
self.assertEqual(SpinValue(16) | 6, 22)

self.assertEqual(SpinValue(1) == '1', False)
self.assertEqual('1' == SpinValue(1), False)

self.assertEqual(SpinValue(1) == 1, True)
self.assertEqual(1 == SpinValue(1), True)


if __name__ == '__main__':
unittest.main()

0 comments on commit a006552

Please sign in to comment.