/// Tests the Weight Functions /// @return True if all tests were executed, false if not bool FontSettingTestSuite::TestCaseWeight() { //------Last Checked------// // - Dec 6, 2004 const int testValueCount = 17; wxInt32 testValues[testValueCount]; testValues[0] = FontSetting::weightDontCare; testValues[1] = FontSetting::weightThin; testValues[2] = FontSetting::weightExtraLight; testValues[3] = FontSetting::weightUltraLight; testValues[4] = FontSetting::weightLight; testValues[5] = FontSetting::weightNormal; testValues[6] = FontSetting::weightRegular; testValues[7] = FontSetting::weightMedium; testValues[8] = FontSetting::weightSemiBold; testValues[9] = FontSetting::weightDemiBold; testValues[10] = FontSetting::weightBold; testValues[11] = FontSetting::weightExtraBold; testValues[12] = FontSetting::weightUltraBold; testValues[13] = FontSetting::weightBlack; testValues[14] = FontSetting::weightHeavy; testValues[15] = -1; testValues[16] = 139; bool expectedResults[testValueCount]; expectedResults[0] = true; expectedResults[1] = true; expectedResults[2] = true; expectedResults[3] = true; expectedResults[4] = true; expectedResults[5] = true; expectedResults[6] = true; expectedResults[7] = true; expectedResults[8] = true; expectedResults[9] = true; expectedResults[10] = true; expectedResults[11] = true; expectedResults[12] = true; expectedResults[13] = true; expectedResults[14] = true; expectedResults[15] = false; expectedResults[16] = false; int i = 0; for (; i < testValueCount; i++) { TEST(wxString::Format(wxT("IsValidWeight - %d"), testValues[i]), (FontSetting::IsValidWeight(testValues[i]) == expectedResults[i])); FontSetting fontSetting; TEST(wxString::Format(wxT("SetWeight - %d"), testValues[i]), (fontSetting.SetWeight(testValues[i]) == expectedResults[i]) && ((!expectedResults[i]) ? 1 : (fontSetting.GetWeight() == testValues[i])) ); } return (true); }
/// 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); }
// 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); }
/// 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); }