Parcourir la source

Removed memory test

Thomas Buck il y a 10 ans
Parent
révision
63e4bb5fd6
22 fichiers modifiés avec 6 ajouts et 1501 suppressions
  1. 3
    0
      ChangeLog
  2. 3
    26
      Makefile
  3. 0
    1
      README.md
  4. 0
    4
      include/List.h
  5. 0
    4
      include/Vector.h
  6. 0
    84
      include/memory_test.h
  7. 0
    5
      src/Camera.cpp
  8. 0
    4
      src/Emitter.cpp
  9. 0
    5
      src/GLString.cpp
  10. 0
    33
      src/OpenRaider.cpp
  11. 0
    5
      src/Particle.cpp
  12. 0
    4
      src/Render.cpp
  13. 0
    9
      src/SDLSystem.cpp
  14. 0
    4
      src/SkeletalModel.cpp
  15. 0
    6
      src/Sound.cpp
  16. 0
    4
      src/System.cpp
  17. 0
    4
      src/Texture.cpp
  18. 0
    6
      src/TombRaider.cpp
  19. 0
    4
      src/World.cpp
  20. 0
    1146
      src/memory_test.cpp
  21. 0
    4
      src/tga.cpp
  22. 0
    139
      test/memory_test.cpp

+ 3
- 0
ChangeLog Voir le fichier

5
 
5
 
6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
7
 
7
 
8
+	[ 20140304 ]
9
+	* Removed memory test
10
+
8
 	[ 20140303 ]
11
 	[ 20140303 ]
9
 	* Removed Map.h & Tree.h, using std::map instead...
12
 	* Removed Map.h & Tree.h, using std::map instead...
10
 
13
 

+ 3
- 26
Makefile Voir le fichier

65
 BUILD_RELEASE_DIR=bin/release
65
 BUILD_RELEASE_DIR=bin/release
66
 BUILD_PROF_DIR=bin/prof
66
 BUILD_PROF_DIR=bin/prof
67
 BUILD_TEST_DIR=bin/test
67
 BUILD_TEST_DIR=bin/test
68
-BUILD_MEM_DIR=bin/mem
69
 BUILD_INSTALL_DIR=bin/$(BUILD_SELECT)
68
 BUILD_INSTALL_DIR=bin/$(BUILD_SELECT)
70
 DEB_DIR=/tmp/$(NAME).deb
69
 DEB_DIR=/tmp/$(NAME).deb
71
 
70
 
154
 	CFLAGS="$(DEBUG_CFLAGS) -DDEDICATED_SERVER" \
153
 	CFLAGS="$(DEBUG_CFLAGS) -DDEDICATED_SERVER" \
155
 	LD_FLAGS="$(LD_FLAGS)"
154
 	LD_FLAGS="$(LD_FLAGS)"
156
 
155
 
157
-# -DDEBUG_MEMORY_VERBOSE
158
-# -DDEBUG_MEMORY
159
-memory:
160
-	@-mkdir -p $(BUILD_MEM_DIR)
161
-	$(MAKE) targets BUILDDIR=$(BUILD_MEM_DIR) \
162
-	DEBUG_OBJ="$(BUILD_MEM_DIR)/memory_test.o" \
163
-	CFLAGS="$(DEBUG_CFLAGS) -DDEBUG_MEMORY" \
164
-	LD_FLAGS="$(LD_FLAGS)"
165
-
166
 depend:
156
 depend:
167
 	@-echo "Making deps..."
157
 	@-echo "Making deps..."
168
 	@-echo "# Autogenerated dependency file" > depend
158
 	@-echo "# Autogenerated dependency file" > depend
