mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-24 22:05:40 +00:00
Removed all local type definitions for GCC.
This commit is contained in:
parent
6cc59a97cc
commit
bedde94a9f
5 changed files with 194 additions and 168 deletions
|
|
@ -25,22 +25,78 @@
|
|||
#include "core/util/journal/journaledSignal.h"
|
||||
#include "core/util/safeDelete.h"
|
||||
|
||||
TEST(Journal, BasicAPI)
|
||||
FIXTURE(Journal)
|
||||
{
|
||||
public:
|
||||
// Used for basic API test.
|
||||
struct receiver
|
||||
{
|
||||
U32 lastTriggerValue;
|
||||
void triggerReceiver(U16 msg)
|
||||
U16 lastTriggerValue;
|
||||
void trigger(U16 msg)
|
||||
{
|
||||
lastTriggerValue = msg;
|
||||
}
|
||||
} rec;
|
||||
};
|
||||
|
||||
// Used for non-basic test.
|
||||
typedef JournaledSignal<void(U32, U16)> EventA;
|
||||
typedef JournaledSignal<void(U8, S8)> EventB;
|
||||
typedef JournaledSignal<void(U32, S32)> EventC;
|
||||
|
||||
// Root, non-dynamic signal receiver.
|
||||
struct multiReceiver {
|
||||
U32 recvA, recvB, recvC;
|
||||
|
||||
EventA *dynamicA;
|
||||
EventB *dynamicB;
|
||||
EventC *dynamicC;
|
||||
|
||||
void receiverRoot(U8 msg)
|
||||
{
|
||||
if(msg==1)
|
||||
{
|
||||
dynamicA = new EventA();
|
||||
dynamicA->notify(this, &multiReceiver::receiverA);
|
||||
}
|
||||
|
||||
if(msg==2)
|
||||
{
|
||||
dynamicB = new EventB();
|
||||
dynamicB->notify(this, &multiReceiver::receiverB);
|
||||
}
|
||||
|
||||
if(msg==3)
|
||||
{
|
||||
dynamicC = new EventC();
|
||||
dynamicC->notify(this, &multiReceiver::receiverC);
|
||||
}
|
||||
}
|
||||
|
||||
void receiverA(U32, U16 d)
|
||||
{
|
||||
recvA += d;
|
||||
}
|
||||
|
||||
void receiverB(U8, S8 d)
|
||||
{
|
||||
recvB += d;
|
||||
}
|
||||
|
||||
void receiverC(U32, S32 d)
|
||||
{
|
||||
recvC += d;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
TEST_FIX(Journal, BasicAPI)
|
||||
{
|
||||
receiver rec;
|
||||
rec.lastTriggerValue = 0;
|
||||
|
||||
// Set up a journaled signal to test with.
|
||||
JournaledSignal<void(U16)> testEvent;
|
||||
testEvent.notify(&rec, &receiver::triggerReceiver);
|
||||
testEvent.notify(&rec, &receiver::trigger);
|
||||
|
||||
// Initialize journal recording and fire off some events...
|
||||
Journal::Record("test.jrn");
|
||||
|
|
@ -71,63 +127,16 @@ TEST(Journal, BasicAPI)
|
|||
<< "Should encounter last journaled value (18).";
|
||||
}
|
||||
|
||||
TEST(Journal, DynamicSignals)
|
||||
TEST_FIX(Journal, DynamicSignals)
|
||||
{
|
||||
typedef JournaledSignal<void(U32, U16)> EventA;
|
||||
typedef JournaledSignal<void(U8, S8)> EventB;
|
||||
typedef JournaledSignal<void(U32, S32)> EventC;
|
||||
|
||||
// Root, non-dynamic signal receiver.
|
||||
struct receiver {
|
||||
U32 recvA, recvB, recvC;
|
||||
|
||||
EventA *dynamicA;
|
||||
EventB *dynamicB;
|
||||
EventC *dynamicC;
|
||||
|
||||
void receiverRoot(U8 msg)
|
||||
{
|
||||
if(msg==1)
|
||||
{
|
||||
dynamicA = new EventA();
|
||||
dynamicA->notify(this, &receiver::receiverA);
|
||||
}
|
||||
|
||||
if(msg==2)
|
||||
{
|
||||
dynamicB = new EventB();
|
||||
dynamicB->notify(this, &receiver::receiverB);
|
||||
}
|
||||
|
||||
if(msg==3)
|
||||
{
|
||||
dynamicC = new EventC();
|
||||
dynamicC->notify(this, &receiver::receiverC);
|
||||
}
|
||||
}
|
||||
|
||||
void receiverA(U32, U16 d)
|
||||
{
|
||||
recvA += d;
|
||||
}
|
||||
|
||||
void receiverB(U8, S8 d)
|
||||
{
|
||||
recvB += d;
|
||||
}
|
||||
|
||||
void receiverC(U32, S32 d)
|
||||
{
|
||||
recvC += d;
|
||||
}
|
||||
} rec;
|
||||
multiReceiver rec;
|
||||
|
||||
// Reset our state values.
|
||||
rec.recvA = rec.recvB = rec.recvC = 0;
|
||||
|
||||
// Set up a signal to start with.
|
||||
JournaledSignal<void(U8)> testEvent;
|
||||
testEvent.notify(&rec, &receiver::receiverRoot);
|
||||
testEvent.notify(&rec, &multiReceiver::receiverRoot);
|
||||
|
||||
// Initialize journal recording and fire off some events...
|
||||
Journal::Record("test.jrn");
|
||||
|
|
@ -177,4 +186,4 @@ TEST(Journal, DynamicSignals)
|
|||
EXPECT_EQ(rec.recvC, 2) << "recvC wasn't 2 - something broken in journal?";
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,22 +25,40 @@
|
|||
#include "core/util/tVector.h"
|
||||
|
||||
// Define some test data used below.
|
||||
static const S32 ints[] = {0, 10, 2, 3, 14, 4, 12, 6, 16, 7, 8, 1, 11, 5, 13, 9, 15};
|
||||
static const U32 length = sizeof(ints) / sizeof(S32);
|
||||
static S32 QSORT_CALLBACK sortInts(const S32* a, const S32* b)
|
||||
FIXTURE(Vector)
|
||||
{
|
||||
S32 av = *a;
|
||||
S32 bv = *b;
|
||||
|
||||
if (av < bv)
|
||||
return -1;
|
||||
else if (av > bv)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
public:
|
||||
struct Dtor
|
||||
{
|
||||
bool* ptr;
|
||||
Dtor() {} // Needed for vector increment.
|
||||
Dtor(bool* ptr): ptr(ptr) {}
|
||||
~Dtor()
|
||||
{
|
||||
*ptr = true;
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Vector, Allocation)
|
||||
static const S32 ints[];
|
||||
static const U32 length;
|
||||
static S32 QSORT_CALLBACK sortInts(const S32* a, const S32* b)
|
||||
{
|
||||
S32 av = *a;
|
||||
S32 bv = *b;
|
||||
|
||||
if (av < bv)
|
||||
return -1;
|
||||
else if (av > bv)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
const S32 VectorFixture::ints[] = {0, 10, 2, 3, 14, 4, 12, 6, 16, 7, 8, 1, 11, 5, 13, 9, 15};
|
||||
const U32 VectorFixture::length = sizeof(VectorFixture::ints) / sizeof(S32);
|
||||
|
||||
TEST_FIX(Vector, Allocation)
|
||||
{
|
||||
Vector<S32> *vector = new Vector<S32>;
|
||||
for (S32 i = 0; i < 1000; i++)
|
||||
|
|
@ -57,19 +75,8 @@ TEST(Vector, Allocation)
|
|||
delete vector;
|
||||
}
|
||||
|
||||
TEST(Vector, Deallocation)
|
||||
TEST_FIX(Vector, Deallocation)
|
||||
{
|
||||
struct Dtor
|
||||
{
|
||||
bool* ptr;
|
||||
Dtor() {} // Needed for vector increment.
|
||||
Dtor(bool* ptr): ptr(ptr) {}
|
||||
~Dtor()
|
||||
{
|
||||
*ptr = true;
|
||||
}
|
||||
};
|
||||
|
||||
bool dtorVals[10];
|
||||
Vector<Dtor> v;
|
||||
|
||||
|
|
@ -101,7 +108,7 @@ TEST(Vector, Deallocation)
|
|||
<< "Element " << i << "'s destructor was not called";
|
||||
}
|
||||
|
||||
TEST(Vector, Sorting)
|
||||
TEST_FIX(Vector, Sorting)
|
||||
{
|
||||
Vector<S32> v;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue