2019-07-02 21:40:50 +00:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
import colours
|
|
|
|
|
|
|
|
HGRColours = colours.HGRColours
|
|
|
|
|
|
|
|
|
|
|
|
class TestColours(unittest.TestCase):
|
|
|
|
|
2019-07-07 20:13:28 +00:00
|
|
|
def test_dots_to_pixels(self):
|
2019-07-02 21:40:50 +00:00
|
|
|
self.assertEqual(
|
|
|
|
(
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.DARK_BLUE,
|
|
|
|
HGRColours.MED_BLUE,
|
|
|
|
HGRColours.AQUA,
|
|
|
|
HGRColours.AQUA,
|
|
|
|
HGRColours.GREEN,
|
|
|
|
HGRColours.BROWN,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
2019-07-04 14:21:20 +00:00
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK
|
2019-07-02 21:40:50 +00:00
|
|
|
),
|
2019-07-07 20:13:28 +00:00
|
|
|
colours.dots_to_nominal_colour_pixels(
|
|
|
|
31, 0b00000000000000000000111000000000, HGRColours, init_phase=0
|
2019-07-02 21:40:50 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
(
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.MAGENTA,
|
|
|
|
HGRColours.VIOLET,
|
|
|
|
HGRColours.LIGHT_BLUE,
|
|
|
|
HGRColours.WHITE,
|
|
|
|
HGRColours.AQUA,
|
|
|
|
HGRColours.GREEN,
|
|
|
|
HGRColours.BROWN,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.MAGENTA,
|
|
|
|
HGRColours.VIOLET,
|
|
|
|
HGRColours.LIGHT_BLUE,
|
|
|
|
HGRColours.WHITE,
|
|
|
|
HGRColours.AQUA,
|
|
|
|
HGRColours.GREEN,
|
|
|
|
HGRColours.BROWN,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.MAGENTA,
|
|
|
|
HGRColours.VIOLET,
|
|
|
|
HGRColours.LIGHT_BLUE,
|
|
|
|
HGRColours.WHITE,
|
|
|
|
HGRColours.AQUA,
|
|
|
|
HGRColours.GREEN,
|
|
|
|
HGRColours.BROWN,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
2019-07-04 14:21:20 +00:00
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
|
|
|
HGRColours.BLACK,
|
2019-07-02 21:40:50 +00:00
|
|
|
HGRColours.BLACK
|
|
|
|
),
|
2019-07-07 20:13:28 +00:00
|
|
|
colours.dots_to_nominal_colour_pixels(
|
|
|
|
31, 0b0000111100001111000011110000, HGRColours, init_phase=0
|
2019-07-02 21:40:50 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class TestRolRoR(unittest.TestCase):
|
|
|
|
def testRolOne(self):
|
|
|
|
self.assertEqual(0b1111, colours.rol(0b1111, 1))
|
|
|
|
self.assertEqual(0b0001, colours.rol(0b1000, 1))
|
|
|
|
self.assertEqual(0b1010, colours.rol(0b0101, 1))
|
|
|
|
|
|
|
|
def testRolMany(self):
|
|
|
|
self.assertEqual(0b1111, colours.rol(0b1111, 3))
|
|
|
|
self.assertEqual(0b0010, colours.rol(0b1000, 2))
|
|
|
|
self.assertEqual(0b0101, colours.rol(0b0101, 2))
|
|
|
|
|
|
|
|
def testRorOne(self):
|
|
|
|
self.assertEqual(0b1111, colours.ror(0b1111, 1))
|
|
|
|
self.assertEqual(0b1000, colours.ror(0b0001, 1))
|
|
|
|
self.assertEqual(0b0101, colours.ror(0b1010, 1))
|
|
|
|
|
|
|
|
def testRoRMany(self):
|
|
|
|
self.assertEqual(0b1111, colours.ror(0b1111, 3))
|
|
|
|
self.assertEqual(0b1000, colours.ror(0b0010, 2))
|
|
|
|
self.assertEqual(0b0101, colours.ror(0b0101, 2))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|