23#ifndef INCLUDED_SELF_TEST
24#define INCLUDED_SELF_TEST
32#define CXXTEST_HAVE_EH
33#define CXXTEST_HAVE_STD
38#include <cxxtest/StdValueTraits.h>
39#include <cxxtest/TestSuite.h>
46 CXXTEST_TEMPLATE_INSTANTIATION
47 class ValueTraits<const CStr8> :
public ValueTraits<const CXXTEST_STD(string)>
50 ValueTraits(
const CStr8 &s ) : ValueTraits<const CXXTEST_STD(string)>( s.c_str() ) {}
55 CXXTEST_TEMPLATE_INSTANTIATION
56 class ValueTraits<const CStrW> :
public ValueTraits<const CXXTEST_STD(wstring)>
59 ValueTraits(
const CStrW &s ) : ValueTraits<const CXXTEST_STD(wstring)>( s.c_str() ) {}
72 CXXTEST_TEMPLATE_INSTANTIATION
80 m_StringRepr = s.str();
84 return m_StringRepr.c_str();
90 CXXTEST_TEMPLATE_INSTANTIATION
97 s <<
"[" << v.
X <<
", " << v.
Y <<
", " << v.
Z <<
"]";
98 m_StringRepr = s.str();
102 return m_StringRepr.c_str();
108 CXXTEST_TEMPLATE_INSTANTIATION
114 std::stringstream ss;
116 ss <<
"Norm=" << TS_AS_STRING(p.
m_Norm);
117 ss <<
", Dist=" << TS_AS_STRING(p.
m_Dist);
119 m_StringRepr = ss.str();
121 const char*
asString()
const {
return m_StringRepr.c_str(); }
127#define TS_ASSERT_OK(expr) TS_ASSERT_EQUALS((expr), INFO::OK)
128#define TSM_ASSERT_OK(m, expr) TSM_ASSERT_EQUALS(m, (expr), INFO::OK)
129#define TS_ASSERT_STR_EQUALS(str1, str2) TS_ASSERT_EQUALS(std::string(str1), std::string(str2))
130#define TSM_ASSERT_STR_EQUALS(m, str1, str2) TSM_ASSERT_EQUALS(m, std::string(str1), std::string(str2))
131#define TS_ASSERT_WSTR_EQUALS(str1, str2) TS_ASSERT_EQUALS(std::wstring(str1), std::wstring(str2))
132#define TSM_ASSERT_WSTR_EQUALS(m, str1, str2) TSM_ASSERT_EQUALS(m, std::wstring(str1), std::wstring(str2))
133#define TS_ASSERT_PATH_EQUALS(path1, path2) TS_ASSERT_EQUALS((path1).string(), (path2).string())
134#define TSM_ASSERT_PATH_EQUALS(m, path1, path2) TSM_ASSERT_EQUALS(m, (path1).string(), (path2).string())
137bool ts_str_contains(
const std::wstring& str1,
const std::wstring& str2);
138#define TS_ASSERT_STR_CONTAINS(str1, str2) TSM_ASSERT(str1, ts_str_contains(str1, str2))
139#define TS_ASSERT_STR_NOT_CONTAINS(str1, str2) TSM_ASSERT(str1, !ts_str_contains(str1, str2))
140#define TS_ASSERT_WSTR_CONTAINS(str1, str2) TSM_ASSERT(str1, ts_str_contains(str1, str2))
141#define TS_ASSERT_WSTR_NOT_CONTAINS(str1, str2) TSM_ASSERT(str1, !ts_str_contains(str1, str2))
146 return std::vector<T>(start, start+(size_bytes/
sizeof(
T)));
148#define TS_ASSERT_VECTOR_EQUALS_ARRAY(vec1, array) TS_ASSERT_EQUALS(vec1, ts_make_vector((array), sizeof(array)))
149#define TS_ASSERT_VECTOR_CONTAINS(vec1, element) TS_ASSERT(std::find((vec1).begin(), (vec1).end(), element) != (vec1).end());
151#define TS_ASSERT_MATRIX_EQUALS_DELTA(m1, m2, size, epsilon) \
152 for (int j = 0; j < size; ++j) \
153 TS_ASSERT_DELTA(m1._data[j], m2._data[j], epsilon);
155#define TS_ASSERT_MATRIX_DIFFERS_DELTA(m1, m2, size, epsilon) \
156 for (int j = 0; j < size; ++j) \
157 TS_ASSERT(!feq(m1._data[j], m2._data[j], epsilon));
Definition: FixedVector3D.h:25
fixed Y
Definition: FixedVector3D.h:27
fixed Z
Definition: FixedVector3D.h:27
fixed X
Definition: FixedVector3D.h:27
double ToDouble() const
Convert to double. Won't be lossy - double can precisely represent all values.
Definition: Fixed.h:177
CVector3D m_Norm
Definition: Plane.h:68
float m_Dist
Definition: Plane.h:69
Definition: Vector3D.h:31
float Z
Definition: Vector3D.h:33
float Y
Definition: Vector3D.h:33
float X
Definition: Vector3D.h:33
const char * asString() const
Definition: self_test.h:82
std::string m_StringRepr
Definition: self_test.h:87
ValueTraits(const CFixedVector3D &v)
Definition: self_test.h:76
ValueTraits(const CPlane &p)
Definition: self_test.h:112
std::string m_StringRepr
Definition: self_test.h:123
const char * asString() const
Definition: self_test.h:121
std::string m_StringRepr
Definition: self_test.h:105
ValueTraits(const CVector3D &v)
Definition: self_test.h:94
const char * asString() const
Definition: self_test.h:100
ValueTraits(const CStr8 &s)
Definition: self_test.h:50
ValueTraits(const CStrW &s)
Definition: self_test.h:59
Abstraction around a SpiderMonkey JS::Realm.
Definition: ScriptInterface.h:72
Definition: self_test.h:45
CXXTEST_COPY_CONST_TRAITS(CStr8)
#define T(string_literal)
Definition: secure_crt.cpp:77
bool ts_str_contains(const std::string &str1, const std::string &str2)
Definition: test_setup.cpp:113
OsPath DataDir()
Definition: test_setup.cpp:127
void ScriptTestSetup(const ScriptInterface &)
Definition: test_setup.cpp:142
std::vector< T > ts_make_vector(T *start, size_t size_bytes)
Definition: self_test.h:144