Thomas Buck 11 years ago
parent
commit
0d5ed28659
5 changed files with 42 additions and 41 deletions
  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 View File

77
 
77
 
78
 The included sample WAV file is made from the [Falling Mate ringtone](http://brechler-web.de/fallingmate/) by [Plaetzchen](http://plaetzchen.cc).
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
 OpenRaider is based on code, specs, and alogrithms from:
82
 OpenRaider is based on code, specs, and alogrithms from:
81
 
83
 
82
 + GooseEgg/Freyja 3d Modelers by Mongoose
84
 + GooseEgg/Freyja 3d Modelers by Mongoose

+ 8
- 10
include/MatMath.h View File

1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2
 /*================================================================
2
 /*================================================================
3
- * 
3
+ *
4
  * Project : Freyja
4
  * Project : Freyja
5
  * Author  : Terry 'Mongoose' Hendrix II
5
  * Author  : Terry 'Mongoose' Hendrix II
6
  * Website : http://www.westga.edu/~stu7440/
6
  * Website : http://www.westga.edu/~stu7440/
7
  * Email   : stu7440@westga.edu
7
  * Email   : stu7440@westga.edu
8
- * Object  : 
8
+ * Object  :
9
  * License : No use w/o permission (C) 2002 Mongoose
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
  *           template generator script.  <stu7440@westga.edu>
14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------ 
15
+ *
16
+ *-- History ------------------------------------------------
17
  *
17
  *
18
  * 2002.05.11:
18
  * 2002.05.11:
19
  * Mongoose - Created
19
  * Mongoose - Created
83
 
83
 
84
 vec_t helDist3v(vec3_t a, vec3_t b);
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
  * Post : Returns length of line segment
87
  * Post : Returns length of line segment
88
  *
88
  *
89
  *-- History ------------------------------------------
89
  *-- History ------------------------------------------
94
 
94
 
95
 void helMidpoint3v(vec3_t a, vec3_t b, vec3_t mid);
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
  * Post : Returns midpoint of line segment
98
  * Post : Returns midpoint of line segment
99
  *
99
  *
100
  *-- History ------------------------------------------
100
  *-- History ------------------------------------------
128
 
128
 
129
 vec_t helRandomNum(vec_t from, vec_t to);
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
 #endif
131
 #endif

+ 0
- 16
src/MatMath.cpp View File

9
 
9
 
10
 #define COMPUTE
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
 bool tmpHelSphereIntersectLine(Vector3d pos, Vector3d lastPos,
12
 bool tmpHelSphereIntersectLine(Vector3d pos, Vector3d lastPos,
29
 										 Vector3d center, vec_t radius)
13
 										 Vector3d center, vec_t radius)
30
 {
14
 {

+ 12
- 2
test/greatest.h View File

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

+ 20
- 13
test/mtk_tga.cpp View File

6
  */
6
  */
7
 #include <stdio.h>
7
 #include <stdio.h>
8
 #include <stdlib.h>
8
 #include <stdlib.h>
9
-
10
 #include <mtk_tga.h>
9
 #include <mtk_tga.h>
11
-
12
 #include "greatest.h"
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
     ASSERT_FALSEm("File is invalid?!", mtk_image__tga_check(f));
24
     ASSERT_FALSEm("File is invalid?!", mtk_image__tga_check(f));
20
     PASS();
25
     PASS();
21
 }
26
 }
22
 
27
 
23
-TEST loadFile() {
28
+TEST loadFile(FILE *f) {
24
     unsigned char *image;
29
     unsigned char *image;
25
     unsigned int width, height;
30
     unsigned int width, height;
26
     char type;
31
     char type;
27
-    ASSERTm("File wasn't opened. Please run the suite!", f != NULL);
32
+    ASSERTm("File wasn't opened.", f != NULL);
28
     ASSERT_FALSEm("File couldn't be loaded!", mtk_image__tga_load(f, &image, &width, &height, &type));
33
     ASSERT_FALSEm("File couldn't be loaded!", mtk_image__tga_load(f, &image, &width, &height, &type));
29
     printf("\nWidth: %u\nHeight: %u\nType: %d\n", width, height, type);
34
     printf("\nWidth: %u\nHeight: %u\nType: %d\n", width, height, type);
30
     PASS();
35
     PASS();
31
 }
36
 }
32
 
37
 
33
 SUITE(tgaSuite) {
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
 GREATEST_MAIN_DEFS();
47
 GREATEST_MAIN_DEFS();

Loading…
Cancel
Save