diff --git a/wslib-tests/TestExtVariousAsNote.sc b/wslib-tests/TestExtVariousAsNote.sc new file mode 100644 index 0000000..b3ea729 --- /dev/null +++ b/wslib-tests/TestExtVariousAsNote.sc @@ -0,0 +1,29 @@ +TestStringExtVariousAsNote : UnitTest { + setUp { + } + + tearDown { + } + + test_asNote { + [ + ["B1", 47], + ["C2", 48], + ["C#2", 49], + ["B2", 59], + ["C3", 60], + ["C#3", 61], + ["B3", 71], + ].do { |pair| + var in = pair[0], expected = pair[1]; + var got = in.asNote; + this.assertEquals(got.class, Note); + this.assertEquals(got.midi, expected); + }; + } +} + +// To test, use one of the following approaches: +// +// UnitTest.gui; +// UnitTest.runTest("TestExtVariousAsNote:test_asNote"); diff --git a/wslib-tests/TestNote.sc b/wslib-tests/TestNote.sc new file mode 100644 index 0000000..93ddcba --- /dev/null +++ b/wslib-tests/TestNote.sc @@ -0,0 +1,25 @@ +TestNote : UnitTest { + setUp { + } + + tearDown { + } + + test_oct { + [ + ["C3", 3], + ["Cb3", 2], + ["B#4", 5], + ].do { |pair| + var in = pair[0], expected = pair[1]; + var got = in.asNote; + this.assertEquals(got.oct, expected); + }; + } +} + +// To test, use one of the following approaches: +// +// UnitTest.gui; +// UnitTest.runTestClassForClass(Note); +// UnitTest.runTest("TestNote:test_oct");