mirror of
https://github.com/mr0xb/spritetagger.git
synced 2026-08-27 20:44:56 -04:00
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
import unittest
|
|
|
|
import playback
|
|
|
|
|
|
class FramesWithLabel(unittest.TestCase):
|
|
def test_returns_sorted_indices_matching_label(self):
|
|
assignments = {5: 'walk', 1: 'walk', 3: 'idle', 8: 'walk'}
|
|
self.assertEqual(playback.frames_with_label(assignments, 'walk'), [1, 5, 8])
|
|
|
|
def test_ignores_other_labels(self):
|
|
assignments = {0: 'idle', 1: 'walk', 2: 'run'}
|
|
self.assertEqual(playback.frames_with_label(assignments, 'idle'), [0])
|
|
|
|
def test_no_matches_returns_empty(self):
|
|
assignments = {0: 'idle', 1: 'walk'}
|
|
self.assertEqual(playback.frames_with_label(assignments, 'jump'), [])
|
|
|
|
|
|
class NextInCycle(unittest.TestCase):
|
|
def test_steps_forward(self):
|
|
self.assertEqual(playback.next_in_cycle([1, 5, 8], 1, 1), 5)
|
|
|
|
def test_wraps_forward_at_end(self):
|
|
self.assertEqual(playback.next_in_cycle([1, 5, 8], 8, 1), 1)
|
|
|
|
def test_steps_backward(self):
|
|
self.assertEqual(playback.next_in_cycle([1, 5, 8], 5, -1), 1)
|
|
|
|
def test_wraps_backward_at_start(self):
|
|
self.assertEqual(playback.next_in_cycle([1, 5, 8], 1, -1), 8)
|
|
|
|
def test_current_not_in_set_returns_first(self):
|
|
self.assertEqual(playback.next_in_cycle([1, 5, 8], 3, 1), 1)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|