Thomas Buck 11 роки тому
джерело
коміт
0d5ed28659
5 змінених файлів з 42 додано та 41 видалено
  1. 2
    0
      README.md
  2. 8
    10
      include/MatMath.h
  3. 0
    16
      src/MatMath.cpp
  4. 12
    2
      test/greatest.h
  5. 20
    13
      test/mtk_tga.cpp

+ 2
- 0
README.md Переглянути файл

@@ -77,6 +77,8 @@ The included example Font, [Droid Sans Mono](http://www.droidfonts.com/licensing
77 77
 
78 78
 The included sample WAV file is made from the [Falling Mate ringtone](http://brechler-web.de/fallingmate/) by [Plaetzchen](http://plaetzchen.cc).
79 79
 
80
+The included Unit Test Framework [greatest](https://github.com/silentbicycle/greatest/) by Scott Vokes is licensed under the [ISC License](http://www.isc.org/downloads/software-support-policy/isc-license/).
81
+
80 82
 OpenRaider is based on code, specs, and alogrithms from:
81 83
 
82 84
 + GooseEgg/Freyja 3d Modelers by Mongoose

+ 8
- 10
include/MatMath.h Переглянути файл

@@ -1,19 +1,19 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Freyja
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
7 7
  * Email   : stu7440@westga.edu
8
- * Object  : 
8
+ * Object  :
9 9
  * License : No use w/o permission (C) 2002 Mongoose
10
- * Comments: 
10
+ * Comments:
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------ 
15
+ *
16
+ *-- History ------------------------------------------------
17 17
  *
18 18
  * 2002.05.11:
19 19
  * Mongoose - Created
@@ -83,7 +83,7 @@ vec_t helDistToBboxFromPlane3v(vec3_t min, vec3_t max, vec4_t plane);
83 83
 
84 84
 vec_t helDist3v(vec3_t a, vec3_t b);
85 85
 /*------------------------------------------------------
86
- * Pre  : Given point A and B 
86
+ * Pre  : Given point A and B
87 87
  * Post : Returns length of line segment
88 88
  *
89 89
  *-- History ------------------------------------------
@@ -94,7 +94,7 @@ vec_t helDist3v(vec3_t a, vec3_t b);
94 94
 
95 95
 void helMidpoint3v(vec3_t a, vec3_t b, vec3_t mid);
96 96
 /*------------------------------------------------------
97
- * Pre  : Given point A and B 
97
+ * Pre  : Given point A and B
98 98
  * Post : Returns midpoint of line segment
99 99
  *
100 100
  *-- History ------------------------------------------
@@ -128,6 +128,4 @@ vec_t helRadToDeg(vec_t rad);
128 128
 
129 129
 vec_t helRandomNum(vec_t from, vec_t to);
130 130
 
131
-/* Some cruft for ye olde mtk3d compatibility */
132
-void helVectorMatrixMult4dv(double v[4], matrix_t m, double result[4]);
133 131
 #endif

+ 0
- 16
src/MatMath.cpp Переглянути файл

@@ -9,22 +9,6 @@
9 9
 
10 10
 #define COMPUTE
11 11
 
12
-void helVectorMatrixMult4dv(double v[4], matrix_t m, double result[4])
13
-{
14
-	/* Column major */
15
-	result[0] = m[ 0] * v[0] + m[ 4] * v[1] + m[ 8] * v[2] + m[12] * v[3];
16
-	result[1] = m[ 1] * v[0] + m[ 5] * v[1] + m[ 9] * v[2] + m[13] * v[3];
17
-	result[2] = m[ 2] * v[0] + m[ 6] * v[1] + m[10] * v[2] + m[14] * v[3];
18
-	result[3] = m[ 3] * v[0] + m[ 7] * v[1] + m[11] * v[2] + m[15] * v[3];
19
-
20
-	/* Row major */
21
-   //result[0] = m[ 0] * v[0] + m[ 1] * v[1] + m[ 2] * v[2] + m[ 3] * v[3];
22
-	//result[1] = m[ 4] * v[0] + m[ 5] * v[1] + m[ 6] * v[2] + m[ 7] * v[3];
23
-	//result[2] = m[ 8] * v[0] + m[ 9] * v[1] + m[10] * v[2] + m[11] * v[3];
24
-	//result[3] = m[12] * v[0] + m[13] * v[1] + m[14] * v[2] + m[15] * v[3];
25
-}
26
-
27
-
28 12
 bool tmpHelSphereIntersectLine(Vector3d pos, Vector3d lastPos,
29 13
 										 Vector3d center, vec_t radius)
30 14
 {

+ 12
- 2
test/greatest.h Переглянути файл

@@ -17,6 +17,12 @@
17 17
 #ifndef GREATEST_H
18 18
 #define GREATEST_H
19 19
 
20
+#ifdef __cplusplus
21
+#define __STDC_VERSION__ 19901L
22
+extern "C"
23
+{
24
+#endif
25
+
20 26
 #define GREATEST_VERSION_MAJOR 0
21 27
 #define GREATEST_VERSION_MINOR 9
22 28
 #define GREATEST_VERSION_PATCH 3
@@ -295,13 +301,13 @@ void GREATEST_SET_TEARDOWN_CB(greatest_teardown_cb *cb, void *udata);
295 301
         }                                                               \
296 302
         greatest_info.msg = NULL;                                       \
297 303
     } while (0)
298
-        
304
+
299 305
 #define GREATEST_PASSm(MSG)                                             \
300 306
     do {                                                                \
301 307
         greatest_info.msg = MSG;                                        \
302 308
         return 0;                                                       \
303 309
     } while (0)
304
-        
310
+
305 311
 #define GREATEST_FAILm(MSG)                                             \
306 312
     do {                                                                \
307 313
         greatest_info.fail_file = __FILE__;                             \
@@ -588,4 +594,8 @@ greatest_run_info greatest_info
588 594
 #define RUN_TESTp      GREATEST_RUN_TESTp
589 595
 #endif /* USE_ABBREVS */
590 596
 
597
+#ifdef __cplusplus
598
+}
599
+#endif
600
+
591 601
 #endif

+ 20
- 13
test/mtk_tga.cpp Переглянути файл

@@ -6,35 +6,42 @@
6 6
  */
7 7
 #include <stdio.h>
8 8
 #include <stdlib.h>
9
-
10 9
 #include <mtk_tga.h>
11
-
12 10
 #include "greatest.h"
13 11
 
14
-#define TESTFILE "data/font-0.tga"
15
-FILE *f = NULL;
16
-
17
-TEST checkFile() {
18
-    ASSERTm("File wasn't opened. Please run the suite!", f != NULL);
12
+//! \todo generate list?
13
+const char *testFiles[] = {
14
+    "data/font-0.tga",
15
+    "data/particle.tga",
16
+    "data/snow.tga",
17
+    "data/snow2.tga",
18
+    "data/splash.tga",
19
+    "data/white.tga"
20
+};
21
+
22
+TEST checkFile(FILE *f) {
23
+    ASSERTm("File wasn't opened.", f != NULL);
19 24
     ASSERT_FALSEm("File is invalid?!", mtk_image__tga_check(f));
20 25
     PASS();
21 26
 }
22 27
 
23
-TEST loadFile() {
28
+TEST loadFile(FILE *f) {
24 29
     unsigned char *image;
25 30
     unsigned int width, height;
26 31
     char type;
27
-    ASSERTm("File wasn't opened. Please run the suite!", f != NULL);
32
+    ASSERTm("File wasn't opened.", f != NULL);
28 33
     ASSERT_FALSEm("File couldn't be loaded!", mtk_image__tga_load(f, &image, &width, &height, &type));
29 34
     printf("\nWidth: %u\nHeight: %u\nType: %d\n", width, height, type);
30 35
     PASS();
31 36
 }
32 37
 
33 38
 SUITE(tgaSuite) {
34
-    f = fopen(TESTFILE, "r");
35
-    RUN_TEST(checkFile);
36
-    RUN_TEST(loadFile);
37
-    fclose(f);
39
+    for (int i = 0; i < (sizeof(testFiles) / sizeof(testFiles[0])); i++) {
40
+        FILE *f = fopen(testFiles[i], "r");
41
+        RUN_TESTp(checkFile, f);
42
+        RUN_TESTp(loadFile, f);
43
+        fclose(f);
44
+    }
38 45
 }
39 46
 
40 47
 GREATEST_MAIN_DEFS();

Завантаження…
Відмінити
Зберегти