示例#1
0
void LabelTestCase::GetLabelText()
{
    // test calls to SetLabel() and then to GetLabelText()

    const wxString& testLabel = "label without mnemonics and markup";
    SET_LABEL(testLabel);
    CPPUNIT_ASSERT_EQUAL( testLabel, m_st->GetLabelText() );
    CPPUNIT_ASSERT_EQUAL( testLabel, m_cb->GetLabelText() );

    const wxString& testLabel2 = "label with &mnemonic";
    const wxString& testLabelText2 = "label with mnemonic";
    SET_LABEL(testLabel2);
    CPPUNIT_ASSERT_EQUAL( testLabelText2, m_st->GetLabelText() );
    CPPUNIT_ASSERT_EQUAL( testLabelText2, m_cb->GetLabelText() );

    const wxString& testLabel3 = "label with <span foreground='blue'>some</span> <b>markup</b>";
    SET_LABEL(testLabel3);
    CPPUNIT_ASSERT_EQUAL( testLabel3, m_st->GetLabelText() );
    CPPUNIT_ASSERT_EQUAL( testLabel3, m_cb->GetLabelText() );

    const wxString& testLabel4 = "label with <span foreground='blue'>some</span> <b>markup</b> and &mnemonic";
    const wxString& testLabelText4 = "label with <span foreground='blue'>some</span> <b>markup</b> and mnemonic";
    SET_LABEL(testLabel4);
    CPPUNIT_ASSERT_EQUAL( testLabelText4, m_st->GetLabelText() );
    CPPUNIT_ASSERT_EQUAL( testLabelText4, m_cb->GetLabelText() );


    const wxString testLabelArray[] = {
        "label without mnemonics and markup",
        "label with &mnemonic",
        "label with <span foreground='blue'>some</span> <b>markup</b>",
        "label with <span foreground='blue'>some</span> <b>markup</b> and &mnemonic",
    };

    // test calls to SetLabelText() and then to GetLabelText()

    for ( unsigned int s = 0; s < WXSIZEOF(testLabelArray); s++ )
    {
        SET_LABEL_TEXT(testLabelArray[s]);

        // GetLabelText() should always return the string passed to SetLabelText()
        CPPUNIT_ASSERT_EQUAL( testLabelArray[s], m_st->GetLabelText() );
        CPPUNIT_ASSERT_EQUAL( testLabelArray[s], m_cb->GetLabelText() );
    }
}