Notes and intervals
This commit is contained in:
62
tests/forth/notes.rs
Normal file
62
tests/forth/notes.rs
Normal file
@@ -0,0 +1,62 @@
|
||||
use super::harness::expect_int;
|
||||
|
||||
#[test]
|
||||
fn note_c4_is_middle_c() {
|
||||
expect_int("c4", 60);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn note_a4_is_440hz_reference() {
|
||||
expect_int("a4", 69);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn note_c0() {
|
||||
expect_int("c0", 12);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn note_sharps() {
|
||||
expect_int("c#4", 61);
|
||||
expect_int("cs4", 61);
|
||||
expect_int("f#3", 54);
|
||||
expect_int("fs3", 54);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn note_flats() {
|
||||
expect_int("db4", 61);
|
||||
expect_int("eb4", 63);
|
||||
expect_int("ab4", 68);
|
||||
expect_int("bb4", 70);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn note_all_naturals_octave4() {
|
||||
expect_int("c4", 60);
|
||||
expect_int("d4", 62);
|
||||
expect_int("e4", 64);
|
||||
expect_int("f4", 65);
|
||||
expect_int("g4", 67);
|
||||
expect_int("a4", 69);
|
||||
expect_int("b4", 71);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn note_octave_range() {
|
||||
expect_int("c0", 12);
|
||||
expect_int("c1", 24);
|
||||
expect_int("c2", 36);
|
||||
expect_int("c3", 48);
|
||||
expect_int("c5", 72);
|
||||
expect_int("c6", 84);
|
||||
expect_int("c7", 96);
|
||||
expect_int("c8", 108);
|
||||
expect_int("c9", 120);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn note_in_expression() {
|
||||
expect_int("c4 12 +", 72); // C4 + octave = C5
|
||||
expect_int("a4 c4 -", 9); // interval from C4 to A4
|
||||
}
|
||||
Reference in New Issue
Block a user