tests: run tests on windows

This commit is contained in:
Recep Aslantas
2019-09-13 09:40:18 +03:00
parent 80c2b3712d
commit 5aa047efdf
8 changed files with 50 additions and 31 deletions

View File

@@ -78,4 +78,14 @@ typedef struct test_entry_t {
test_status_t test_ ## FUN (void); \
test_status_t test_ ## FUN()
#if defined(_WIN32)
# define srand48(x) srand((int)(x))
# define drand48() ((float)(rand() / RAND_MAX))
# define OK_TEXT "ok:"
# define FAIL_TEXT "fail:"
#else
# define OK_TEXT "✔︎"
# define FAIL_TEXT "𐄂"
#endif
#endif /* common_h */

View File

@@ -32,7 +32,7 @@ main(int argc, const char * argv[]) {
if (!st.status) {
fprintf(stderr,
BOLDRED " 𐄂" BOLDWHITE " %s " RESET,
BOLDRED " " FAIL_TEXT BOLDWHITE " %s " RESET,
entry->name);
if (st.msg) {
fprintf(stderr,
@@ -44,7 +44,7 @@ main(int argc, const char * argv[]) {
failed++;
} else {
fprintf(stderr, GREEN " ✔︎" RESET " %s - " , entry->name);
fprintf(stderr, GREEN " " OK_TEXT RESET " %s - " , entry->name);
if (elapsed > 0.01)
fprintf(stderr, YELLOW "%.2f", elapsed);

View File

@@ -41,10 +41,10 @@ TEST_IMPL(camera_decomp) {
glm_persp_sizes(proj, fovy, sizes);
glm_frustum(-sizes[0] * 0.5,
sizes[0] * 0.5,
-sizes[1] * 0.5,
sizes[1] * 0.5,
glm_frustum(-sizes[0] * 0.5f,
sizes[0] * 0.5f,
-sizes[1] * 0.5f,
sizes[1] * 0.5f,
nearVal,
farVal,
proj2);

View File

@@ -8,8 +8,8 @@
#include "test_common.h"
TEST_IMPL(clamp) {
vec3 v3 = {15.07, 0.4, 17.3};
vec4 v4 = {5.07, 2.3, 1.3, 1.4};
vec3 v3 = {15.07f, 0.4f, 17.3f};
vec4 v4 = {5.07f, 2.3f, 1.3f, 1.4f};
ASSERT(glm_clamp(1.6f, 0.0f, 1.0f) == 1.0f)
ASSERT(glm_clamp(-1.6f, 0.0f, 1.0f) == 0.0f)

View File

@@ -27,7 +27,7 @@ TEST_IMPL(quat) {
ASSERT(glm_eq(glm_quat_real(q4), cosf(glm_rad(0.0f) * 0.5f)))
glm_quat_mat4(q4, rot1);
ASSERT(test_assert_mat4_eq2(rot1, GLM_MAT4_IDENTITY, 0.000009).status == 1)
ASSERT(test_assert_mat4_eq2(rot1, GLM_MAT4_IDENTITY, 0.000009f).status == 1)
/* 1. test quat to mat and mat to quat */
for (i = 0; i < 1000; i++) {
@@ -42,7 +42,7 @@ TEST_IMPL(quat) {
/* 3. test first rot and second rotation */
/* almost equal */
ASSERT(test_assert_mat4_eq2(inRot, outRot, 0.000009).status == 1);
ASSERT(test_assert_mat4_eq2(inRot, outRot, 0.000009f).status == 1);
/* 4. test SSE mul and raw mul */
#if defined( __SSE__ ) || defined( __SSE2__ )
@@ -62,7 +62,7 @@ TEST_IMPL(quat) {
/* create view matrix with quaternion */
glm_quat_look(eye, q3, view2);
ASSERT(test_assert_mat4_eq2(view1, view2, 0.000009).status == 1);
ASSERT(test_assert_mat4_eq2(view1, view2, 0.000009f).status == 1);
/* 6. test quaternion rotation matrix result */
test_rand_quat(q3);
@@ -72,7 +72,7 @@ TEST_IMPL(quat) {
glm_quat_axis(q3, axis);
glm_rotate_make(rot2, glm_quat_angle(q3), axis);
ASSERT(test_assert_mat4_eq2(rot1, rot2, 0.000009).status == 1);
ASSERT(test_assert_mat4_eq2(rot1, rot2, 0.000009f).status == 1);
/* 7. test quaternion multiplication (hamilton product),
final rotation = first rotation + second = quat1 * quat2
@@ -92,7 +92,7 @@ TEST_IMPL(quat) {
glm_quat_mat4(q5, rot2);
/* result must be same (almost) */
ASSERT(test_assert_mat4_eq2(rot1, rot2, 0.000009).status == 1)
ASSERT(test_assert_mat4_eq2(rot1, rot2, 0.000009f).status == 1)
/* 8. test quaternion for look rotation */
@@ -168,7 +168,7 @@ TEST_IMPL(quat) {
glm_quat_rotate(rot2, q3, rot2);
/* result must be same (almost) */
ASSERT(test_assert_mat4_eq2(rot1, rot2, 0.000009).status == 1)
ASSERT(test_assert_mat4_eq2(rot1, rot2, 0.000009f).status == 1)
glm_rotate_make(rot1, glm_rad(-90), GLM_ZUP);
glm_translate(rot1, (vec3){-10.0, 45.0f, 8.0f});
@@ -179,7 +179,7 @@ TEST_IMPL(quat) {
glm_translate(rot2, (vec3){-10.0, 45.0f, 8.0f});
/* result must be same (almost) */
ASSERT(test_assert_mat4_eq2(rot1, rot2, 0.000009).status == 1)
ASSERT(test_assert_mat4_eq2(rot1, rot2, 0.000009f).status == 1)
/* reverse */
glm_rotate_make(rot1, glm_rad(-90), GLM_ZUP);
@@ -187,7 +187,7 @@ TEST_IMPL(quat) {
glm_quat_rotate(rot1, q3, rot1);
/* result must be identity */
ASSERT(test_assert_mat4_eq2(rot1, GLM_MAT4_IDENTITY, 0.000009).status == 1)
ASSERT(test_assert_mat4_eq2(rot1, GLM_MAT4_IDENTITY, 0.000009f).status == 1)
test_rand_quat(q3);

View File

@@ -98,9 +98,9 @@ TEST_IMPL(vec4) {
test_rand_vec4(v2);
d1 = glm_vec4_distance(v1, v2);
d2 = sqrtf(powf(v1[0] - v2[0], 2.0f)
+ pow(v1[1] - v2[1], 2.0f)
+ pow(v1[2] - v2[2], 2.0f)
+ pow(v1[3] - v2[3], 2.0f));
+ powf(v1[1] - v2[1], 2.0f)
+ powf(v1[2] - v2[2], 2.0f)
+ powf(v1[3] - v2[3], 2.0f));
ASSERT(fabsf(d1 - d2) <= 0.000009)
}
@@ -129,18 +129,18 @@ TEST_IMPL(vec4) {
glm_vec4_div(v, v1, v);
ASSERT(glmc_vec4_eq_eps(v, 5))
glm_vec4_divs(v, 0.5, v);
glm_vec4_divs(v, 0.5f, v);
ASSERT(glmc_vec4_eq_eps(v, 10))
glm_vec4_mul(v, v1, v);
ASSERT(glmc_vec4_eq_eps(v, 20))
glm_vec4_scale(v, 0.5, v);
glm_vec4_scale(v, 0.5f, v);
ASSERT(glmc_vec4_eq_eps(v, 10))
glm_vec4_normalize_to(v, v1);
glm_vec4_scale(v1, 0.8, v1);
glm_vec4_scale_as(v, 0.8, v);
glm_vec4_scale(v1, 0.8f, v1);
glm_vec4_scale_as(v, 0.8f, v);
ASSERT(test_assert_vec4_eq(v1, v).status == 1)
/* addadd, subadd, muladd */
@@ -170,8 +170,8 @@ TEST_IMPL(vec4) {
ASSERT(test_assert_vec4_eq(v3, v4).status == 1)
/* clamp */
glm_vec4_clamp(v3, 0.1, 0.8);
test_vec4_clamp(v4, 0.1, 0.8);
glm_vec4_clamp(v3, 0.1f, 0.8f);
test_vec4_clamp(v4, 0.1f, 0.8f);
ASSERT(test_assert_vec4_eq(v3, v4).status == 1)
ASSERT(v3[0] >= 0.0999 && v3[0] <= 0.80001) /* rounding erros */

View File

@@ -1,10 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.7
# Visual Studio Version 16
VisualStudioVersion = 16.0.29123.88
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cglm", "cglm.vcxproj", "{CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cglm-test", "cglm-test.vcxproj", "{200E0DF1-7532-44E6-8273-84FB92C5557E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -21,8 +23,19 @@ Global
{CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Release|x64.Build.0 = Release|x64
{CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Release|x86.ActiveCfg = Release|Win32
{CA8BCAF9-CD25-4133-8F62-3D1449B5D2FC}.Release|x86.Build.0 = Release|Win32
{200E0DF1-7532-44E6-8273-84FB92C5557E}.Debug|x64.ActiveCfg = Debug|x64
{200E0DF1-7532-44E6-8273-84FB92C5557E}.Debug|x64.Build.0 = Debug|x64
{200E0DF1-7532-44E6-8273-84FB92C5557E}.Debug|x86.ActiveCfg = Debug|Win32
{200E0DF1-7532-44E6-8273-84FB92C5557E}.Debug|x86.Build.0 = Debug|Win32
{200E0DF1-7532-44E6-8273-84FB92C5557E}.Release|x64.ActiveCfg = Release|x64
{200E0DF1-7532-44E6-8273-84FB92C5557E}.Release|x64.Build.0 = Release|x64
{200E0DF1-7532-44E6-8273-84FB92C5557E}.Release|x86.ActiveCfg = Release|Win32
{200E0DF1-7532-44E6-8273-84FB92C5557E}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2AEF23C9-433B-428B-BEBC-068BF3AC9A65}
EndGlobalSection
EndGlobal

View File

@@ -5,10 +5,6 @@
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="src">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>