Пример #1
0
/// Tests the PointSize Functions
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCasePointSize()
{
    //------Last Checked------//
    // - Dec 6, 2004
    
    const int testValueCount = 5;
    wxInt32 testValues[testValueCount];
    testValues[0] = FontSetting::MIN_POINTSIZE - 1;
    testValues[1] = FontSetting::MIN_POINTSIZE;
    testValues[2] = 12;
    testValues[3] = FontSetting::MAX_POINTSIZE;
    testValues[4] = FontSetting::MAX_POINTSIZE + 1;
    bool expectedResults[testValueCount];
    expectedResults[0] = false;
    expectedResults[1] = true;
    expectedResults[2] = true;
    expectedResults[3] = true;
    expectedResults[4] = false;
    
    int i = 0;
    for (; i < testValueCount; i++)
    {
        TEST(wxString::Format(wxT("IsValidPointSize - %d"), testValues[i]),
            (FontSetting::IsValidPointSize(testValues[i]) == expectedResults[i]));
        
        FontSetting fontSetting;
        TEST(wxString::Format(wxT("SetPointSize - %d"), testValues[i]), 
            (fontSetting.SetPointSize(testValues[i]) == expectedResults[i]) &&
            ((!expectedResults[i]) ? 1 :
                (fontSetting.GetPointSize() == testValues[i]))
        );
    }
        
    return (true);
}
Пример #2
0
/// Tests the SetFontSetting Function
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCaseSetFontSetting()
{
    //------Last Checked------//
    // - Dec 6, 2004
    FontSetting fontSetting;
    
    TEST(wxT("SetFontSetting - NULL facename"), 
        !fontSetting.SetFontSetting(NULL, 12, FontSetting::weightBold, true,
        true, true, wxColor(255,0,0)));
    TEST(wxT("SetFontSetting - invalid point size"), 
        !fontSetting.SetFontSetting(wxT("Arial"), 0, FontSetting::weightBold,
        true, true, true, wxColor(255,0,0)));
    TEST(wxT("SetFontSetting - invalid weight"), 
        !fontSetting.SetFontSetting(wxT("Arial"), 12, 139, true, true, true,
        wxColor(255,0,0)));
   
    TEST(wxT("SetFontSetting - valid"),
        fontSetting.SetFontSetting(wxT("Arial"), 12, FontSetting::weightBold,
        true, true, true, wxColor(255,0,0)) &&
        (fontSetting.GetFaceName() == wxT("Arial")) &&
        (fontSetting.GetPointSize() == 12) &&
        (fontSetting.GetWeight() == FontSetting::weightBold) &&
        (fontSetting.IsItalic()) &&
        (fontSetting.IsUnderline()) &&
        (fontSetting.IsStrikeOut()) &&
        (fontSetting.GetColor() == wxColor(255,0,0))
    );
    
    return (true);
}
Пример #3
0
// Test Case Functions
/// Tests the Constructors
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCaseConstructor()
{
    //------Last Checked------//
    // - Dec 6, 2004
    
    // TEST CASE: Default constructor
    {
        FontSetting fontSetting;
        TEST(wxT("Default Constructor"), 
            (fontSetting.GetFaceName() == FontSetting::DEFAULT_FACENAME) &&
            (fontSetting.GetPointSize() == FontSetting::DEFAULT_POINTSIZE) &&
            (fontSetting.GetWeight() == FontSetting::DEFAULT_WEIGHT) &&
            (fontSetting.IsItalic() == FontSetting::DEFAULT_ITALIC) &&
            (fontSetting.IsUnderline() == FontSetting::DEFAULT_UNDERLINE) &&
            (fontSetting.IsStrikeOut() == FontSetting::DEFAULT_STRIKEOUT) &&
            (fontSetting.GetColor() == FontSetting::DEFAULT_COLOR)
        );        
    }
    
    // TEST CASE: Primary constructor
    {
        FontSetting fontSetting(wxT("Arial"), 12, FontSetting::weightBold, true,
            true, true, wxColor(255,0,0));
        TEST(wxT("Primary Constructor"), 
            (fontSetting.GetFaceName() == wxT("Arial")) &&
            (fontSetting.GetPointSize() == 12) &&
            (fontSetting.GetWeight() == FontSetting::weightBold) &&
            (fontSetting.IsItalic()) &&
            (fontSetting.IsUnderline()) &&
            (fontSetting.IsStrikeOut()) &&
            (fontSetting.GetColor() == wxColor(255,0,0))
        );
    }
    
    // TEST CASE: Copy constructor
    {
        FontSetting fontSetting(wxT("Arial"), 12, FontSetting::weightBold, true,
            true, true, wxColor(255,0,0));
        FontSetting fontSetting2(fontSetting);
        TEST(wxT("Copy Constructor"), 
            (fontSetting2.GetFaceName() == wxT("Arial")) &&
            (fontSetting2.GetPointSize() == 12) &&
            (fontSetting2.GetWeight() == FontSetting::weightBold) &&
            (fontSetting2.IsItalic()) &&
            (fontSetting2.IsUnderline()) &&
            (fontSetting2.IsStrikeOut()) &&
            (fontSetting2.GetColor() == wxColor(255,0,0))
        );
    }
    
    return (true);
}
Пример #4
0
/// Tests the SetFontSettingFromString Function
/// @return True if all tests were executed, false if not
bool FontSettingTestSuite::TestCaseSetFontSettingFromString()
{
    //------Last Checked------//
    // - Dec 6, 2004
    FontSetting fontSetting;
    TEST(wxT("SetFontSettingFromString - NULL string"),
        !fontSetting.SetFontSettingFromString(NULL));
    
    // String format = comma delimited: FaceName,PointSize,Weight,Italic(T/F),
    // Underline(T/F),StrikeOut(T/F),Color
    TEST(wxT("SetFontSettingFromString - valid string"),
        fontSetting.SetFontSettingFromString(wxT("Arial,12,700,T,T,F,255")) && 
        (fontSetting.GetFaceName() == wxT("Arial")) &&
        (fontSetting.GetPointSize() == 12) &&
        (fontSetting.GetWeight() == FontSetting::weightBold) &&
        (fontSetting.IsItalic()) &&
        (fontSetting.IsUnderline()) &&
        (!fontSetting.IsStrikeOut()) &&
        (fontSetting.GetColor() == wxColor(255,0,0))
    );
    
    return (true);
}