- Updated Coding Standards and adjusted code to fit.
- Restructured test for organization purposes
This commit is contained in:
@@ -12,6 +12,7 @@ add_executable(fennec-test main.cpp
|
||||
tests/test_memory.h
|
||||
tests/test_math.h
|
||||
tests/test_lang.h
|
||||
tests/lang/conditional_types.h
|
||||
)
|
||||
|
||||
target_link_libraries(fennec-test PRIVATE
|
||||
|
||||
@@ -18,51 +18,23 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "tests/test_scalar.h"
|
||||
#include "tests/test_vector.h"
|
||||
#include "tests/test_geometric.h"
|
||||
#include "tests/math/test_matrix.h"
|
||||
#include "test.h"
|
||||
|
||||
#include <fennec/memory/bits.h>
|
||||
#include "tests/test_lang.h"
|
||||
#include "tests/test_math.h"
|
||||
#include "tests/test_memory.h"
|
||||
|
||||
|
||||
int main(int, char **)
|
||||
{
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_section("fennec-test, a program to execute unit tests for fennec");
|
||||
fennec_test_header("fennec-test, a program to execute unit tests for fennec");
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
fennec_test_section(scalar tests =================================================================================);
|
||||
|
||||
fennec_test_header("math library");
|
||||
fennec_test_spacer(2);
|
||||
|
||||
fennec::test::fennec_test_scalar();
|
||||
|
||||
fennec::test::fennec_test_math();
|
||||
fennec_test_spacer(3);
|
||||
|
||||
fennec_test_section(vector tests =================================================================================);
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
fennec::test::fennec_test_vector();
|
||||
|
||||
fennec_test_spacer(3);
|
||||
|
||||
fennec_test_section(geometric tests ==============================================================================);
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
fennec::test::fennec_test_geometric();
|
||||
|
||||
fennec_test_spacer(3);
|
||||
|
||||
fennec_test_section(matrix tests =================================================================================);
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
fennec::test::fennec_test_matrix();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
10
test/test.h
10
test/test.h
@@ -23,6 +23,7 @@
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
#include <fennec/lang/limits.h>
|
||||
#include <fennec/math/common.h>
|
||||
#include <fennec/math/relational.h>
|
||||
@@ -90,7 +91,14 @@ inline void __fennec_test_run(const std::string& expression, ResultT result, Res
|
||||
}
|
||||
|
||||
#define fennec_test_run(Expression, Expected) __fennec_test_run(#Expression, Expression, Expected)
|
||||
#define fennec_test_section(Section) std::cout << #Section << std::endl
|
||||
|
||||
#define fennec_test_header(Header) std::cout << std::string(80, '=') << std::endl \
|
||||
<< (Header) << std::endl \
|
||||
<< std::string(80, '=') << std::endl
|
||||
|
||||
#define fennec_test_subheader(Header) std::cout << (Header) << ' ' << std::string(80 - sizeof(Header), '=') << std::endl
|
||||
#define fennec_test_section(Section) std::cout << (Section) << ' ' << std::string(80 - sizeof(Section), '-') << std::endl
|
||||
|
||||
#define fennec_test_spacer(Count) std::cout << std::string(Count, std::cout.widen('\n'))
|
||||
|
||||
#endif // FENNEC_TEST_H
|
||||
|
||||
24
test/tests/lang/conditional_types.h
Normal file
24
test/tests/lang/conditional_types.h
Normal file
@@ -0,0 +1,24 @@
|
||||
// =====================================================================================================================
|
||||
// fennec-test, a program to execute unit tests for fennec
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef FENNEC_TEST_LANG_CONDITIONAL_TYPES_H
|
||||
#define FENNEC_TEST_LANG_CONDITIONAL_TYPES_H
|
||||
|
||||
|
||||
|
||||
#endif // FENNEC_TEST_LANG_CONDITIONAL_TYPES_H
|
||||
@@ -1,6 +1,6 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright (C) 2025 Medusa Slockbower
|
||||
// fennec-test, a program to execute unit tests for fennec
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@@ -17,8 +17,8 @@
|
||||
// =====================================================================================================================
|
||||
|
||||
|
||||
#ifndef TEST_GEOMETRIC_H
|
||||
#define TEST_GEOMETRIC_H
|
||||
#ifndef FENNEC_TEST_GEOMETRIC_H
|
||||
#define FENNEC_TEST_GEOMETRIC_H
|
||||
|
||||
#include <fennec/math/geometric.h>
|
||||
#include <fennec/math/trigonometric.h>
|
||||
@@ -31,10 +31,8 @@ namespace fennec
|
||||
namespace test
|
||||
{
|
||||
|
||||
inline void fennec_test_geometric()
|
||||
inline void fennec_test_math_geometric()
|
||||
{
|
||||
fennec_test_section(geometric functions);
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
fennec_test_run(fennec::dot(vec2(1, 2), vec2(1, 2)), 5.0f);
|
||||
@@ -77,4 +75,4 @@ inline void fennec_test_geometric()
|
||||
}
|
||||
|
||||
|
||||
#endif // TEST_GEOMETRIC_H
|
||||
#endif // FENNEC_TEST_GEOMETRIC_H
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright (C) 2025 Medusa Slockbower
|
||||
// fennec-test, a program to execute unit tests for fennec
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@@ -32,7 +32,7 @@ namespace fennec
|
||||
namespace test
|
||||
{
|
||||
|
||||
inline void fennec_test_matrix()
|
||||
inline void fennec_test_math_matrix()
|
||||
{
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright (C) 2025 Medusa Slockbower
|
||||
// fennec-test, a program to execute unit tests for fennec
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@@ -17,8 +17,8 @@
|
||||
// =====================================================================================================================
|
||||
|
||||
|
||||
#ifndef TEST_SCALAR_H
|
||||
#define TEST_SCALAR_H
|
||||
#ifndef FENNEC_TEST_SCALAR_H
|
||||
#define FENNEC_TEST_SCALAR_H
|
||||
|
||||
#include <fennec/math/vector_traits.h>
|
||||
|
||||
@@ -30,9 +30,9 @@ namespace fennec
|
||||
namespace test
|
||||
{
|
||||
|
||||
inline void fennec_test_scalar()
|
||||
inline void fennec_test_math_scalar()
|
||||
{
|
||||
fennec_test_section(component_count);
|
||||
fennec_test_section("component_count");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
@@ -71,4 +71,4 @@ inline void fennec_test_scalar()
|
||||
|
||||
}
|
||||
|
||||
#endif //TEST_SCALAR_H
|
||||
#endif // FENNEC_TEST_SCALAR_H
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// fennec-test, a program to execute unit tests for fennec
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
@@ -17,8 +17,8 @@
|
||||
// =====================================================================================================================
|
||||
|
||||
|
||||
#ifndef TEST_VECTOR_H
|
||||
#define TEST_VECTOR_H
|
||||
#ifndef FENNEC_TEST_VECTOR_H
|
||||
#define FENNEC_TEST_VECTOR_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace fennec
|
||||
namespace test
|
||||
{
|
||||
|
||||
inline void fennec_test_vector()
|
||||
inline void fennec_test_math_vector()
|
||||
{
|
||||
fennec_test_section(component_count);
|
||||
fennec_test_section("component_count");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
@@ -146,7 +146,7 @@ inline void fennec_test_vector()
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
fennec_test_section(vec2 constructors);
|
||||
fennec_test_section("vec2 constructors");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
@@ -161,7 +161,7 @@ inline void fennec_test_vector()
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
fennec_test_section(vec2 swizzles);
|
||||
fennec_test_section("vec2 swizzles");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
@@ -172,7 +172,7 @@ inline void fennec_test_vector()
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
fennec_test_section(vec3 constructors);
|
||||
fennec_test_section("vec3 constructors");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
@@ -187,7 +187,7 @@ inline void fennec_test_vector()
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
fennec_test_section(vec3 swizzles);
|
||||
fennec_test_section("vec3 swizzles");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
@@ -233,7 +233,7 @@ inline void fennec_test_vector()
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
fennec_test_section(scalar-vector operations);
|
||||
fennec_test_section("scalar-vector operations");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
@@ -249,7 +249,7 @@ inline void fennec_test_vector()
|
||||
|
||||
fennec_test_spacer(2);
|
||||
|
||||
fennec_test_section(vector-vector operations);
|
||||
fennec_test_section("vector-vector operations");
|
||||
|
||||
fennec_test_spacer(1);
|
||||
|
||||
@@ -288,4 +288,4 @@ inline void fennec_test_vector()
|
||||
|
||||
}
|
||||
|
||||
#endif //TEST_VECTOR_H
|
||||
#endif // FENNEC_TEST_VECTOR_H
|
||||
|
||||
@@ -1,8 +1,22 @@
|
||||
// =====================================================================================================================
|
||||
// fennec-test, a program to execute unit tests for fennec
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// Created by medusa on 6/8/25.
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef TEST_LANG_H
|
||||
#define TEST_LANG_H
|
||||
#ifndef FENNEC_TEST_LANG_H
|
||||
#define FENNEC_TEST_LANG_H
|
||||
|
||||
#endif //TEST_LANG_H
|
||||
#endif // FENNEC_TEST_LANG_H
|
||||
|
||||
@@ -1,8 +1,62 @@
|
||||
// =====================================================================================================================
|
||||
// fennec-test, a program to execute unit tests for fennec
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// Created by medusa on 6/8/25.
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef TEST_MATH_H
|
||||
#define TEST_MATH_H
|
||||
#ifndef FENNEC_TEST_MATH_H
|
||||
#define FENNEC_TEST_MATH_H
|
||||
|
||||
#endif //TEST_MATH_H
|
||||
#include "math/test_scalar.h"
|
||||
#include "math/test_vector.h"
|
||||
#include "math/test_matrix.h"
|
||||
#include "math/test_geometric.h"
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
namespace test
|
||||
{
|
||||
|
||||
inline void fennec_test_math()
|
||||
{
|
||||
|
||||
fennec_test_subheader("scalar tests");
|
||||
fennec_test_spacer(2);
|
||||
fennec_test_math_scalar();
|
||||
fennec_test_spacer(3);
|
||||
|
||||
fennec_test_subheader("vector tests");
|
||||
fennec_test_spacer(2);
|
||||
fennec_test_math_vector();
|
||||
fennec_test_spacer(3);
|
||||
|
||||
fennec_test_subheader("matrix tests");
|
||||
fennec_test_spacer(2);
|
||||
fennec_test_math_matrix();
|
||||
fennec_test_spacer(3);
|
||||
|
||||
|
||||
fennec_test_subheader("geometric tests");
|
||||
fennec_test_spacer(2);
|
||||
fennec_test_math_geometric();
|
||||
fennec_test_spacer(3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // FENNEC_TEST_MATH_H
|
||||
|
||||
@@ -1,8 +1,22 @@
|
||||
// =====================================================================================================================
|
||||
// fennec-test, a program to execute unit tests for fennec
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// Created by medusa on 6/8/25.
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#ifndef TEST_MEMORY_H
|
||||
#define TEST_MEMORY_H
|
||||
#ifndef FENNEC_TEST_MEMORY_H
|
||||
#define FENNEC_TEST_MEMORY_H
|
||||
|
||||
#endif //TEST_MEMORY_H
|
||||
#endif // FENNEC_TEST_MEMORY_H
|
||||
|
||||
Reference in New Issue
Block a user