Browse Source

Unit tests

Thomas Buck 10 years ago
parent
commit
16649cf2ee
11 changed files with 81 additions and 84 deletions
  1. 3
    0
      ChangeLog
  2. 2
    2
      Makefile
  3. 1
    1
      include/MatMath.h
  4. 1
    1
      include/memory_test.h
  5. 1
    1
      src/Texture.cpp
  6. 3
    16
      src/memory_test.cpp
  7. 14
    17
      test/GLString.cpp
  8. 14
    14
      test/MatMath.cpp
  9. 15
    15
      test/Matrix.cpp
  10. 13
    3
      test/TombRaider.cpp
  11. 14
    14
      test/memory_test.cpp

+ 3
- 0
ChangeLog View File

5
 
5
 
6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
7
 
7
 
8
+	[ 20140131 ]
9
+	* All unit tests buildable again and no more warnings
10
+
8
 	[ 20140129 ]
11
 	[ 20140129 ]
9
 	* Removed unused libferit stuff
12
 	* Removed unused libferit stuff
10
 	* Changed code to generate much less warnings
13
 	* Changed code to generate much less warnings

+ 2
- 2
Makefile View File

343
 	@-echo "Building Matrix unit test"
343
 	@-echo "Building Matrix unit test"
344
 	mkdir -p $(BUILD_TEST_DIR)
344
 	mkdir -p $(BUILD_TEST_DIR)
345
 	$(CC) $(FLAGS_ALL) $(WARNINGS) -g -lm -lstdc++ -Iinclude \
345
 	$(CC) $(FLAGS_ALL) $(WARNINGS) -g -lm -lstdc++ -Iinclude \
346
-	src/Matrix.cpp src/Quaternion.cpp src/Vector3d.cpp \
346
+	src/Matrix.cpp src/Quaternion.cpp src/Vector3d.cpp src/MatMath.cpp \
347
 	test/Matrix.cpp -o $(BUILD_TEST_DIR)/Matrix.test
347
 	test/Matrix.cpp -o $(BUILD_TEST_DIR)/Matrix.test
348
 
348
 
349
 Math.test:
349
 Math.test:
364
 
364
 
365
 Network.test:
365
 Network.test:
366
 	mkdir -p $(BUILD_TEST_DIR)
366
 	mkdir -p $(BUILD_TEST_DIR)
367
-	$(CC) $(TEST_FLAGS) $(WARNINGS) \
367
+	$(CC) $(TEST_FLAGS) $(WARNINGS) src/MatMath.cpp src/Vector3d.cpp \
368
 	src/Network.cpp test/Network.cpp -o $(BUILD_TEST_DIR)/Network.test
368
 	src/Network.cpp test/Network.cpp -o $(BUILD_TEST_DIR)/Network.test
369
 
369
 
370
 #################################################################
370
 #################################################################

+ 1
- 1
include/MatMath.h View File

13
 
13
 
14
 #define HEL_PI           ((float)M_PI) //!< pi
14
 #define HEL_PI           ((float)M_PI) //!< pi
15
 #define HEL_2_PI         (HEL_PI * 2.0f) //!< pi*2
15
 #define HEL_2_PI         (HEL_PI * 2.0f) //!< pi*2
16
-#define HEL_PI_OVER_4    (M_PI_4 / 4.0f) //!< pi/4
16
+#define HEL_PI_OVER_4    (HEL_PI / 4.0f) //!< pi/4
17
 #define HEL_PI_OVER_180  (HEL_PI / 180.0f) //!< pi/180
17
 #define HEL_PI_OVER_180  (HEL_PI / 180.0f) //!< pi/180
18
 #define HEL_180_OVER_PI  (180.0f / HEL_PI) //!< 180/pi
18
 #define HEL_180_OVER_PI  (180.0f / HEL_PI) //!< 180/pi
19
 
19
 

+ 1
- 1
include/memory_test.h View File

