diff options
Diffstat (limited to 'src/argaze.test')
-rw-r--r-- | src/argaze.test/DataStructures.py | 54 | ||||
-rw-r--r-- | src/argaze.test/GazeFeatures.py | 20 |
2 files changed, 74 insertions, 0 deletions
diff --git a/src/argaze.test/DataStructures.py b/src/argaze.test/DataStructures.py new file mode 100644 index 0000000..cab3a31 --- /dev/null +++ b/src/argaze.test/DataStructures.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python + +import unittest + +from argaze import DataStructures + +class TestTimeStampedBufferClass(unittest.TestCase): + """Test TimeStampedBuffer class.""" + + def test_new(self): + """Test TimeStampedBuffer creation.""" + + # Check TimeStampedBuffer length after creation + self.assertEqual(len(DataStructures.TimeStampedBuffer()), 0) + self.assertEqual(len(DataStructures.TimeStampedBuffer({0: ""})), 1) + self.assertEqual(len(DataStructures.TimeStampedBuffer({0.1: ""})), 1) + self.assertEqual(len(DataStructures.TimeStampedBuffer({0: "A", 1: "B"})), 2) + + # Check TimeStampedBuffer keys after creation + self.assertEqual(list(DataStructures.TimeStampedBuffer().keys()), []) + self.assertEqual(list(DataStructures.TimeStampedBuffer({0: ""}).keys()), [0]) + self.assertEqual(list(DataStructures.TimeStampedBuffer({0.1: ""}).keys()), [0.1]) + self.assertEqual(list(DataStructures.TimeStampedBuffer({0: "A", 1: "B"}).keys()), [0, 1]) + + # Check TimeStampedBuffer items after creation + self.assertEqual(list(DataStructures.TimeStampedBuffer().items()), []) + self.assertEqual(list(DataStructures.TimeStampedBuffer({0: ""}).items()), [(0, "")]) + self.assertEqual(list(DataStructures.TimeStampedBuffer({0.1: ""}).items()), [(0.1, "")]) + self.assertEqual(list(DataStructures.TimeStampedBuffer({0: "A", 1: "B"}).items()), [(0, "A"), (1, "B")]) + + # Check that TimeStampedBuffer creation fails when keys are not numbers + with self.assertRaises(AssertionError): + + DataStructures.TimeStampedBuffer({"first": ""}) + + def test_str(self): + """Test TimeStampedBuffer string representation.""" + + self.assertEqual(str(DataStructures.TimeStampedBuffer()), "{}") + self.assertEqual(str(DataStructures.TimeStampedBuffer({0: ""})), "{\"0\": \"\"}") + self.assertEqual(str(DataStructures.TimeStampedBuffer({0.1: ""})), "{\"0.1\": \"\"}") + + def test_append(self): + """Test TimeStampedBuffer append method.""" + + ts_buffer = DataStructures.TimeStampedBuffer({0: "A", 1: "B"}) + ts_buffer_next = DataStructures.TimeStampedBuffer({2: "C", 3: "D"}) + + self.assertEqual(len(ts_buffer.append(ts_buffer_next)), 4) + self.assertEqual(list(ts_buffer.append(ts_buffer_next).keys()), [0, 1, 2, 3]) + +if __name__ == '__main__': + + unittest.main()
\ No newline at end of file diff --git a/src/argaze.test/GazeFeatures.py b/src/argaze.test/GazeFeatures.py new file mode 100644 index 0000000..692b6cf --- /dev/null +++ b/src/argaze.test/GazeFeatures.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +import unittest + +from argaze import GazeFeatures + +class TestGazePositionClass(unittest.TestCase): + """Test GazePosition class.""" + + def test_new(self): + """Test GazePosition creation.""" + + # Check empty GazePosition + empty_gaze_position = GazeFeatures.GazePosition() + self.assertEqual(empty_gaze_position.value, (0, 0)) + self.assertEqual(empty_gaze_position.accuracy, 0.) + +if __name__ == '__main__': + + unittest.main()
\ No newline at end of file |