Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 4aa63f4

Browse files
[[ cpptest ]] Add C++ test framework to the engine folder
1 parent 285ae29 commit 4aa63f4

File tree

9 files changed

+182
-34
lines changed

9 files changed

+182
-34
lines changed

config/cpptest.gypi

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
{
2+
'variables':
3+
{
4+
'module_test_dependencies%': '',
5+
'module_test_additional_sources%': '',
6+
'module_test_include_dirs%': '',
7+
'module_test_defines%': '',
8+
},
9+
210
'targets': [
311
{
412
'target_name': 'test-<(module_name)',
513

6-
'conditions':
14+
'conditions':
715
[
816
[
917
'OS == "ios"',
@@ -17,16 +25,21 @@
1725
],
1826
],
1927

20-
'dependencies':
28+
'dependencies':
2129
[
22-
'libcpptest'
30+
'../libcpptest/libcpptest.gyp:libcpptest',
31+
'<@(module_test_dependencies)',
2332
],
2433

2534
'sources':
2635
[
2736
'<!@(ls -1 test/*.cpp)',
37+
'<@(module_test_additional_sources)',
2838
],
2939

40+
'include_dirs': [ '<@(module_test_include_dirs)', ],
41+
'defines': [ '<@(module_test_defines)', ],
42+
3043
'msvs_settings':
3144
{
3245
'VCLinkerTool':
@@ -38,7 +51,7 @@
3851
},
3952
],
4053

41-
'conditions':
54+
'conditions':
4255
[
4356
[
4457
'OS == "emscripten"',
@@ -88,4 +101,4 @@
88101
},
89102
],
90103
],
91-
}
104+
}

engine/engine-common.gyp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
'includes':
33
[
44
'../common.gypi',
5+
'engine-sources.gypi',
56
],
67

78
'targets':
@@ -73,5 +74,24 @@
7374
],
7475
},
7576

77+
{
78+
'target_name': 'security-community',
79+
'type': 'static_library',
80+
81+
'dependencies':
82+
[
83+
'../thirdparty/libopenssl/libopenssl.gyp:libopenssl',
84+
85+
# Because our headers are so messed up...
86+
'../libfoundation/libfoundation.gyp:libFoundation',
87+
'../libgraphics/libgraphics.gyp:libGraphics',
88+
],
89+
90+
'sources':
91+
[
92+
'<@(engine_security_source_files)',
93+
],
94+
},
95+
7696
],
7797
}

