-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_support.h
71 lines (52 loc) · 1.64 KB
/
test_support.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#if defined(_DEBUG) || ENABLE_RELEASE_TEST
# define ENABLE_TEST 1
#else
# define ENABLE_TEST 0
#endif
#if ENABLE_TEST
// -------------------------------------------------------------------------- //
#define _MODULE_NAME cdeccore
#include "../include/unittest.h"
using namespace UnitTest;
using namespace cdec;
// -------------------------------------------------------------------------- //
// String constants avoiding code page dependent
// See test_support.cpp for contents
extern WCHAR TEXT_ChsLine2[];
extern WCHAR TEXT_Chs[];
extern char TEXT_ChsEng_UTF8[];
extern WCHAR TEXT_ChsEng_Wide[];
// -------------------------------------------------------------------------- //
template<class _Ty>
struct ObjectRefSpy: _Ty
{
using _Ty::_ref;
static UINT GetRef(_Ty* pThis)
{
return ((ObjectRefSpy<_Ty >*)pThis)->_ref;
}
};
// -------------------------------------------------------------------------- //
class TestEnv
{
public:
// »ñÈ¡²âÊÔÑùÕÅĿ¼
static stringx get_sample_path(stringx fname)
{
#ifdef X_OS_WINDOWS
static stringx pathSampleBase = __X("..\\tests\\samples\\");
#else
static stringx pathSampleBase = __X("../tests/samples/");
#endif
return pathSampleBase + fname;
}
static void AssertByteRangeEqual(const void* ps, const void* pt, int c)
{
UNITTEST_ASSERT(memcmp(ps, pt, c) == 0);
}
static void AssertByteRangeEqual(ref<ByteArray> s, int offS, const void* pt, int c);
static void AssertByteArrayEqual(ref<ByteArray> s, const void* pt, int ct);
};
// -------------------------------------------------------------------------- //
#endif