From 0788a45b3e943609e19f8c586384997376827dee Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Mon, 10 Nov 2008 01:23:45 +0000 Subject: [PATCH] Originally committed to SVN as r2442. --- assdraw/src/settings.cpp | 8 ++-- unit_test/src/athenasub/test_time.cpp | 65 +++++++++++++++++---------- unit_test/src/main.cpp | 2 + unit_test/src/suites.h | 15 ++++++- 4 files changed, 61 insertions(+), 29 deletions(-) diff --git a/assdraw/src/settings.cpp b/assdraw/src/settings.cpp index ea42321b4..be5c3ef0d 100644 --- a/assdraw/src/settings.cpp +++ b/assdraw/src/settings.cpp @@ -67,14 +67,14 @@ void ASSDrawSettingsDialog::Init() #define APPENDCOLOURPROP(pgid, label, color) pgid = propgrid->Append( wxColourProperty(label, wxPG_LABEL, color) ); #define APPENDUINTPROP(pgid, label, uint) \ - pgid = propgrid->Append( wxUIntProperty(label, wxPG_LABEL, uint) ); \ + pgid = propgrid->Append(wxUIntProperty(label, wxPG_LABEL, uint) ); \ propgrid->SetPropertyValidator( pgid, validator ); #define APPENDBOOLPROP(pgid, label, boolvar) \ - pgid = propgrid->Append( wxBoolProperty (label, wxPG_LABEL, boolvar ) ); \ + pgid = propgrid->Append(wxBoolProperty (label, wxPG_LABEL, boolvar ) ); \ propgrid->SetPropertyAttribute( pgid, wxPG_BOOL_USE_CHECKBOX, (long)1 ); wxLongPropertyValidator validator(0x0,0xFF); - propgrid->Append( wxPropertyCategory(_T("Appearance"),wxPG_LABEL) ); + propgrid->Append(wxPropertyCategory(_T("Appearance"),wxPG_LABEL) ); APPENDCOLOURPROP(colors_canvas_bg_pgid, _T("Canvas"), m_frame->colors.canvas_bg) APPENDCOLOURPROP(colors_canvas_shape_normal_pgid, _T("Drawing"), m_frame->colors.canvas_shape_normal) APPENDUINTPROP(alphas_canvas_shape_normal_pgid, _T("Drawing @"), m_frame->alphas.canvas_shape_normal) @@ -97,7 +97,7 @@ void ASSDrawSettingsDialog::Init() APPENDCOLOURPROP(colors_ruler_h_pgid, _T("H ruler"), m_frame->colors.ruler_h) APPENDCOLOURPROP(colors_ruler_v_pgid, _T("V ruler"), m_frame->colors.ruler_v) - propgrid->Append( wxPropertyCategory(_T("Behaviors"),wxPG_LABEL) ); + propgrid->Append(wxPropertyCategory(_T("Behaviors"),wxPG_LABEL) ); APPENDBOOLPROP(behaviors_capitalizecmds_pgid, _T("Capitalize commands"), m_frame->behaviors.capitalizecmds); APPENDBOOLPROP(behaviors_autoaskimgopac_pgid, _T("Ask for image opacity"), m_frame->behaviors.autoaskimgopac); APPENDBOOLPROP(behaviors_parse_spc_pgid, _T("Parse S/P/C"), m_frame->behaviors.parse_spc); diff --git a/unit_test/src/athenasub/test_time.cpp b/unit_test/src/athenasub/test_time.cpp index a9670650d..e6c1b2f1e 100644 --- a/unit_test/src/athenasub/test_time.cpp +++ b/unit_test/src/athenasub/test_time.cpp @@ -33,10 +33,12 @@ // Contact: mailto:zeratul@cellosoft.com // +#include "../suites.h" +#if ATHENASUB_TEST == 1 + #include #include -#include "../../../aegilib/include/athenasub/athenasub.h" -#include "../suites.h" +#include "../../../athenasub/include/athenasub/athenasub.h" using namespace Athenasub; @@ -44,51 +46,66 @@ class AthenasubTimeTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(AthenasubTimeTest); CPPUNIT_TEST(testBounds); CPPUNIT_TEST(testComparison); + CPPUNIT_TEST(testOperators); + CPPUNIT_TEST(testSetGet); CPPUNIT_TEST_SUITE_END(); private: - Time a; - Time *b; - Time *c; - Time *d; - Time e; public: void setUp() { - a; - b = new Time(0); - c = new Time(5000); - d = new Time(-500); - e.SetMS(-1000); } void tearDown() { - delete b; - delete c; } void testComparison() { + Time a; + Time b(0); + Time c(5000); + Time d(-500); + CPPUNIT_ASSERT(a == a); CPPUNIT_ASSERT(a <= a); CPPUNIT_ASSERT(a >= a); - CPPUNIT_ASSERT(a == *b); - CPPUNIT_ASSERT(a == *d); - CPPUNIT_ASSERT(a != *c); - CPPUNIT_ASSERT(*b != *c); - CPPUNIT_ASSERT(a < *c); - CPPUNIT_ASSERT(a <= *c); - CPPUNIT_ASSERT(*c > *b); - CPPUNIT_ASSERT(*c >= *b); + CPPUNIT_ASSERT(a == b); + CPPUNIT_ASSERT(a == d); + CPPUNIT_ASSERT(a != c); + CPPUNIT_ASSERT(b != c); + CPPUNIT_ASSERT(a < c); + CPPUNIT_ASSERT(a <= c); + CPPUNIT_ASSERT(c > b); + CPPUNIT_ASSERT(c >= b); } void testBounds() { - CPPUNIT_ASSERT(d->GetMS() >= 0); - CPPUNIT_ASSERT(e.GetMS() >= 0); + Time a(-500); + CPPUNIT_ASSERT(a.GetMS() >= 0); + } + + void testSetGet() + { + Time a; + CPPUNIT_ASSERT(a.GetMS() == 0); + a.SetMS(5000); + CPPUNIT_ASSERT(a.GetMS() == 5000); + a.SetMS(-5000); + CPPUNIT_ASSERT(a.GetMS() == 0); + } + + void testOperators() + { + Time a(500); + CPPUNIT_ASSERT(a + 300 == Time(800)); + CPPUNIT_ASSERT(a - 300 == Time(200)); + CPPUNIT_ASSERT(a - 600 == Time(0)); } }; CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(AthenasubTimeTest,AegisubSuites::athenasub()); + +#endif diff --git a/unit_test/src/main.cpp b/unit_test/src/main.cpp index 17cc8b030..9150e3881 100644 --- a/unit_test/src/main.cpp +++ b/unit_test/src/main.cpp @@ -48,7 +48,9 @@ int main() { CppUnit::TextUi::TestRunner runner; +#if ATHENASUB_TEST == 1 runner.addTest(CppUnit::TestFactoryRegistry::getRegistry(AegisubSuites::athenasub()).makeTest()); +#endif runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); bool result = runner.run("",false); diff --git a/unit_test/src/suites.h b/unit_test/src/suites.h index 26cdac39b..1f7ec79e4 100644 --- a/unit_test/src/suites.h +++ b/unit_test/src/suites.h @@ -33,6 +33,19 @@ // Contact: mailto:zeratul@cellosoft.com // +#include + + +////////////////////////////// +// Enable/disable test suites +#define ATHENASUB_TEST 1 + + + +/////////////////////// +// Name of test suites namespace AegisubSuites { - static std::string athenasub() { return "athenasub"; } +#if ATHENASUB_TEST == 1 + inline std::string athenasub() { return "athenasub"; } +#endif };