engine/engine.gyp

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,7 @@
5151
},
5252
],
5353
},
54-
55-
{
56-
'target_name': 'security-community',
57-
'type': 'static_library',
58-
59-
'dependencies':
60-
[
61-
'../thirdparty/libopenssl/libopenssl.gyp:libopenssl',
6254

63-
# Because our headers are so messed up...
64-
'../libfoundation/libfoundation.gyp:libFoundation',
65-
'../libgraphics/libgraphics.gyp:libGraphics',
66-
],
67-
68-
'sources':
69-
[
70-
'<@(engine_security_source_files)',
71-
],
72-
},
73-
7455
{
7556
'target_name': 'server',
7657
'type': 'executable',
@@ -140,7 +121,7 @@
140121
'dependencies':
141122
[
142123
'kernel-standalone.gyp:kernel-standalone',
143-
'security-community',
124+
'engine-common.gyp:security-community',
144125
],
145126

146127
'sources':
@@ -437,7 +418,7 @@
437418
'dependencies':
438419
[
439420
'kernel-installer.gyp:kernel-installer',
440-
'security-community',
421+
'engine-common.gyp:security-community',
441422
],
442423

443424
'sources':
@@ -555,7 +536,7 @@
555536
[
556537
'kernel-development.gyp:kernel-development',
557538
'encode_environment_stack',
558-
'security-community',
539+
'engine-common.gyp:security-community',
559540
],
560541

561542
'sources':
@@ -742,7 +723,7 @@
742723
'dependencies':
743724
[
744725
'kernel-standalone.gyp:kernel-standalone',
745-
'security-community',
726+
'engine-common.gyp:security-community',
746727
],
747728

748729
'sources':

engine/kernel-development.gyp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
11
{
2+
'variables':
3+
{
4+
'module_name': 'kernel-development',
5+
'module_test_dependencies':
6+
[
7+
'kernel-development',
8+
'engine-common.gyp:security-community',
9+
'../libfoundation/libfoundation.gyp:libFoundation',
10+
'../libgraphics/libgraphics.gyp:libGraphics',
11+
],
12+
'module_test_additional_sources':
13+
[
14+
'<(SHARED_INTERMEDIATE_DIR)/src/startupstack.cpp',
15+
],
16+
'module_test_include_dirs':
17+
[
18+
'include',
19+
'src',
20+
],
21+
'module_test_defines': [ 'MODE_DEVELOPMENT', ],
22+
},
23+
224
'includes':
325
[
426
'../common.gypi',
527
'engine-sources.gypi',
28+
'../config/cpptest.gypi'
629
],
730

831
'targets':

engine/kernel-installer.gyp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
{
2+
'variables':
3+
{
4+
'module_name': 'kernel-installer',
5+
'module_test_dependencies':
6+
[
7+
'kernel-installer',
8+
'engine-common.gyp:security-community',
9+
'../libfoundation/libfoundation.gyp:libFoundation',
10+
'../libgraphics/libgraphics.gyp:libGraphics',
11+
],
12+
'module_test_include_dirs':
13+
[
14+
'include',
15+
'src',
16+
],
17+
'module_test_defines': [ 'MODE_INSTALLER', ],
18+
},
19+
220
'includes':
321
[
422
'../common.gypi',
523
'engine-sources.gypi',
24+
'../config/cpptest.gypi'
625
],
726

827
'targets':

engine/kernel-server.gyp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
{
2+
'variables':
3+
{
4+
'module_name': 'kernel-server',
5+
'module_test_dependencies':
6+
[
7+
'kernel-server',
8+
'../libfoundation/libfoundation.gyp:libFoundation',
9+
'../libgraphics/libgraphics.gyp:libGraphics',
10+
],
11+
'module_test_additional_sources':
12+
[
13+
'<@(engine_security_source_files)'
14+
],
15+
'module_test_include_dirs':
16+
[
17+
'include',
18+
'src',
19+
],
20+
'module_test_defines': [ 'MODE_SERVER', ],
21+
},
22+
223
'includes':
324
[
425
'../common.gypi',
526
'engine-sources.gypi',
27+
'../config/cpptest.gypi'
628
],
729

830
'targets':

engine/kernel-standalone.gyp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
{
2+
'variables':
3+
{
4+
'module_name': 'kernel-standalone',
5+
'module_test_dependencies':
6+
[
7+
'kernel-standalone',
8+
'engine-common.gyp:security-community',
9+
'../libfoundation/libfoundation.gyp:libFoundation',
10+
'../libgraphics/libgraphics.gyp:libGraphics',
11+
],
12+
'module_test_include_dirs':
13+
[
14+
'include',
15+
'src',
16+
],
17+
'module_test_defines': [ 'MODE_STANDALONE', ],
18+
},
19+
220
'includes':
321
[
422
'../common.gypi',
523
'engine-sources.gypi',
24+
'../config/cpptest.gypi'
625
],
726

827
'targets':

engine/test/test_lextable.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* Copyright (C) 2003-2015 LiveCode Ltd.
2+
3+
This file is part of LiveCode.
4+
5+
LiveCode is free software; you can redistribute it and/or modify it under
6+
the terms of the GNU General Public License v3 as published by the Free
7+
Software Foundation.
8+
9+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
10+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
16+
17+
#include "gtest/gtest.h"
18+
19+
#include "prefix.h"
20+
#include "parsedef.h"
21+
#include "scriptpt.h"
22+
23+
24+
TEST(lextable, factor_table)
25+
//
26+
// Checks that the entries of factor_table are in alphabetical order.
27+
//
28+
{
29+
extern LT factor_table[];
30+
extern const uint4 factor_table_size;
31+
32+
ASSERT_GE(factor_table_size, 1);
33+
34+
for(uint4 i = 0; i < factor_table_size - 1; i++) {
35+
EXPECT_LT(strcmp(factor_table[i].token, factor_table[i+1].token), 0)
36+
<< "\"" << factor_table[i+1].token << "\""
37+
<< " comes before "
38+
<< "\"" << factor_table[i].token << "\"";
39+
}
40+
}

livecode.gyp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@
190190
'javascriptify': ''
191191
},
192192

193+
'dependencies':
194+
[
195+
'libcpptest/libcpptest.gyp:test-libcpptest<(javascriptify)',
196+
'engine/kernel-standalone.gyp:test-kernel-standalone<(javascriptify)',
197+
],
198+
193199
'conditions':
194200
[
195201
[
@@ -201,13 +207,18 @@
201207
},
202208
},
203209
],
210+
[
211+
'mobile == 0',
212+
{
213+
'dependencies':
214+
[
215+
'engine/kernel-server.gyp:test-kernel-server<(javascriptify)',
216+
'engine/kernel-development.gyp:test-kernel-development<(javascriptify)',
217+
'engine/kernel-installer.gyp:test-kernel-installer<(javascriptify)',
218+
],
219+
},
220+
],
204221
],
205-
206-
'dependencies':
207-
[
208-
'libcpptest/libcpptest.gyp:test-libcpptest<(javascriptify)',
209-
],
210-
211222
},
212223
],
213224
}

0 commit comments

Comments
 (0)