Skip to content

Commit

Permalink
add unit tests for Note.oct and String.asNote
Browse files Browse the repository at this point in the history
This should serve as a starting point for other unit tests.
  • Loading branch information
Adam Spiers committed Oct 21, 2017
1 parent 86527bd commit 2e16b88
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
29 changes: 29 additions & 0 deletions wslib-tests/TestExtVariousAsNote.sc
Original file line number Diff line number Diff line change
@@ -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");
25 changes: 25 additions & 0 deletions wslib-tests/TestNote.sc
Original file line number Diff line number Diff line change
@@ -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");

0 comments on commit 2e16b88

Please sign in to comment.