258
 	@-rm -f $(BUILD_DEBUG_DIR)/*.o
248
 	@-rm -f $(BUILD_DEBUG_DIR)/*.o
259
 	@-rm -f $(BUILD_RELEASE_DIR)/*.o
249
 	@-rm -f $(BUILD_RELEASE_DIR)/*.o
260
 	@-rm -f $(BUILD_TEST_DIR)/*.o
250
 	@-rm -f $(BUILD_TEST_DIR)/*.o
261
-	@-rm -f $(BUILD_MEM_DIR)/*.o
262
 	@-echo "[DONE]"
251
 	@-echo "[DONE]"
263
 
252
 
264
 clean-build:
253
 clean-build:
266
 	@-rm -f $(BUILD_PROF_DIR)/$(NAME)
255
 	@-rm -f $(BUILD_PROF_DIR)/$(NAME)
267
 	@-rm -f $(BUILD_DEBUG_DIR)/$(NAME)
256
 	@-rm -f $(BUILD_DEBUG_DIR)/$(NAME)
268
 	@-rm -f $(BUILD_RELEASE_DIR)/$(NAME)
257
 	@-rm -f $(BUILD_RELEASE_DIR)/$(NAME)
269
-	@-rm -f $(BUILD_MEM_DIR)/$(NAME)
270
 	@-echo "[DONE]"
258
 	@-echo "[DONE]"
271
 
259
 
272
 clean-doc:
260
 clean-doc:
311
 TEST_MAP_TR2=~/.OpenRaider/paks/tr2/unwater.tr2
299
 TEST_MAP_TR2=~/.OpenRaider/paks/tr2/unwater.tr2
312
 TEST_MAP_TR1=~/.OpenRaider/paks/tr1/level1.phd
300
 TEST_MAP_TR1=~/.OpenRaider/paks/tr1/level1.phd
313
 
301
 
314
-test.build: Matrix.test Math.test Memory.test Network.test Sound.test tga.test GLString.test TombRaider.test
302
+test.build: Matrix.test Math.test Network.test Sound.test tga.test GLString.test TombRaider.test
315
 
303
 
316
 test: test.build
304
 test: test.build
317
 	@-echo "================================================="
305
 	@-echo "================================================="
318
-	@-echo "Running Memory unit test"
319
-	$(BUILD_TEST_DIR)/memory_test.test
320
-	@-echo "================================================="
321
 	@-echo "Running Matrix unit test"
306
 	@-echo "Running Matrix unit test"
322
 	$(BUILD_TEST_DIR)/Matrix.test
307
 	$(BUILD_TEST_DIR)/Matrix.test
323
 	@-echo "================================================="
308
 	@-echo "================================================="
344
 	$(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR4) > /tmp/log.tr4
329
 	$(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR4) > /tmp/log.tr4
345
 	$(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR5) > /tmp/log.tr5
330
 	$(BUILD_TEST_DIR)/TombRaider.test load $(TEST_MAP_TR5) > /tmp/log.tr5
346
 
331
 
347
-TR_FLAGS = -D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES -DDEBUG_MEMORY
332
+TR_FLAGS = -D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES
348
 
333
 
349
 TombRaider.test:
334
 TombRaider.test:
350
 	@-mkdir -p $(BUILD_TEST_DIR)
335
 	@-mkdir -p $(BUILD_TEST_DIR)
351
 	$(CC) $(FLAGS_ALL) $(WARNINGS) -Iinclude $(TR_FLAGS) -o $(BUILD_TEST_DIR)/TombRaiderTest.o -c test/TombRaider.cpp
336
 	$(CC) $(FLAGS_ALL) $(WARNINGS) -Iinclude $(TR_FLAGS) -o $(BUILD_TEST_DIR)/TombRaiderTest.o -c test/TombRaider.cpp
352
 	$(MAKE) targets NAME=TombRaider.test BUILDDIR=$(BUILD_TEST_DIR) \
337
 	$(MAKE) targets NAME=TombRaider.test BUILDDIR=$(BUILD_TEST_DIR) \
353
-	OBJS="$(BUILD_TEST_DIR)/TombRaiderTest.o $(BUILD_TEST_DIR)/TombRaider.o $(BUILD_TEST_DIR)/tga.o $(BUILD_TEST_DIR)/memory_test.o" \
338
+	OBJS="$(BUILD_TEST_DIR)/TombRaiderTest.o $(BUILD_TEST_DIR)/TombRaider.o $(BUILD_TEST_DIR)/tga.o" \
354
 	CFLAGS="$(BASE_CFLAGS) -g $(TR_FLAGS)" \
339
 	CFLAGS="$(BASE_CFLAGS) -g $(TR_FLAGS)" \
355
 	LD_FLAGS="-lz -lstdc++"
340
 	LD_FLAGS="-lz -lstdc++"
356
 
341
 
381
 
366
 
382
 #################################################################
367
 #################################################################
383
 
368
 
384
-Memory.test:
385
-	mkdir -p $(BUILD_TEST_DIR)
386
-	$(CC) $(FLAGS_ALL) $(WARNINGS) -g -lstdc++ -Iinclude \
387
-	-DDEBUG_MEMORY -DDEBUG_MEMORY_ERROR \
388
-	src/memory_test.cpp test/memory_test.cpp -o $(BUILD_TEST_DIR)/memory_test.test
389
-
390
-#################################################################
391
-
392
 Network.test:
369
 Network.test:
393
 	mkdir -p $(BUILD_TEST_DIR)
370
 	mkdir -p $(BUILD_TEST_DIR)
394
 	$(CC) $(TEST_FLAGS) $(WARNINGS) src/MatMath.cpp src/Vector3d.cpp \
371
 	$(CC) $(TEST_FLAGS) $(WARNINGS) src/MatMath.cpp src/Vector3d.cpp \

+ 0
- 1
README.md Voir le fichier

148
 | noclip              | Toggle world clipping in cycle                         |
148
 | noclip              | Toggle world clipping in cycle                         |
149
 | hop                 | Toggle room hopping hack                               |
149
 | hop                 | Toggle room hopping hack                               |
150
 | showfps BOOL        | Show FPS                                               |
150
 | showfps BOOL        | Show FPS                                               |
151
-| mem ARG             | Prints memory report, where ARG is `usage` or `report` |
152
 | resize STRING       | Change resolution to `xga`, `svga` or `vga`            |
151
 | resize STRING       | Change resolution to `xga`, `svga` or `vga`            |
153
 
152
 
154
 #### Render
153
 #### Render

+ 0
- 4
include/List.h Voir le fichier

15
 #include <limits.h>
15
 #include <limits.h>
16
 #include <stdio.h>
16
 #include <stdio.h>
17
 
17
 
18
-#ifdef DEBUG_MEMORY
19
-#include <memory_test.h>
20
-#endif
21
-
22
 /*!
18
 /*!
23
  * \brief Template class encapsulating a single list node
19
  * \brief Template class encapsulating a single list node
24
  * \tparam T encapsulated data type
20
  * \tparam T encapsulated data type

+ 0
- 4
include/Vector.h Voir le fichier

11
 #include <stdlib.h>
11
 #include <stdlib.h>
12
 #include <stdio.h>
12
 #include <stdio.h>
13
 
13
 
14
-#ifdef DEBUG_MEMORY
15
-#include <memory_test.h>
16
-#endif
17
-
18
 /*!
14
 /*!
19
  * \brief Template class for a (pretty strange) Vector
15
  * \brief Template class for a (pretty strange) Vector
20
  * \tparam Object datatype the Vector can store
16
  * \tparam Object datatype the Vector can store

+ 0
- 84
include/memory_test.h Voir le fichier

1
-/*!
2
- * \file include/memory_test.h
3
- * Memory testing Toolkit
4
- *
5
- * \author Mongoose
6
- */
7
-
8
-#ifndef _MEMORY_TEST_H_
9
-#define _MEMORY_TEST_H_
10
-
11
-#include <cstddef>
12
-
13
-#if defined(DEBUG_MEMORY) && !defined(UNIT_TEST_MEMORY)
14
-
15
-#define DEBUG_NEW new(__FILE__, __LINE__)
16
-void *operator new(size_t size, const char *file, int line);
17
-void *operator new [](size_t size, const char *file, int line);
18
-
19
-#define DEBUG_DELETE delete_check(__FILE__, __LINE__, 0);delete
20
-void operator delete(void *p);
21
-void operator delete [](void *p);
22
-
23
-#else
24
-
25
-#define DEBUG_NEW new
26
-#define DEBUG_DELETE delete
27
-
28
-#endif
29
-
30
-#define new DEBUG_NEW
31
-#define delete DEBUG_DELETE
32
-
33
-typedef enum {
34
-    MEMORY_USED_BY_PROGRAM      = 1,
35
-    MEMORY_USED_BY_OVERHEAD     = 2,
36
-    MEMORY_USED_TOTAL           = 3,
37
-    MAX_MEMORY_USED_BY_PROGRAM  = 4,
38
-    MAX_MEMORY_USED_BY_OVERHEAD = 5
39
-} memory_query_t;
40
-
41
-void delete_check(const char *file, int line, int print);
42
-
43
-void display_memory_usage();
44
-
45
-/*!
46
- * \brief Get total memory usage
47
- * \param query what to return
48
- * \returns amount of requested memory used
49
- */
50
-long memory_used(memory_query_t query);
51
-
52
-/*!
53
- * \brief Dumps raw Tree holding memory accounting
54
- */
55
-void dump_memory_report();
56
-
57
-#ifdef DEBUG_MEMORY
58
-
59
-#define DWORD unsigned long
60
-#define ZERO_ALLOC_SLOTS 3
61
-
62
-typedef enum { RB_BLACK = 0, RB_RED = 1 } rbtree_color_t;
63
-
64
-typedef struct rbtree_s {
65
-    void *data;
66
-    DWORD key;
67
-    rbtree_color_t color;
68
-    struct rbtree_s *left;
69
-    struct rbtree_s *right;
70
-    struct rbtree_s *parent;
71
-} rbtree_t;
72
-
73
-typedef struct meminfo_filename_s {
74
-    char *filename;
75
-    char filename_len;
76
-    DWORD size;
77
-    unsigned int alloc_zero;
78
-    unsigned int alloc_zero_at_line[ZERO_ALLOC_SLOTS];
79
-    struct meminfo_filename_s *next;
80
-} meminfo_filename_t;
81
-
82
-#endif
83
-
84
-#endif

