oops... class TargetObject defined twice
This commit is contained in:
parent
eef591f873
commit
1d462845dd
3 changed files with 83 additions and 67 deletions
|
|
@ -66,7 +66,7 @@ namespace cinelerra
|
|||
|
||||
namespace test
|
||||
{
|
||||
class TargetObj;
|
||||
class TestSingletonO;
|
||||
using cinelerra::Singleton;
|
||||
|
||||
} // namespace test
|
||||
|
|
@ -94,8 +94,8 @@ namespace cinelerra
|
|||
|
||||
|
||||
template<>
|
||||
class Singleton<test::TargetObj>
|
||||
: public MockInjector<test::TargetObj>
|
||||
class Singleton<test::TestSingletonO>
|
||||
: public MockInjector<test::TestSingletonO>
|
||||
{ };
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -103,6 +103,49 @@ out: dtor ~TargetObj(12) successfull
|
|||
END
|
||||
|
||||
|
||||
TEST "SanitizedIdentifier_test" SanitizedIdentifier_test <<END
|
||||
out: 'Word' --> 'Word'
|
||||
out: 'a Sentence' --> 'a_Sentence'
|
||||
out: 'trailing Withespace
|
||||
out: ' --> 'trailing_Withespace'
|
||||
out: 'with a lot
|
||||
out: of Whitespace' --> 'with_a_lot_of_Whitespace'
|
||||
out: 'with"much (punctuation)[]!' --> 'withmuch_(punctuation)'
|
||||
out: '§&Ω%€ leading garbarge' --> 'leading_garbarge'
|
||||
out: 'mixed Ω garbarge' --> 'mixed_garbarge'
|
||||
out: 'Bääääh!!' --> 'Bh'
|
||||
out: '§&Ω%€' --> ''
|
||||
END
|
||||
|
||||
|
||||
TEST "SingletonTestMock_test" SingletonTestMock_test <<END
|
||||
out: TestSingletonO::doIt() call=1
|
||||
out: TestSingletonO::doIt() call=2
|
||||
out: Mock_1::doIt() call=1
|
||||
out: Mock_1::doIt() call=2
|
||||
out: Mock_1::doIt() call=3
|
||||
out: Mock_1::doIt() call=4
|
||||
out: Mock_1::doIt() call=5
|
||||
out: Mock_2::doIt() call=1
|
||||
out: TestSingletonO::doIt() call=3
|
||||
END
|
||||
|
||||
|
||||
|
||||
TEST "Singleton_test" Singleton_test 23 <<END
|
||||
out: testing TargetObj(23) as Singleton(statically allocated)
|
||||
out: ctor TargetObj(23) successfull
|
||||
out: calling a non-static method on the Singleton instance
|
||||
out: .....TargetObj(23): data="***********************", array[23]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,}
|
||||
out: testing TargetObj(24) as Singleton(heap allocated)
|
||||
out: ctor TargetObj(24) successfull
|
||||
out: calling a non-static method on the Singleton instance
|
||||
out: .....TargetObj(24): data="************************", array[24]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,}
|
||||
out: dtor ~TargetObj(23) successfull
|
||||
out: dtor ~TargetObj(24) successfull
|
||||
END
|
||||
|
||||
|
||||
TEST "TestOption_test" TestOption_test <<END
|
||||
out: Testing invocation with cmdline: ...
|
||||
out: --> Testgroup=ALL
|
||||
|
|
@ -139,30 +182,3 @@ out: --> remaining=SingleTestID spam --eggs
|
|||
END
|
||||
|
||||
|
||||
TEST "SanitizedIdentifier_test" SanitizedIdentifier_test <<END
|
||||
out: 'Word' --> 'Word'
|
||||
out: 'a Sentence' --> 'a_Sentence'
|
||||
out: 'trailing Withespace
|
||||
out: ' --> 'trailing_Withespace'
|
||||
out: 'with a lot
|
||||
out: of Whitespace' --> 'with_a_lot_of_Whitespace'
|
||||
out: 'with"much (punctuation)[]!' --> 'withmuch_(punctuation)'
|
||||
out: '§&Ω%€ leading garbarge' --> 'leading_garbarge'
|
||||
out: 'mixed Ω garbarge' --> 'mixed_garbarge'
|
||||
out: 'Bääääh!!' --> 'Bh'
|
||||
out: '§&Ω%€' --> ''
|
||||
END
|
||||
|
||||
|
||||
TEST "Singleton_test" Singleton_test 23 <<END
|
||||
out: testing TargetObj(23) as Singleton(statically allocated)
|
||||
out: ctor TargetObj(23) successfull
|
||||
out: calling a non-static method on the Singleton instance
|
||||
out: .....TargetObj(23): data="***********************", array[23]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,}
|
||||
out: testing TargetObj(24) as Singleton(heap allocated)
|
||||
out: ctor TargetObj(24) successfull
|
||||
out: calling a non-static method on the Singleton instance
|
||||
out: .....TargetObj(24): data="************************", array[24]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,}
|
||||
out: dtor ~TargetObj(23) successfull
|
||||
out: dtor ~TargetObj(24) successfull
|
||||
END
|
||||
|
|
|
|||
|
|
@ -48,19 +48,19 @@ namespace cinelerra
|
|||
* Client Class normally to be instantiated as Singleton.
|
||||
* But for tests, this class should be replaced by a Mock....
|
||||
*/
|
||||
class TargetObj
|
||||
class TestSingletonO
|
||||
{
|
||||
int callCnt;
|
||||
char* typid;
|
||||
format msg;
|
||||
|
||||
public:
|
||||
TargetObj(char* ty="TargetObj")
|
||||
TestSingletonO(char* ty="TestSingletonO")
|
||||
: callCnt (0), typid(ty), msg ("%s::doIt() call=%d\n")
|
||||
{
|
||||
TRACE (singleton, "ctor %s", typid);
|
||||
}
|
||||
virtual ~TargetObj()
|
||||
virtual ~TestSingletonO()
|
||||
{
|
||||
TRACE (singleton, "dtor %s", typid);
|
||||
}
|
||||
|
|
@ -78,17 +78,17 @@ namespace cinelerra
|
|||
/**
|
||||
* Mock-1 to replace the Client Class...
|
||||
*/
|
||||
struct Mock_1 : TargetObj
|
||||
struct Mock_1 : TestSingletonO
|
||||
{
|
||||
Mock_1() : TargetObj("Mock_1") {};
|
||||
Mock_1() : TestSingletonO("Mock_1") {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Mock-2 to replace the Client Class...
|
||||
*/
|
||||
struct Mock_2 : TargetObj
|
||||
struct Mock_2 : TestSingletonO
|
||||
{
|
||||
Mock_2() : TargetObj("Mock_2") {};
|
||||
Mock_2() : TestSingletonO("Mock_2") {};
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ namespace cinelerra
|
|||
*/
|
||||
class SingletonTestMock_test : public Test
|
||||
{
|
||||
Singleton<TargetObj> instance;
|
||||
Singleton<TestSingletonO> instance;
|
||||
|
||||
virtual void run(Arg arg)
|
||||
{
|
||||
|
|
@ -135,30 +135,30 @@ namespace cinelerra
|
|||
*/
|
||||
void injectBoth ()
|
||||
{
|
||||
TargetObj* tartar = &instance();
|
||||
tartar->doIt();
|
||||
tartar->doIt();
|
||||
ASSERT (tartar->getCnt() == 2);
|
||||
TestSingletonO* sing = &instance();
|
||||
sing->doIt();
|
||||
sing->doIt();
|
||||
ASSERT (sing->getCnt() == 2);
|
||||
|
||||
instance.injectSubclass (new Mock_1);
|
||||
tartar = &instance();
|
||||
tartar->doIt();
|
||||
tartar->doIt();
|
||||
tartar->doIt();
|
||||
tartar->doIt();
|
||||
tartar->doIt();
|
||||
ASSERT (tartar->getCnt() == 5);
|
||||
sing = &instance();
|
||||
sing->doIt();
|
||||
sing->doIt();
|
||||
sing->doIt();
|
||||
sing->doIt();
|
||||
sing->doIt();
|
||||
ASSERT (sing->getCnt() == 5);
|
||||
|
||||
instance.injectSubclass (new Mock_2);
|
||||
tartar = &instance();
|
||||
tartar->doIt();
|
||||
ASSERT (tartar->getCnt() == 1);
|
||||
sing = &instance();
|
||||
sing->doIt();
|
||||
ASSERT (sing->getCnt() == 1);
|
||||
|
||||
instance.injectSubclass (0); // unshaddowing original instance
|
||||
tartar = &instance();
|
||||
ASSERT (tartar->getCnt() == 2);
|
||||
tartar->doIt();
|
||||
ASSERT (tartar->getCnt() == 3);
|
||||
sing = &instance();
|
||||
ASSERT (sing->getCnt() == 2);
|
||||
sing->doIt();
|
||||
ASSERT (sing->getCnt() == 3);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -166,8 +166,8 @@ namespace cinelerra
|
|||
*/
|
||||
void noMock ()
|
||||
{
|
||||
TargetObj& tartar = instance();
|
||||
tartar.doIt();
|
||||
TestSingletonO& sing = instance();
|
||||
sing.doIt();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -177,8 +177,8 @@ namespace cinelerra
|
|||
void onlyMock ()
|
||||
{
|
||||
instance.injectSubclass (new Mock_1);
|
||||
TargetObj& tartar = instance();
|
||||
tartar.doIt();
|
||||
TestSingletonO& sing = instance();
|
||||
sing.doIt();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -189,15 +189,15 @@ namespace cinelerra
|
|||
void firstMock ()
|
||||
{
|
||||
instance.injectSubclass (new Mock_1);
|
||||
TargetObj* tartar = &instance();
|
||||
tartar->doIt();
|
||||
tartar->doIt();
|
||||
ASSERT (tartar->getCnt() == 2);
|
||||
TestSingletonO* sing = &instance();
|
||||
sing->doIt();
|
||||
sing->doIt();
|
||||
ASSERT (sing->getCnt() == 2);
|
||||
|
||||
instance.injectSubclass (0);
|
||||
tartar = &instance();
|
||||
tartar->doIt();
|
||||
ASSERT (tartar->getCnt() == 1);
|
||||
sing = &instance();
|
||||
sing->doIt();
|
||||
ASSERT (sing->getCnt() == 1);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue