コード例 #1
0
/// Tests the Key Functions
/// @return True if all tests were executed, false if not
bool KeySignatureTestSuite::TestCaseKey()
{
    //------Last Checked------//
    // - Dec 11, 2004
    KeySignature keySignature;
    TEST(wxT("SetKey - invalid key type"), !keySignature.SetKey(44, KeySignature::threeFlats));
    TEST(wxT("SetKey - invalid key accidentals"), !keySignature.SetKey(KeySignature::minorKey, 44));
    TEST(wxT("SetKey - valid"), keySignature.SetKey(KeySignature::minorKey, KeySignature::threeFlats) &&
        (keySignature.GetKeyType() == KeySignature::minorKey) &&
        (keySignature.GetKeyAccidentals() == KeySignature::threeFlats)
    );
    
    // TEST CASE: IsSameKey
    {
        KeySignature keySignature(KeySignature::minorKey, KeySignature::threeFlats);
        keySignature.Show();
        KeySignature keySignature2(KeySignature::minorKey, KeySignature::threeFlats);
        KeySignature keySignature3(KeySignature::majorKey, KeySignature::threeFlats);
        KeySignature keySignature4(KeySignature::minorKey, KeySignature::fourFlats);
        TEST(wxT("IsSameKey - true"), keySignature.IsSameKey(keySignature2));
        TEST(wxT("IsSameKey - false"), !keySignature.IsSameKey(keySignature3));
        TEST(wxT("IsSameKey - false"), !keySignature.IsSameKey(keySignature4));
    }
    return (true);
}
コード例 #2
0
/// Tests the Key Accidentals Functions
/// @return True if all tests were executed, false if not
bool KeySignatureTestSuite::TestCaseKeyAccidentals()
{
    //------Last Checked------//
    // - Dec 11, 2004
    
    // TEST CASE: IsValidKeyAccidentals
    {
        wxByte i = KeySignature::noAccidentals;
        for (; i <= (KeySignature::sevenFlats + 1); i++)
            TEST(wxString::Format(wxT("IsValidKeyAccidentals - %d"), i), 
                (KeySignature::IsValidKeyAccidentals(i) == (i <= KeySignature::sevenFlats))
            );
    }
    
    KeySignature keySignature;
    wxByte i = KeySignature::noAccidentals;
    for (; i <= (KeySignature::sevenFlats + 1); i++)
        TEST(wxString::Format(wxT("SetKeyAccidentals - %d"), i), 
                (keySignature.SetKeyAccidentals(i) == (i <= KeySignature::sevenFlats)) &&
                ((i > KeySignature::sevenFlats) ? 1 : (keySignature.GetKeyAccidentals() == i))
            );
            
    // TEST CASE: HasNAccidentals
    {
        KeySignature keySignature;
        wxByte i = KeySignature::noAccidentals;
        for (; i <= KeySignature::sevenFlats; i++)
        {
            keySignature.SetKeyAccidentals(i);
            TEST(wxString::Format(wxT("HasNoKeyAccidentals - %d"), i), (keySignature.HasNoKeyAccidentals() == (i == KeySignature::noAccidentals)));
            TEST(wxString::Format(wxT("HasOneSharp - %d"), i), (keySignature.HasOneSharp() == (i == KeySignature::oneSharp)));
            TEST(wxString::Format(wxT("HasTwoSharps - %d"), i), (keySignature.HasTwoSharps() == (i == KeySignature::twoSharps)));
            TEST(wxString::Format(wxT("HasThreeSharps - %d"), i), (keySignature.HasThreeSharps() == (i == KeySignature::threeSharps)));
            TEST(wxString::Format(wxT("HasFourSharps - %d"), i), (keySignature.HasFourSharps() == (i == KeySignature::fourSharps)));
            TEST(wxString::Format(wxT("HasFiveSharps - %d"), i), (keySignature.HasFiveSharps() == (i == KeySignature::fiveSharps)));
            TEST(wxString::Format(wxT("HasSixSharps - %d"), i), (keySignature.HasSixSharps() == (i == KeySignature::sixSharps)));
            TEST(wxString::Format(wxT("HasSevenSharps - %d"), i), (keySignature.HasSevenSharps() == (i == KeySignature::sevenSharps)));
            TEST(wxString::Format(wxT("HasOneFlat - %d"), i), (keySignature.HasOneFlat() == (i == KeySignature::oneFlat)));
            TEST(wxString::Format(wxT("HasTwoFlats - %d"), i), (keySignature.HasTwoFlats() == (i == KeySignature::twoFlats)));
            TEST(wxString::Format(wxT("HasThreeFlats - %d"), i), (keySignature.HasThreeFlats() == (i == KeySignature::threeFlats)));
            TEST(wxString::Format(wxT("HasFourFlats - %d"), i), (keySignature.HasFourFlats() == (i == KeySignature::fourFlats)));
            TEST(wxString::Format(wxT("HasFiveFlats - %d"), i), (keySignature.HasFiveFlats() == (i == KeySignature::fiveFlats)));
            TEST(wxString::Format(wxT("HasSixFlats - %d"), i), (keySignature.HasSixFlats() == (i == KeySignature::sixFlats)));
            TEST(wxString::Format(wxT("HasSevenFlats - %d"), i), (keySignature.HasSevenFlats() == (i == KeySignature::sevenFlats)));
        }   
    }
    return (true);
}