66
     char filename_len;
66
     char filename_len;
67
     DWORD size;
67
     DWORD size;
68
     unsigned int alloc_zero;
68
     unsigned int alloc_zero;
69
-    unsigned short int alloc_zero_at_line[ZERO_ALLOC_SLOTS];
69
+    unsigned int alloc_zero_at_line[ZERO_ALLOC_SLOTS];
70
     struct meminfo_filename_s *next;
70
     struct meminfo_filename_s *next;
71
 } meminfo_filename_t;
71
 } meminfo_filename_t;
72
 
72
 

+ 1
- 1
src/Texture.cpp View File

990
 
990
 
991
     return id;
991
     return id;
992
 #else
992
 #else
993
-    printf("ERROR: TGA support not enabled in this build\n");
993
+    printf("ERROR: TGA support not enabled in this build (%s)\n", filename);
994
     return -1;
994
     return -1;
995
 #endif
995
 #endif
996
 }
996
 }

+ 3
- 16
src/memory_test.cpp View File

12
 #define UNIT_TEST_MEMORY
12
 #define UNIT_TEST_MEMORY
13
 #include <memory_test.h>
13
 #include <memory_test.h>
14
 
14
 
15
-#define USE_ITERATIVE_TREE_INSERT
16
-
17
-
18
 bool tree_check(rbtree_t *tree, const char *file, int line)
15
 bool tree_check(rbtree_t *tree, const char *file, int line)
