[Igarden-commit] Garden/UnitTest LayoutDBTests.cpp, NONE, 1.1.2.1 LayoutDBTests.h, NONE, 1.1.2.1 Un
Status: Beta
Brought to you by:
jlbedell
|
From: Jeffrey B. <jlb...@us...> - 2006-12-12 03:50:32
|
Update of /cvsroot/igarden/Garden/UnitTest In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv30428/UnitTest Added Files: Tag: Release_branch_v1 LayoutDBTests.cpp LayoutDBTests.h UnitTest.cpp UnitTest.h Log Message: Added Files: Tag: Release_branch_v1 UnitTest/LayoutDBTests.cpp UnitTest/LayoutDBTests.h UnitTest/UnitTest.cpp UnitTest/UnitTest.h --- NEW FILE: UnitTest.h --- /* * UnitTest.h * qs * * Created by Jeffrey Bedell on 12/11/06. * Copyright 2006 __MyCompanyName__. All rights reserved. * */ #include <Carbon/Carbon.h> extern class RunTestsInTimer installTimer; class RunTestsInTimer { public: RunTestsInTimer(); virtual ~RunTestsInTimer(); EventLoopTimerUPP timerUPP; EventLoopTimerRef timerRef; static void firedTimerBridge( EventLoopTimerRef inTimer, void *inUserData ); void firedTimer( EventLoopTimerRef inTimer ); }; --- NEW FILE: LayoutDBTests.cpp --- /* * TestCase1.cpp * qs * * Created by Jeffrey Bedell on 12/11/06. * Copyright 2006 __MyCompanyName__. All rights reserved. * */ #include "LayoutDBTests.h" #include "MaterialCollection.h" BasicTests test1( TEST_INVOCATION(BasicTests, testCase1) ); BasicTests test2( TEST_INVOCATION(BasicTests, testCase2) ); extern void MyQsort(); BasicTests::BasicTests(TestInvocation *invocation) : TestCase(invocation) { } BasicTests::~BasicTests() { } void BasicTests::testCase1() { #if 0 matCollItem_t items[6]; long n; items[0].sortName = "Viburnum lantana"; items[1].sortName = "Magnolia x soulangiana"; items[2].sortName = "Larix decidua"; items[3].sortName = "Tradescantia virginiana"; items[4].sortName = "Kochia scoparia"; items[5].sortName = "Monarda didyma"; // for(n = 0; n < 10; n++) // printf("Before A[%ld] = %ld\n", n, a[n]); MyQsort(items, 0, 5); for(n = 0; n < 5; n++) CPTAssert(items[n] <= items[n+1]); #endif } void BasicTests::testCase2() { CPTAssert(false); } --- NEW FILE: LayoutDBTests.h --- /* * TestCase1.h * qs * * Created by Jeffrey Bedell on 12/11/06. * Copyright 2006 __MyCompanyName__. All rights reserved. * */ #include <CPlusTest/CPlusTest.h> class BasicTests : public TestCase { public: BasicTests(TestInvocation* invocation); virtual ~BasicTests(); public: void testCase1(); void testCase2(); }; #if 0 class TestCase1 : public TestCase { public: TestCase1(TestInvocation* invocation); virtual ~TestCase1(); virtual void setUp(); virtual void tearDown(); void MyFirstTest(); }; #endif --- NEW FILE: UnitTest.cpp --- /* * UnitTest.cpp * qs * * Created by Jeffrey Bedell on 12/11/06. * Copyright 2006 __MyCompanyName__. All rights reserved. * */ // RunTestsInTimer.cpp (almost straight copy and paste from Apple's suggestion) #include <CPlusTest/CPlusTest.h> #include "UnitTest.h" RunTestsInTimer installTimer; RunTestsInTimer::RunTestsInTimer() : timerUPP(0), timerRef(0) { printf("Got to RunTestsInTimer()!\n"); timerUPP = NewEventLoopTimerUPP(RunTestsInTimer::firedTimerBridge); InstallEventLoopTimer(GetMainEventLoop(), 0, 0, timerUPP, this, &timerRef); // RunTestsInTimer::firedTimer(timerRef); // No event loop in test app } RunTestsInTimer::~RunTestsInTimer() { if ( timerRef ) { RemoveEventLoopTimer(timerRef); timerRef = 0; } if ( timerUPP ) { DisposeEventLoopTimerUPP(timerUPP); timerUPP = 0; } } void RunTestsInTimer::firedTimerBridge( EventLoopTimerRef inTimer, void *inUserData ) { printf("Got to firedTimerBridge()!\n"); reinterpret_cast<RunTestsInTimer*>(inUserData)->firedTimer(inTimer); } void RunTestsInTimer::firedTimer( EventLoopTimerRef inTimer ) { if ( inTimer == timerRef ) { TestRun run; TestLog log(std::cerr); run.addObserver(&log); TestSuite& allTests = TestSuite::allTests(); allTests.run(run); std::cerr << "Ran " << run.runCount() << " tests, " << run.failureCount() << " failed." << std::endl; RemoveEventLoopTimer(timerRef); timerRef = 0; QuitApplicationEventLoop(); } } |