diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 18:37:05 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 18:37:05 +0000 |
commit | 145364a8af6a1fec06556221e66d4b724a62fc9a (patch) | |
tree | 53bd71a544008c518034f208d64c932dc2883f50 /src/base/test/accidentals.cpp | |
download | rosegarden-145364a8af6a1fec06556221e66d4b724a62fc9a.tar.gz rosegarden-145364a8af6a1fec06556221e66d4b724a62fc9a.zip |
Added old abandoned KDE3 version of the RoseGarden MIDI tool
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/rosegarden@1097595 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/base/test/accidentals.cpp')
-rw-r--r-- | src/base/test/accidentals.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/base/test/accidentals.cpp b/src/base/test/accidentals.cpp new file mode 100644 index 0000000..53dbfc8 --- /dev/null +++ b/src/base/test/accidentals.cpp @@ -0,0 +1,60 @@ +// -*- c-basic-offset: 4 -*- + +#include "NotationTypes.h" + +using namespace Rosegarden; +using std::cout; + +// Unit test-ish tests for resolving accidentals +// +// Returns -1 (or crashes :)) on error, 0 on success +void assertHasAccidental(Pitch &pitch, + const Accidental& accidental, const Key& key) +{ + Accidental calculatedAccidental = + pitch.getAccidental(key); + + std::cout << "Got " << calculatedAccidental << " for pitch " << pitch.getPerformancePitch() << " in key " << key.getName() << std::endl; + + if (calculatedAccidental != accidental) + { + std::cout << "Expected " << accidental << std::endl; + exit(-1); + } +} + +void testBInEMinor() +{ + // a B, also in E minor, has no accidental + Pitch testPitch(59 % 12); + assertHasAccidental(testPitch, + Accidentals::NoAccidental, Key("E minor")); +} + +/** + * + */ +void testFInBMinor() +{ + Pitch testPitch(77); + assertHasAccidental(testPitch, + Accidentals::NoAccidental, Key("B minor")); +} + +void testInvalidSuggestion() +{ + // If we specify an invalid suggestion, + // getAccidental() should be robust against that. + Pitch testPitch = Pitch(59, Accidentals::Sharp); + assertHasAccidental(testPitch, + Accidentals::NoAccidental, Key("E minor")); +} + +int main(int argc, char **argv) +{ + testBInEMinor(); + testFInBMinor(); + testInvalidSuggestion(); + std::cout << "Success" << std::endl; + exit(0); +} |