19
 {
16
 {
20
     bool ret = true;
17
     bool ret = true;
722
 {
719
 {
723
     DWORD address;
720
     DWORD address;
724
     DWORD size;
721
     DWORD size;
725
-    unsigned short int line;
722
+    unsigned int line;
726
     meminfo_filename_t *filename;
723
     meminfo_filename_t *filename;
727
 
724
 
728
 } meminfo_t;
725
 } meminfo_t;
771
 
768
 
772
 long memory_used(memory_query_t query)
769
 long memory_used(memory_query_t query)
773
 {
770
 {
774
-    switch (query)
775
-    {
771
+    switch (query) {
776
         case MEMORY_USED_BY_PROGRAM:
772
         case MEMORY_USED_BY_PROGRAM:
777
             return MEMORY_USED;
773
             return MEMORY_USED;
778
-            break;
779
         case MAX_MEMORY_USED_BY_PROGRAM:
774
         case MAX_MEMORY_USED_BY_PROGRAM:
780
             return MAX_MEMORY_USED;
775
             return MAX_MEMORY_USED;
781
-            break;
782
         case MAX_MEMORY_USED_BY_OVERHEAD:
776
         case MAX_MEMORY_USED_BY_OVERHEAD:
783
             return MAX_MEMORYA_USED + MAX_MEMORYC_USED;
777
             return MAX_MEMORYA_USED + MAX_MEMORYC_USED;
784
-            break;
785
         case MEMORY_USED_BY_OVERHEAD:
778
         case MEMORY_USED_BY_OVERHEAD:
786
             return MEMORYA_USED + MEMORYC_USED;
779
             return MEMORYA_USED + MEMORYC_USED;
787
-            break;
788
         case MEMORY_USED_TOTAL:
780
         case MEMORY_USED_TOTAL:
789
             return MEMORY_USED + MEMORYA_USED + MEMORYC_USED;
781
             return MEMORY_USED + MEMORYA_USED + MEMORYC_USED;
790
-            break;
791
-        default:
792
-            ;
793
     }
782
     }
794
-
795
-    return 0;
796
 }
783
 }
797
 
784
 
798
 
785
 
958
         if (!memfile)
945
         if (!memfile)
959
         {
946
         {
960
             memfile = (meminfo_filename_t *)malloc(sizeof(meminfo_filename_t));
947
             memfile = (meminfo_filename_t *)malloc(sizeof(meminfo_filename_t));
961
-            memfile->filename_len = len;
948
+            memfile->filename_len = (char)len;
962
             memfile->filename = (char *)malloc(len+1);
949
             memfile->filename = (char *)malloc(len+1);
963
             strncpy(memfile->filename, filename, len);
950
             strncpy(memfile->filename, filename, len);
964
             memfile->filename[len+1] = 0;
951
             memfile->filename[len+1] = 0;

+ 14
- 17
test/GLString.cpp View File

31
     // gluPerspective is deprecated!
31
     // gluPerspective is deprecated!
32
     // gluPerspective(40.0, aspect, 1, 2000);
32
     // gluPerspective(40.0, aspect, 1, 2000);
33
     // fix: http://stackoverflow.com/a/2417756
33
     // fix: http://stackoverflow.com/a/2417756
34
-    GLfloat fH = tan(float(40.0 / 360.0f * 3.14159f));
34
+    GLfloat fH = tanf(40.0f / 360.0f * 3.14159f);
35
     GLfloat fW = fH * aspect;
35
     GLfloat fW = fH * aspect;
36
     glFrustum(-fW, fW, -fH, fH, 1, 2000);
36
     glFrustum(-fW, fW, -fH, fH, 1, 2000);
37
 
37
 
39
 }
39
 }
40
 
40
 
41
 void event_display(int width, int height) {
41
 void event_display(int width, int height) {
42
-    static float x = 0.0, y = 0.0, z = -150.0, r = 0.0;
42
+    static float x = 0.0f, y = 0.0f, z = -150.0f, r = 0.0f;
43
 
43
 
44
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
44
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
45
     glLoadIdentity();
45
     glLoadIdentity();
46
 
46
 
47
-    glTranslatef(0.0, 0.0, -20.0);
48
-    glRotatef((float)cos(r)*180.0, 0.0, 0.0, 1.0);
49
-    r += 0.01;
47
+    glTranslatef(0.0f, 0.0f, -20.0f);
48
+    glRotatef((float)cosf(r)*180.0f, 0.0f, 0.0f, 1.0f);
49
+    r += 0.01f;
50
 
50
 
51
     // Mongoose 2002.01.01, Render color quad
51
     // Mongoose 2002.01.01, Render color quad
52
     glDisable(GL_TEXTURE_2D);
52
     glDisable(GL_TEXTURE_2D);
114
     if (i) {
114
     if (i) {
115
         printf(errorText, i);
115
         printf(errorText, i);
116
     }
116
     }
117
-    TEXT->Scale(1.2);
117
+    TEXT->Scale(1.2f);
118
     i = TEXT->glPrintf((width/2)-100, height/2+32, "Unit Test by Mongoose");
118
     i = TEXT->glPrintf((width/2)-100, height/2+32, "Unit Test by Mongoose");
119
     if (i) {
119
     if (i) {
120
         printf(errorText, i);
120
         printf(errorText, i);
129
     TEXT->setActive(3, true);
129
     TEXT->setActive(3, true);
130
 }
130
 }
131
 
131
 
132
-int main_gl(int argc, char *argv[]) {
132
+[[noreturn]] void main_gl() {
133
     SDL_Event event;
133
     SDL_Event event;
134
     unsigned int mkeys, mod, key;
134
     unsigned int mkeys, mod, key;
135
     int flags;
135
     int flags;
143
     // Setup clean up on exit
143
     // Setup clean up on exit
144
     atexit(shutdown_gl);
144
     atexit(shutdown_gl);
145
 
145
 
146
-    // Get user settings
147
-    //event_init(&width, &height, &fullscreen, &driver, argc, argv);
148
-
149
     // Create GL context
146
     // Create GL context
150
     SDL_Init(SDL_INIT_VIDEO);
147
     SDL_Init(SDL_INIT_VIDEO);
151
 
148
 
196
             switch (event.type) {
193
             switch (event.type) {
197
                 case SDL_QUIT:
194
                 case SDL_QUIT:
198
                     exit(0);
195
                     exit(0);
199
-                    break;
200
                 case SDL_MOUSEMOTION:
196
                 case SDL_MOUSEMOTION:
201
                     break;
197
                     break;
202
                 case SDL_MOUSEBUTTONDOWN:
198
                 case SDL_MOUSEBUTTONDOWN:
236
                     {
232
                     {
237
                         case 0x1B: // 27d, ESC
233
                         case 0x1B: // 27d, ESC
238
                             exit(0);
234
                             exit(0);
239
-                            break;
240
 #ifdef __APPLE__
235
 #ifdef __APPLE__
241
                         case 113: // q
236
                         case 113: // q
242
                             if ((mod & KMOD_RMETA) || (mod & KMOD_LMETA))
237
                             if ((mod & KMOD_RMETA) || (mod & KMOD_LMETA))
258
             }
253
             }
259
         }
254
         }
260
     }
255
     }
261
-
262
-    return 0;
263
 }
256
 }
264
 
257
 
265
 int main(int argc, char *argv[]) {
258
 int main(int argc, char *argv[]) {
266
-    TEXT = new GLString();
267
-    main_gl(argc, argv);
268
-    return 0;
259
+    if (argc == 1) {
260
+        TEXT = new GLString();
261
+        main_gl();
262
+    } else {
263
+        printf("Usage:\n\t%s\n", argv[0]);
264
+        return 1;
265
+    }
269
 }
266
 }
270
 
267
 

+ 14
- 14
test/MatMath.cpp View File

11
 #include <MatMath.h>
11
 #include <MatMath.h>
12
 #include "greatest.h"
12
 #include "greatest.h"
13
 
13
 
14
-vec_t testDegrees[] = { 0.0, 30.0, 45.0, 60.0, 90.0, 360.0, -100.0 };
15
-vec_t testRads[] = { 0.0, 0.5236, 0.7854, 1.0472, 1.5708, 6.2832, -1.7453 };
14
+vec_t testDegrees[] = { 0.0f, 30.0f, 45.0f, 60.0f, 90.0f, 360.0f, -100.0f };
15
+vec_t testRads[] = { 0.0f, 0.5236f, 0.7854f, 1.0472f, 1.5708f, 6.2832f, -1.7453f };
16
 vec_t testBounds[][2] = {
16
 vec_t testBounds[][2] = {
17
-    { 0.0, 1.0 },
18
-    { -5.0, 5.0 },
19
-    { 1.0, 1.0 },
17
+    { 0.0f, 1.0f },
18
+    { -5.0f, 5.0f },
19
+    { 1.0f, 1.0f },
20
 };
20
 };
21
 
21
 
22
 TEST constants() {
22
 TEST constants() {
23
-    ASSERT_EQm("Pi not correct!", HEL_PI, M_PI);
24
-    ASSERT_EQm("2Pi not correct!", HEL_2_PI, (M_PI * 2.0));
25
-    ASSERT_EQm("Pi/4 not correct!", HEL_PI_OVER_4, (M_PI / 4.0));
26
-    ASSERT_EQm("Pi/180 not correct!", HEL_PI_OVER_180, (M_PI / 180.0));
27
-    ASSERT_EQm("180/Pi not correct!", HEL_180_OVER_PI, (180.0 / M_PI));
23
+    ASSERTm("Pi not correct!", equalEpsilon(HEL_PI, (vec_t)M_PI));
24
+    ASSERTm("2Pi not correct!", equalEpsilon(HEL_2_PI, ((vec_t)M_PI * 2.0f)));
25
+    ASSERTm("Pi/4 not correct!", equalEpsilon(HEL_PI_OVER_4, ((vec_t)M_PI / 4.0f)));
26
+    ASSERTm("Pi/180 not correct!", equalEpsilon(HEL_PI_OVER_180, ((vec_t)M_PI / 180.0f)));
27
+    ASSERTm("180/Pi not correct!", equalEpsilon(HEL_180_OVER_PI, (180.0f / (vec_t)M_PI)));
28
     PASS();
28
     PASS();
29
 }
29
 }
30
 
30
 
38
 
38
 
39
 TEST conversionToRad(vec_t deg) {
39
 TEST conversionToRad(vec_t deg) {
40
     vec_t conv = HEL_DEG_TO_RAD(deg);
40
     vec_t conv = HEL_DEG_TO_RAD(deg);
41
-    vec_t hand = (deg * M_PI / 180.0);
42
-    if (conv != hand) {
41
+    vec_t hand = (deg * (vec_t)M_PI / 180.0f);
42
+    if (!equalEpsilon(conv, hand)) {
43
         printf("Degree to Radian conversion failed: %f != %f\n", conv, hand);
43
         printf("Degree to Radian conversion failed: %f != %f\n", conv, hand);
44
         FAIL();
44
         FAIL();
45
     } else {
45
     } else {
49
 
49
 
50
 TEST conversionToDeg(vec_t rad) {
50
 TEST conversionToDeg(vec_t rad) {
51
     vec_t conv = HEL_RAD_TO_DEG(rad);
51
     vec_t conv = HEL_RAD_TO_DEG(rad);
52
-    vec_t hand = (rad * 180.0 / M_PI);
53
-    if (conv != hand) {
52
+    vec_t hand = (rad * 180.0f / (vec_t)M_PI);
53
+    if (!equalEpsilon(conv, hand)) {
54
         printf("Radian to Degree conversion failed: %f != %f\n", conv, hand);
54
         printf("Radian to Degree conversion failed: %f != %f\n", conv, hand);
55
         FAIL();
55
         FAIL();
56
     } else {
56
     } else {

+ 15
- 15
test/Matrix.cpp View File

62
     Matrix a;
62
     Matrix a;
63
     a.setIdentity();
63
     a.setIdentity();
64
     a.translate(10, 20, 30);
64
     a.translate(10, 20, 30);
65
-    ASSERT(a.mMatrix[i12] == 10);
66
-    ASSERT(a.mMatrix[i13] == 20);
67
-    ASSERT(a.mMatrix[i14] == 30);
65
+    ASSERT(equalEpsilon(a.mMatrix[i12], 10));
66
+    ASSERT(equalEpsilon(a.mMatrix[i13], 20));
67
+    ASSERT(equalEpsilon(a.mMatrix[i14], 30));
68
     PASS();
68
     PASS();
69
 }
69
 }
70
 
70
 
74
     vec_t rot = 90 * 0.01745329251994329f;
74
     vec_t rot = 90 * 0.01745329251994329f;
75
     a.rotate((axis == 0) ? rot : 0, (axis == 1) ? rot : 0, (axis == 2) ? rot : 0);
75
     a.rotate((axis == 0) ? rot : 0, (axis == 1) ? rot : 0, (axis == 2) ? rot : 0);
76
     if (axis == 0) {
76
     if (axis == 0) {
77
-        ASSERT(a.mMatrix[i0] == 1);
78
-        ASSERT(a.mMatrix[i15] == 1);
79
-        ASSERT(a.mMatrix[i9] == -1);
80
-        ASSERT(a.mMatrix[i6] == 1);
77
+        ASSERT(equalEpsilon(a.mMatrix[i0], 1));
78
+        ASSERT(equalEpsilon(a.mMatrix[i15], 1));
79
+        ASSERT(equalEpsilon(a.mMatrix[i9], -1));
80
+        ASSERT(equalEpsilon(a.mMatrix[i6], 1));
81
     } else if (axis == 1) {
81
     } else if (axis == 1) {
82
-        ASSERT(a.mMatrix[i8] == 1);
83
-        ASSERT(a.mMatrix[i2] == -1);
84
-        ASSERT(a.mMatrix[i15] == 1);
82
+        ASSERT(equalEpsilon(a.mMatrix[i8], 1));
83
+        ASSERT(equalEpsilon(a.mMatrix[i2], -1));
84
+        ASSERT(equalEpsilon(a.mMatrix[i15], 1));
85
     } else if (axis == 2) {
85
     } else if (axis == 2) {
86
-        ASSERT(a.mMatrix[i4] == -1);
87
-        ASSERT(a.mMatrix[i15] == 1);
88
-        ASSERT(a.mMatrix[i1] == 1);
89
-        ASSERT(a.mMatrix[i10] == 1);
86
+        ASSERT(equalEpsilon(a.mMatrix[i4], -1));
87
+        ASSERT(equalEpsilon(a.mMatrix[i15], 1));
88
+        ASSERT(equalEpsilon(a.mMatrix[i1], 1));
89
+        ASSERT(equalEpsilon(a.mMatrix[i10], 1));
90
     } else {
90
     } else {
91
         FAIL();
91
         FAIL();
92
     }
92
     }
105
     a.scale(10, 10, 10);
105
     a.scale(10, 10, 10);
106
     a.print();
106
     a.print();
107
     printf("\n -> scale (0.1, 0.1, 0.1)\n");
107
     printf("\n -> scale (0.1, 0.1, 0.1)\n");
108
-    a.scale(0.1, 0.1, 0.1);
108
+    a.scale(0.1f, 0.1f, 0.1f);
109
     printf(" -> Translate (-10, -20, -30)\n");
109
     printf(" -> Translate (-10, -20, -30)\n");
110
     a.translate(-10, -20, -30);
110
     a.translate(-10, -20, -30);
111
     printf(" -> Rotate (0, 0, -90 degrees)\n");
111
     printf(" -> Rotate (0, 0, -90 degrees)\n");

+ 13
- 3
test/TombRaider.cpp View File

89
 
89
 
90
             if (f)
90
             if (f)
91
             {
91
             {
92
-                if (!mtk_image__tga_save(f, image, 256, 256, 4))
92
+                if (!tga_save(f, image, 256, 256, 4))
93
                     printf("\tWrote texture %s\n", buffer);
93
                     printf("\tWrote texture %s\n", buffer);
94
 
94
 
95
                 fclose(f);
95
                 fclose(f);
116
 
116
 
117
             if (f)
117
             if (f)
118
             {
118
             {
119
-                if (!mtk_image__tga_save(f, bumpmap, 256, 256, 4))
119
+                if (!tga_save(f, bumpmap, 256, 256, 4))
120
                     printf("\tWrote texture %s\n", buffer);
120
                     printf("\tWrote texture %s\n", buffer);
121
 
121
 
122
                 fclose(f);
122
                 fclose(f);
136
 
136
 
137
         if (f)
137
         if (f)
138
         {
138
         {
139
-            if (!mtk_image__tga_save(f, image, 256, 256, 4))
139
+            if (!tga_save(f, image, 256, 256, 4))
140
                 printf("\tWrote texture %s\n", buffer);
140
                 printf("\tWrote texture %s\n", buffer);
141
 
141
 
142
             fclose(f);
142
             fclose(f);
352
                         & 0xff, rgba);
352
                         & 0xff, rgba);
353
                 break;
353
                 break;
354
             default:
354
             default:
355
+            case TR_VERSION_UNKNOWN:
356
+            case TR_VERSION_2:
357
+            case TR_VERSION_3:
358
+            case TR_VERSION_4:
359
+            case TR_VERSION_5:
355
                 tr->getColor((meshes[index].coloured_triangles[i].texture>>8)
360
                 tr->getColor((meshes[index].coloured_triangles[i].texture>>8)
356
                         & 0xff, rgba);
361
                         & 0xff, rgba);
357
         }
362
         }
404
                         & 0xff, rgba);
409
                         & 0xff, rgba);
405
                 break;
410
                 break;
406
             default:
411
             default:
412
+            case TR_VERSION_UNKNOWN:
413
+            case TR_VERSION_2:
414
+            case TR_VERSION_3:
415
+            case TR_VERSION_4:
416
+            case TR_VERSION_5:
407
                 tr->getColor((meshes[index].coloured_rectangles[i].texture>>8)
417
                 tr->getColor((meshes[index].coloured_rectangles[i].texture>>8)
408
                         & 0xff, rgba);
418
                         & 0xff, rgba);
409
         }
419
         }

+ 14
- 14
test/memory_test.cpp View File

24
 
24
 
25
 #define PRINT_TEST_BREAK_LINE   printf("\n############################################################\n\n");
25
 #define PRINT_TEST_BREAK_LINE   printf("\n############################################################\n\n");
26
 
26
 
27
-int memory_test_unit_test(int argc, char *argv[])
28
-{
27
+int memory_test_unit_test() {
29
     int *i, *j, *k, *l, *m, *n, *o;
28
     int *i, *j, *k, *l, *m, *n, *o;
30
 
29
 
31
-
32
     PRINT_TEST_BREAK_LINE
30
     PRINT_TEST_BREAK_LINE
33
         printf("Memory test\n");
31
         printf("Memory test\n");
34
     PRINT_TEST_BREAK_LINE
32
     PRINT_TEST_BREAK_LINE
35
 
33
 
36
-        i = new int;
34
+    i = new int;
37
     printf(">\ti = new int; (%p)  %s:%i\n", i, __FILE__, __LINE__);
35
     printf(">\ti = new int; (%p)  %s:%i\n", i, __FILE__, __LINE__);
38
     dump_memory_report();
36
     dump_memory_report();
39
     tree_valid_report(MEMORY_INFO);
37
     tree_valid_report(MEMORY_INFO);
45
 
43
 
46
     PRINT_TEST_BREAK_LINE
44
     PRINT_TEST_BREAK_LINE
47
 
45
 
48
-        i = new int[3];
46
+    i = new int[3];
49
     printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
47
     printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
50
     dump_memory_report();
48
     dump_memory_report();
51
     tree_valid_report(MEMORY_INFO);
49
     tree_valid_report(MEMORY_INFO);
57
 
55
 
58
     PRINT_TEST_BREAK_LINE
56
     PRINT_TEST_BREAK_LINE
59
 
57
 
60
-        i = new int[3];
58
+    i = new int[3];
61
     printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
59
     printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
62
     j = new int;
60
     j = new int;
63
     printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
61
     printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
76
 
74
 
77
     PRINT_TEST_BREAK_LINE
75
     PRINT_TEST_BREAK_LINE
78
 
76
 
79
-        i = new int[3];
77
+    i = new int[3];
80
     printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
78
     printf(">\ti = new int[3]; (%p)  %s:%i\n", i, __FILE__, __LINE__);
81
     j = new int;
79
     j = new int;
82
     printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
80
     printf(">\tj = new int; (%p)  %s:%i\n", j, __FILE__, __LINE__);
148
 
146
 
149
     PRINT_TEST_BREAK_LINE
147
     PRINT_TEST_BREAK_LINE
150
 
148
 
151
-        return 0;
149
+    return 0;
152
 }
150
 }
153
 
151
 
154
-
155
-int main(int argc, char *argv[])
156
-{
157
-    printf("[memory_test test]\n");
158
-
159
-    return memory_test_unit_test(argc, argv);
152
+int main(int argc, char *argv[]) {
153
+    if (argc != 1) {
154
+        printf("Usage:\n\t%s\n", argv[0]);
155
+        return 1;
156
+    } else {
157
+        printf("[memory_test test]\n");
158
+        return memory_test_unit_test();
159
+    }
160
 }
160
 }
161
 
161
 

Loading…
Cancel
Save