#include "StringTest.hpp"

#include "../UTest/UTest.hpp"

/*** TrooperEngine DLL Header Files ***/
#include "TrooperEngine.hpp"

using UtilityEngine::cString;

void StringTest() 
{
	// cString
	printf("\nTesting cString -----\n\n");

	UTest u("cString");

	const char * _ctest = "   \tfoo   \r\n";
	cString ttest = _ctest;
	u.test("cstring ctor", ttest.length() == 12);
	ttest.trim();
	u.test("trim", ttest.length() == 3);

	cString x = "foo";
	cString y = "bar";
	cString z = x + "baz" + y;

	u.test("concat", z.length() == 9 && memcmp(z.c_str(), "foobazbar", 10) == 0);

	x = y = "foo";
	u.test("foo == foo", (x == y));
	u.test("foo  > foo", !(x > y));
	u.test("foo >= foo", (x >= y));
	u.test("foo  < foo", !(x < y));
	u.test("foo <= foo", (x <= y));

	x = "bar";
	u.test("bar == foo", !(x == y));
	u.test("bar  > foo", !(x > y));
	u.test("bar >= foo", !(x >= y));
	u.test("bar  < foo", (x < y));
	u.test("bar <= foo", (x <= y));

	u.test("foo == bar", !(y == x));
	u.test("foo  > bar", (y > x));
	u.test("foo >= bar", (y >= x));
	u.test("foo  < bar", !(y < x));
	u.test("foo <= bar", !(y <= x));

	u.report();
}