Add comprehensive tests for toSpelledPitch(Pitch) and toPitch(SpelledPitch).
This commit is contained in:
@@ -387,3 +387,63 @@ when isMainModule:
|
||||
assert "#5" == $toScaleDegree(
|
||||
Key(tonic: parseSpelledPitch("Eb"), mode: Ionian),
|
||||
parseSpelledPitch("B"))
|
||||
|
||||
assert toSpelledPitch(Pitch.F + 2) ==
|
||||
SpelledPitch(note: Note.G, alteration: naNatural)
|
||||
|
||||
let pitchCases = [
|
||||
(Pitch.Af, SpelledPitch(note: Note.A, alteration: naFlat)),
|
||||
(Pitch.A, SpelledPitch(note: Note.A, alteration: naNatural)),
|
||||
(Pitch.Bf, SpelledPitch(note: Note.B, alteration: naFlat)),
|
||||
(Pitch.B, SpelledPitch(note: Note.B, alteration: naNatural)),
|
||||
(Pitch.C, SpelledPitch(note: Note.C, alteration: naNatural)),
|
||||
(Pitch.Df, SpelledPitch(note: Note.D, alteration: naFlat)),
|
||||
(Pitch.D, SpelledPitch(note: Note.D, alteration: naNatural)),
|
||||
(Pitch.Ef, SpelledPitch(note: Note.E, alteration: naFlat)),
|
||||
(Pitch.E, SpelledPitch(note: Note.E, alteration: naNatural)),
|
||||
(Pitch.F, SpelledPitch(note: Note.F, alteration: naNatural)),
|
||||
(Pitch.Gf, SpelledPitch(note: Note.G, alteration: naFlat)),
|
||||
(Pitch.G, SpelledPitch(note: Note.G, alteration: naNatural)),
|
||||
]
|
||||
for (pitch, expected) in pitchCases:
|
||||
assert toSpelledPitch(pitch) == expected
|
||||
|
||||
let spelledPitchCases = [
|
||||
("Ab", Pitch.Af),
|
||||
("G#", Pitch.Af),
|
||||
("A", Pitch.A),
|
||||
("G##", Pitch.A),
|
||||
("Bbb", Pitch.A),
|
||||
("Bb", Pitch.Bf),
|
||||
("A#", Pitch.Bf),
|
||||
("Cbb", Pitch.Bf),
|
||||
("B", Pitch.B),
|
||||
("Cb", Pitch.B),
|
||||
("A##", Pitch.B),
|
||||
("C", Pitch.C),
|
||||
("B#", Pitch.C),
|
||||
("Dbb", Pitch.C),
|
||||
("Db", Pitch.Df),
|
||||
("C#", Pitch.Df),
|
||||
("B##", Pitch.Df),
|
||||
("D", Pitch.D),
|
||||
("C##", Pitch.D),
|
||||
("Ebb", Pitch.D),
|
||||
("Eb", Pitch.Ef),
|
||||
("D#", Pitch.Ef),
|
||||
("Fbb", Pitch.Ef),
|
||||
("E", Pitch.E),
|
||||
("Fb", Pitch.E),
|
||||
("D##", Pitch.E),
|
||||
("F", Pitch.F),
|
||||
("E#", Pitch.F),
|
||||
("Gbb", Pitch.F),
|
||||
("Gb", Pitch.Gf),
|
||||
("F#", Pitch.Gf),
|
||||
("E##", Pitch.Gf),
|
||||
("G", Pitch.G),
|
||||
("F##", Pitch.G),
|
||||
("Abb", Pitch.G),
|
||||
]
|
||||
for (spelled, expected) in spelledPitchCases:
|
||||
assert parseSpelledPitch(spelled).toPitch == expected
|
||||
|
||||
Reference in New Issue
Block a user