Permalink
Browse files

Added unit tests

  • Loading branch information...
1 parent 92a3d7c commit 88803abfb93e9ea907bebe949cf7881642700c82 @ppaez committed Jan 20, 2014
Showing with 51 additions and 0 deletions.
  1. +51 −0 test_alsamidi.py
View
51 test_alsamidi.py
@@ -1,5 +1,56 @@
from unittest import TestCase
+
+class NoteEvent(TestCase):
+
+ def test(self):
+ from alsamidi import noteevent
+
+ midi_event = (1, 60, 127, 1000, 10)
+ data = (1, 60, 127, 0, 10)
+ expected = (5, 1, 0, 0, (1, 0), (0, 0), (0, 0), data)
+ self.assertEqual(expected, noteevent(*midi_event))
+
+
+class NoteOnEvent(TestCase):
+
+ def test(self):
+ from alsamidi import noteonevent
+
+ midi_event = (1, 60, 127)
+ data = (1, 60, 127, 0, 0)
+ expected = (6, 1, 0, 253, (0, 0), (0, 0), (0, 0), data)
+ self.assertEqual(expected, noteonevent(*midi_event))
+
+
+class NoteOffEvent(TestCase):
+
+ def test(self):
+ from alsamidi import noteoffevent
+
+ midi_event = (1, 60, 10)
+ data = (1, 60, 10, 0, 0)
+ expected = (7, 1, 0, 253, (0, 0), (0, 0), (0, 0), data)
+ self.assertEqual(expected, noteoffevent(*midi_event))
+
+
+class PgmChangeEvent(TestCase):
+
+ def test_sent_directly(self):
+ from alsamidi import pgmchangeevent
+
+ data = (1, 0, 0, 0, 0, 9)
+ expected = (11, 1, 0, 253, (0, 0), (0, 0), (0, 0), data)
+ self.assertEqual(expected, pgmchangeevent(1, 9))
+
+ def test_scheduled(self):
+ from alsamidi import pgmchangeevent
+
+ data = (1, 0, 0, 0, 0, 9)
+ expected = (11, 1, 0, 0, (1, 0), (0, 0), (0, 0), data)
+ self.assertEqual(expected, pgmchangeevent(1, 9, 1000))
+
+
class Merge(TestCase):
def test_no_tracks(self):

0 comments on commit 88803ab

Please sign in to comment.