mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-05 19:57:40 +00:00
moved remaining tests
FrameTemp had its template initializers removed, and also its ~ operator, return these if we need to.
This commit is contained in:
parent
4017c3a21d
commit
ffc001bb97
6 changed files with 57 additions and 16 deletions
|
|
@ -291,8 +291,11 @@ public:
|
|||
FrameTemp(const U32 numElements = 0)
|
||||
{
|
||||
mPosition = FrameAllocator::getWaterMark();
|
||||
mData = (T*)FrameAllocator::alloc(sizeof(T) * numElements);
|
||||
mData = reinterpret_cast<T*>(FrameAllocator::alloc(sizeof(T) * numElements));
|
||||
mSize = numElements;
|
||||
|
||||
for (S32 i = 0; i < numElements; i++)
|
||||
constructInPlace<T>(&mData[i]);
|
||||
}
|
||||
|
||||
~FrameTemp()
|
||||
|
|
@ -303,6 +306,8 @@ public:
|
|||
}
|
||||
|
||||
// Operators
|
||||
inline TORQUE_FORCEINLINE T* operator~() { return mData; }
|
||||
inline TORQUE_FORCEINLINE const T* operator~() const { return mData; }
|
||||
|
||||
inline TORQUE_FORCEINLINE T& operator*() { return *mData; }
|
||||
inline TORQUE_FORCEINLINE const T& operator*() const { return *mData; }
|
||||
|
|
@ -329,5 +334,34 @@ public:
|
|||
inline TORQUE_FORCEINLINE const U32 getObjectCount() const { return mSize; }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FrameTemp specializations for types with no constructor/destructor
|
||||
#define FRAME_TEMP_NC_SPEC(type) \
|
||||
template<> \
|
||||
inline FrameTemp<type>::FrameTemp( const U32 count ) \
|
||||
{ \
|
||||
AssertFatal( count > 0, "Allocating a FrameTemp with less than one instance" ); \
|
||||
mPosition = FrameAllocator::getWaterMark(); \
|
||||
mSize = count;\
|
||||
mData = reinterpret_cast<type *>( FrameAllocator::alloc( sizeof( type ) * count ) ); \
|
||||
} \
|
||||
template<>\
|
||||
inline FrameTemp<type>::~FrameTemp() \
|
||||
{ \
|
||||
FrameAllocator::setWaterMark( mPosition ); \
|
||||
} \
|
||||
|
||||
FRAME_TEMP_NC_SPEC(char);
|
||||
FRAME_TEMP_NC_SPEC(float);
|
||||
FRAME_TEMP_NC_SPEC(double);
|
||||
FRAME_TEMP_NC_SPEC(bool);
|
||||
FRAME_TEMP_NC_SPEC(int);
|
||||
FRAME_TEMP_NC_SPEC(short);
|
||||
|
||||
FRAME_TEMP_NC_SPEC(unsigned char);
|
||||
FRAME_TEMP_NC_SPEC(unsigned int);
|
||||
FRAME_TEMP_NC_SPEC(unsigned short);
|
||||
|
||||
#undef FRAME_TEMP_NC_SPEC
|
||||
|
||||
#endif // _H_FRAMEALLOCATOR_
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef TORQUE_TESTS_ENABLED
|
||||
#include "testing/unitTesting.h"
|
||||
#include "core/util/path.h"
|
||||
|
||||
|
|
@ -36,5 +35,3 @@ TEST(MakeRelativePath, MakeRelativePath)
|
|||
EXPECT_EQ(Torque::Path::MakeRelativePath("levels/den/file.png", "art/interiors/burg/"), "../../../levels/den/file.png");
|
||||
EXPECT_EQ(Torque::Path::MakeRelativePath("art/interiors/burg/file.png", "art/dts/burg/"), "../../interiors/burg/file.png");
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -218,9 +218,28 @@ TEST(String, Order)
|
|||
}
|
||||
}
|
||||
|
||||
/// TODO
|
||||
TEST(String, Find)
|
||||
{
|
||||
String str("foobarbarfoo");
|
||||
|
||||
// Character searches.
|
||||
EXPECT_EQ(str.find('f'), 0);
|
||||
EXPECT_EQ(str.find('o'), 1);
|
||||
EXPECT_EQ(str.find('b'), 3);
|
||||
EXPECT_EQ(str.find('r'), 5);
|
||||
|
||||
// Substring searches.
|
||||
EXPECT_EQ(str.find("foo"), 0);
|
||||
EXPECT_EQ(str.find("bar"), 3);
|
||||
EXPECT_EQ(str.find("barfoo"), 6);
|
||||
|
||||
// Not found.
|
||||
EXPECT_EQ(str.find("baz"), String::NPos);
|
||||
EXPECT_EQ(str.find('x'), String::NPos);
|
||||
|
||||
// Empty string.
|
||||
EXPECT_EQ(String("").find("foo"), String::NPos);
|
||||
EXPECT_EQ(String("").find('f'), String::NPos);
|
||||
}
|
||||
|
||||
TEST(String, Insert)
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef TORQUE_TESTS_ENABLED
|
||||
#include "platform/platform.h"
|
||||
#include "testing/unitTesting.h"
|
||||
#include "core/util/swizzle.h"
|
||||
|
|
@ -106,7 +105,7 @@ TEST(Swizzle, Swizzle)
|
|||
EXPECT_TRUE( same )
|
||||
<< "Test object failed to be competent";
|
||||
|
||||
bgraObjSwizzle.InPlace( ~objTest, sizeof( TestStruct ) * ( sizeof( objIdx ) / sizeof( U32 ) ) );
|
||||
bgraObjSwizzle.InPlace( objTest.address(), sizeof(TestStruct) * (sizeof(objIdx) / sizeof(U32)));
|
||||
same = true;
|
||||
|
||||
for( U32 i = 0; i < sizeof( objIdx ) / sizeof( U32 ); i++ )
|
||||
|
|
@ -115,7 +114,7 @@ TEST(Swizzle, Swizzle)
|
|||
EXPECT_TRUE( same )
|
||||
<< "Object RGBA->BGRA test failed.";
|
||||
|
||||
bgraObjSwizzle.InPlace( ~objTest, sizeof( TestStruct ) * ( sizeof( objIdx ) / sizeof( U32 ) ) );
|
||||
bgraObjSwizzle.InPlace( objTest.address(), sizeof(TestStruct) * (sizeof(objIdx) / sizeof(U32)));
|
||||
same = true;
|
||||
|
||||
for( U32 i = 0; i < sizeof( objIdx ) / sizeof( U32 ); i++ )
|
||||
|
|
@ -125,5 +124,3 @@ TEST(Swizzle, Swizzle)
|
|||
<< "Object RGBA->BGRA reverse test failed.";
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef TORQUE_TESTS_ENABLED
|
||||
#include "testing/unitTesting.h"
|
||||
#include "core/util/tFixedSizeDeque.h"
|
||||
|
||||
|
|
@ -45,5 +44,3 @@ TEST(FixedSizeDeque, FixedSizeDeque)
|
|||
EXPECT_EQ( deque.popFront(), 2 );
|
||||
EXPECT_TRUE( deque.isEmpty() );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef TORQUE_TESTS_ENABLED
|
||||
#include "testing/unitTesting.h"
|
||||
#include "core/util/tVector.h"
|
||||
|
||||
|
|
@ -121,5 +120,3 @@ TEST_FIX(Vector, Sorting)
|
|||
EXPECT_TRUE(v[i] <= v[i + 1])
|
||||
<< "Element " << i << " was not in sorted order";
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue