Browse Source

Explicit test template instantiation for coverage

Kajetan Johannes Hammerle 2 months ago
parent
commit
85c099b58f

+ 6 - 2
include/core/math/Vector.hpp

@@ -137,11 +137,15 @@ namespace Core {
         }
 
         float length() const {
-            return Math::squareRoot(squareLength());
+            return Math::squareRoot(static_cast<float>(squareLength()));
         }
 
         Vector& normalize() {
-            *this *= 1.0f / length();
+            if constexpr(Core::IsSame<float, T> || Core::IsSame<double, T>) {
+                *this *= 1.0f / length();
+            } else {
+                *this /= static_cast<T>(length());
+            }
             return *this;
         }
 

+ 1 - 0
test/modules/ArrayListTests.cpp

@@ -1,6 +1,7 @@
 #include "../Tests.hpp"
 #include "core/data/ArrayList.hpp"
 
+template class Core::ArrayList<int, 20>;
 using IntList = Core::ArrayList<int, 20>;
 
 static void testAdd() {

+ 3 - 0
test/modules/ArrayStringTests.cpp

@@ -2,6 +2,9 @@
 #include "core/data/HashMap.hpp"
 #include "core/utils/ArrayString.hpp"
 
+template class Core::ArrayString<128, char>;
+template class Core::ArrayString<128, char32_t>;
+
 using String8 = Core::String8<128>;
 using String32 = Core::String32<128>;
 

+ 2 - 0
test/modules/BufferedValueTests.cpp

@@ -2,6 +2,8 @@
 #include "core/math/BufferedValue.hpp"
 #include "core/math/Vector.hpp"
 
+template class Core::BufferedValue<Core::Vector2>;
+
 const float eps = 0.0001f;
 
 static void testInit() {

+ 5 - 0
test/modules/ColorTests.cpp

@@ -1,6 +1,11 @@
 #include "../Tests.hpp"
 #include "core/utils/Color.hpp"
 
+template class Core::Color<1>;
+template class Core::Color<2>;
+template class Core::Color<3>;
+template class Core::Color<4>;
+
 const float eps = 0.0001f;
 
 static void testColor1() {

+ 2 - 0
test/modules/ComponentsTests.cpp

@@ -1,6 +1,8 @@
 #include "../Tests.hpp"
 #include "core/data/Components.hpp"
 
+template class Core::Components<int>;
+
 using IntComponent = Core::Components<int>;
 
 static void testAddForEach() {

+ 1 - 0
test/modules/HashMapTests.cpp

@@ -1,6 +1,7 @@
 #include "../Tests.hpp"
 #include "core/data/HashMap.hpp"
 
+template class Core::HashMap<int, int>;
 using IntMap = Core::HashMap<int, int>;
 
 static void testAdd() {

+ 3 - 2
test/modules/LinkedListTests.cpp

@@ -1,6 +1,9 @@
 #include "../Tests.hpp"
 #include "core/data/LinkedList.hpp"
 
+template class Core::LinkedList<int>;
+using IntList = Core::LinkedList<int>;
+
 struct LinkedListTester final {
     int a;
     LinkedListTester(int a_) : a(a_) {
@@ -11,8 +14,6 @@ struct LinkedListTester final {
     LinkedListTester& operator=(LinkedListTester&&) = delete;
 };
 
-using IntList = Core::LinkedList<int>;
-
 static void testWithoutCopyOrMove() {
     Core::LinkedList<LinkedListTester> list;
     CORE_TEST_ERROR(list.add(3));

+ 1 - 0
test/modules/ListTests.cpp

@@ -1,6 +1,7 @@
 #include "../Tests.hpp"
 #include "core/data/List.hpp"
 
+template class Core::List<int>;
 using IntList = Core::List<int>;
 
 static void testAdd() {

+ 1 - 0
test/modules/MatrixStackTests.cpp

@@ -1,6 +1,7 @@
 #include "../Tests.hpp"
 #include "core/math/MatrixStack.hpp"
 
+template class Core::MatrixStack<5>;
 using Matrices = Core::MatrixStack<5>;
 
 static void testInit() {

+ 1 - 0
test/modules/ProbingHashMapTests.cpp

@@ -3,6 +3,7 @@
 #include "../Tests.hpp"
 #include "core/data/ProbingHashMap.hpp"
 
+template class Core::ProbingHashMap<int, int>;
 using IntMap = Core::ProbingHashMap<int, int>;
 
 static void testAdd() {

+ 2 - 0
test/modules/RingBufferTests.cpp

@@ -1,6 +1,8 @@
 #include "../Tests.hpp"
 #include "core/data/RingBuffer.hpp"
 
+template class Core::RingBuffer<int, 5>;
+
 struct Tester final {
     static int ids;
     static int sum;

+ 3 - 0
test/modules/StackTests.cpp

@@ -1,6 +1,9 @@
 #include "../Tests.hpp"
 #include "core/data/Stack.hpp"
 
+template class Core::Internal::BaseStack<int, Core::List<int>>;
+template class Core::Internal::BaseStack<int, Core::ArrayList<int, 100>>;
+
 template<typename T>
 static void testPushPopPeek() {
     T stack;

+ 2 - 0
test/modules/UniquePointerTests.cpp

@@ -15,6 +15,8 @@ struct B final {
 
 int B::instances = 0;
 
+template class Core::UniquePointer<B>;
+
 static void testDestroy() {
     {
         Core::UniquePointer<B> p(new B());

+ 7 - 0
test/modules/VectorTests.cpp

@@ -6,6 +6,13 @@ const float eps = 0.0001f;
 using V3 = Core::Vector3;
 using I3 = Core::IntVector3;
 
+template class Core::Vector<4, float>;
+template class Core::Vector<4, int>;
+template class Core::Vector<3, float>;
+template class Core::Vector<3, int>;
+template class Core::Vector<2, float>;
+template class Core::Vector<2, int>;
+
 static void testInitAndRead() {
     V3 v1;
     Core::Vector2 v2(1.0f, 2.0f);