+ 0
- 5
src/Camera.cpp Voir le fichier

11
 #include <MatMath.h>
11
 #include <MatMath.h>
12
 #include <Camera.h>
12
 #include <Camera.h>
13
 
13
 
14
-#ifdef DEBUG_MEMORY
15
-#include <memory_test.h>
16
-#endif
17
-
18
-
19
 unsigned int Camera::mCounter = 0;
14
 unsigned int Camera::mCounter = 0;
20
 
15
 
21
 ////////////////////////////////////////////////////////////
16
 ////////////////////////////////////////////////////////////

+ 0
- 4
src/Emitter.cpp Voir le fichier

18
 
18
 
19
 #include <Emitter.h>
19
 #include <Emitter.h>
20
 
20
 
21
-#ifdef DEBUG_MEMORY
22
-#include <memory_test.h>
23
-#endif
24
-
25
 vec_t Emitter::mFrustum[6][4];
21
 vec_t Emitter::mFrustum[6][4];
26
 
22
 
27
 int Emitter::compareParticleDist(const void *voidA, const void *voidB) {
23
 int Emitter::compareParticleDist(const void *voidA, const void *voidB) {

+ 0
- 5
src/GLString.cpp Voir le fichier

19
 #include <Texture.h>
19
 #include <Texture.h>
20
 #include <GLString.h>
20
 #include <GLString.h>
21
 
21
 
22
-#ifdef DEBUG_MEMORY
23
-#include <memory_test.h>
24
-#endif
25
-
26
-
27
 GLString::GLString() {
22
 GLString::GLString() {
28
     _num_string_max = 0;
23
     _num_string_max = 0;
29
     _num_string = 0;
24
     _num_string = 0;

+ 0
- 33
src/OpenRaider.cpp Voir le fichier

14
 #include <sys/types.h>
14
 #include <sys/types.h>
15
 #include <dirent.h>
15
 #include <dirent.h>
16
 
16
 
17
-#ifdef DEBUG_MEMORY
18
-#include <memory_test.h>
19
-#endif
20
-
21
 #include <World.h>
17
 #include <World.h>
22
 #include <SkeletalModel.h>
18
 #include <SkeletalModel.h>
23
 #include <TombRaider1.h> // tmp stop-gap
19
 #include <TombRaider1.h> // tmp stop-gap
77
     //delete OpenRaider::Instance();
73
     //delete OpenRaider::Instance();
78
 #warning "Can't delete OpenRaider::Instance() without a not-allocated-free error. Something is fishy here..."
74
 #warning "Can't delete OpenRaider::Instance() without a not-allocated-free error. Something is fishy here..."
79
 
75
 
80
-#ifdef DEBUG_MEMORY
81
-    printf("\n[Mongoose MEMORY_DEBUG]\nMemory leak table:\n");
82
-    dump_memory_report();
83
-#endif
84
-
85
     printf("\nThanks for testing %s\n", VERSION);
76
     printf("\nThanks for testing %s\n", VERSION);
86
     printf("Build date: %s @ %s\n", __DATE__, __TIME__);
77
     printf("Build date: %s @ %s\n", __DATE__, __TIME__);
87
     printf("Build host: %s\n", BUILD_HOST);
78
     printf("Build host: %s\n", BUILD_HOST);
1166
     // Cache/process sound fx
1157
     // Cache/process sound fx
1167
     processPakSounds();
1158
     processPakSounds();
1168
 
1159
 
1169
-#ifdef DEBUG_MEMORY
1170
-    // Right before pak is cleared will be highest use or memory
1171
-    display_memory_usage();
1172
-#endif
1173
-
1174
     // Mongoose 2002.01.02, Go ahead and free the TR pak
1160
     // Mongoose 2002.01.02, Go ahead and free the TR pak
1175
     m_tombraider.reset();
1161
     m_tombraider.reset();
1176
 
1162
 
1177
     print(true, "Level pak freed from memory, Starting game...");
1163
     print(true, "Level pak freed from memory, Starting game...");
1178
 
1164
 
1179
-#ifdef DEBUG_MEMORY
1180
-    display_memory_usage();
1181
-#endif
1182
-
1183
     /*! \fixme GL call to critical section,
1165
     /*! \fixme GL call to critical section,
1184
      * needs mutex really -- Mongoose 2002.01.02
1166
      * needs mutex really -- Mongoose 2002.01.02
1185
      */
1167
      */
2943
 
2925
 
2944
         print(false, "World clipping is [OFF]");
2926
         print(false, "World clipping is [OFF]");
2945
     }
2927
     }
2946
-    else if (rc_command("mem", cmd))
2947
-    {
2948
-#ifdef DEBUG_MEMORY
2949
-        if (rc_command("usage", cmd))
2950
-        {
2951
-            display_memory_usage();
2952
-        }
2953
-        else if (rc_command("report", cmd))
2954
-        {
2955
-            dump_memory_report();
2956
-        }
2957
-#else
2958
-        printf("This build isn't DEBUG_MEMORY enabled\n");
2959
-#endif
2960
-    }
2961
     else if (rc_command("loadlevel", cmd))
2928
     else if (rc_command("loadlevel", cmd))
2962
     {
2929
     {
2963
         loadLevel(cmd);
2930
         loadLevel(cmd);

+ 0
- 5
src/Particle.cpp Voir le fichier

10
 
10
 
11
 #include <Particle.h>
11
 #include <Particle.h>
12
 
12
 
13
-#ifdef DEBUG_MEMORY
14
-#include <memory_test.h>
15
-#endif
16
-
17
-
18
 Particle::Particle()
13
 Particle::Particle()
19
 {
14
 {
20
     setActive(true);
15
     setActive(true);

+ 0
- 4
src/Render.cpp Voir le fichier

20
 #include <Emitter.h>
20
 #include <Emitter.h>
21
 #endif
21
 #endif
22
 
22
 
23
-#ifdef DEBUG_MEMORY
24
-#include <memory_test.h>
25
-#endif
26
-
27
 #include <Render.h>
23
 #include <Render.h>
28
 
24
 
29
 extern entity_t *LARA;
25
 extern entity_t *LARA;

+ 0
- 9
src/SDLSystem.cpp Voir le fichier

10
 #include <string.h>
10
 #include <string.h>
11
 #include <cmath>
11
 #include <cmath>
12
 
12
 
13
-#ifdef MEMORY_TEST
14
-#include <memory_test.h>
15
-#endif
16
-
17
 #include <SDL2/SDL_opengl.h>
13
 #include <SDL2/SDL_opengl.h>
18
 
14
 
19
 #include <MatMath.h>
15
 #include <MatMath.h>
355
     //SDL_QuitSubSystem(SDL_OPENGL);
351
     //SDL_QuitSubSystem(SDL_OPENGL);
356
     //SDL_Quit(); // Moved to atexit() call
352
     //SDL_Quit(); // Moved to atexit() call
357
 
353
 
358
-    //#ifdef DEBUG_MEMORY
359
-    //printf("[Mongoose MEMORY_DEBUG]\nUnfreed memory table:\n");
360
-    //dump_memory_report();
361
-    //#endif
362
-
363
     exit(i);
354
     exit(i);
364
 }
355
 }
365
 
356
 

+ 0
- 4
src/SkeletalModel.cpp Voir le fichier

7
 
7
 
8
 #include <SkeletalModel.h>
8
 #include <SkeletalModel.h>
9
 
9
 
10
-#ifdef MEMORY_TEST
11
-#include <memory_test.h>
12
-#endif
13
-
14
 ////////////////////////////////////////////////////////////
10
 ////////////////////////////////////////////////////////////
15
 // Constructors
11
 // Constructors
16
 ////////////////////////////////////////////////////////////
12
 ////////////////////////////////////////////////////////////

+ 0
- 6
src/Sound.cpp Voir le fichier

27
 
27
 
28
 #include <Sound.h>
28
 #include <Sound.h>
29
 
29
 
30
-#ifdef DEBUG_MEMORY
31
-#include <memory_test.h>
32
-#endif
33
-
34
-
35
-
36
 Sound::Sound()
30
 Sound::Sound()
37
 {
31
 {
38
     mSource[0] = 0;
32
     mSource[0] = 0;

+ 0
- 4
src/System.cpp Voir le fichier

28
 #include <sys/time.h>
28
 #include <sys/time.h>
29
 #endif
29
 #endif
30
 
30
 
31
-#ifdef MEMORY_TEST
32
-#include <memory_test.h>
33
-#endif
34
-
35
 #include <MatMath.h>
31
 #include <MatMath.h>
36
 #include <System.h>
32
 #include <System.h>
37
 
33
 

+ 0
- 4
src/Texture.cpp Voir le fichier

10
 #include <stdio.h>
10
 #include <stdio.h>
11
 #include <stdarg.h>
11
 #include <stdarg.h>
12
 
12
 
13
-#ifdef DEBUG_MEMORY
14
-#include <memory_test.h>
15
-#endif
16
-
17
 #include <SDL2/SDL_ttf.h>
13
 #include <SDL2/SDL_ttf.h>
18
 
14
 
19
 #ifdef __APPLE__
15
 #ifdef __APPLE__

+ 0
- 6
src/TombRaider.cpp Voir le fichier

58
 #include <TGA.h>
58
 #include <TGA.h>
59
 #endif
59
 #endif
60
 
60
 
61
-#ifdef DEBUG_MEMORY
62
-#include <memory_test.h>
63
-#endif
64
-
65
-
66
-
67
 TombRaider::TombRaider()
61
 TombRaider::TombRaider()
68
 {
62
 {
69
     _textile8 = NULL;
63
     _textile8 = NULL;

+ 0
- 4
src/World.cpp Voir le fichier

5
  * \author Mongoose
5
  * \author Mongoose
6
  */
6
  */
7
 
7
 
8
-#ifdef DEBUG_MEMORY
9
-#include <memory_test.h>
10
-#endif
11
-
12
 #include <math.h>
8
 #include <math.h>
13
 
9
 
14
 #include <World.h>
10
 #include <World.h>

+ 0
- 1146
src/memory_test.cpp
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


+ 0
- 4
src/tga.cpp Voir le fichier

13
 
13
 
14
 #include <TGA.h>
14
 #include <TGA.h>
15
 
15
 
16
-#ifdef DEBUG_MEMORY
17
-#include <memory_test.h>
18
-#endif
19
-
20
 int tga_check(FILE *f) {
16
 int tga_check(FILE *f) {
21
     char buffer[10];
17
     char buffer[10];
22
 
18
 

+ 0
- 139
test/memory_test.cpp Voir le fichier

1
-/*!
2
- * \file test/memory_test.cpp
3
- * Memory testing Toolkit Unit test
4
- *
5
- * \author Mongoose
6
- * \author xythobuz
7
- */
8
-
9
-#include <string.h>
10
-#include <stdio.h>
11
-#include <stdlib.h>
12
-#include "greatest.h"
13
-#include <memory_test.h>
14
-
15
-extern rbtree_t *MEMORY_INFO;
16
-bool check_red_black_tree(rbtree_t *current, bool valid, bool strict);
17
-
18
-int *i, *j, *k;
19
-float *l, *m, *n;
20
-
21
-void integerTeardown(void *) {
22
-    free(i);
23
-    free(j);
24
-    free(k);
25
-}
26
-
27
-void floatTeardown(void *) {
28
-    free(l);
29
-    free(m);
30
-    free(n);
31
-}
32
-
33
-TEST singleInteger() {
34
-    i = new int;
35
-    ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
36
-    ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), sizeof(int));
37
-
38
-    delete i;
39
-    i = NULL;
40
-    ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
41
-    ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 0);
42
-    PASS();
43
-}
44
-
45
-TEST arrayInteger() {
46
-    i = new int[3];
47
-    ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
48
-    ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 3 * sizeof(int));
49
-
50
-    delete [] i;
51
-    i = NULL;
52
-    ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
53
-    ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 0);
54
-    PASS();
55
-}
56
-
57
-TEST arrayCombinedInteger() {
58
-    i = new int[3];
59
-    j = new int;
60
-    k = new int[3];
61
-    ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
62
-    ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 7 * sizeof(int));
63
-
64
-    delete [] i;
65
-    delete j;
66
-    delete [] k;
67
-    i = NULL;
68
-    j = NULL;
69
-    k = NULL;
70
-    ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
71
-    ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 0);
72
-    PASS();
73
-}
74
-
75
-SUITE(integerSuite) {
76
-    SET_TEARDOWN(integerTeardown, NULL);
77
-    RUN_TEST(singleInteger);
78
-    RUN_TEST(arrayInteger);
79
-    RUN_TEST(arrayCombinedInteger);
80
-}
81
-
82
-TEST singleFloat() {
83
-    l = new float;
84
-    ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
85
-    ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), sizeof(float));
86
-
87
-    delete l;
88
-    l = NULL;
89
-    ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
90
-    ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 0);
91
-    PASS();
92
-}
93
-
94
-TEST arrayFloat() {
95
-    l = new float[3];
96
-    ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
97
-    ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 3 * sizeof(float));
98
-
99
-    delete [] l;
100
-    l = NULL;
101
-    ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
102
-    ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 0);
103
-    PASS();
104
-}
105
-
106
-TEST arrayCombinedFloat() {
107
-    l = new float[3];
108
-    m = new float;
109
-    n = new float[3];
110
-    ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
111
-    ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 7 * sizeof(float));
112
-
113
-    delete [] l;
114
-    delete m;
115
-    delete [] n;
116
-    l = NULL;
117
-    m = NULL;
118
-    n = NULL;
119
-    ASSERTm("No valid red-black tree!", check_red_black_tree(MEMORY_INFO, true, true));
120
-    ASSERT_EQm("Memory-Tracking faulty!", memory_used(MEMORY_USED_BY_PROGRAM), 0);
121
-    PASS();
122
-}
123
-
124
-SUITE(floatSuite) {
125
-    SET_TEARDOWN(floatTeardown, NULL);
126
-    RUN_TEST(singleFloat);
127
-    RUN_TEST(arrayFloat);
128
-    RUN_TEST(arrayCombinedFloat);
129
-}
130
-
131
-GREATEST_MAIN_DEFS();
132
-
133
-int main(int argc, char *argv[]) {
134
-    GREATEST_MAIN_BEGIN();
135
-    RUN_SUITE(integerSuite);
136
-    RUN_SUITE(floatSuite);
137
-    GREATEST_MAIN_END();
138
-}
139
-

Chargement…
Annuler
Enregistrer