Skip to content

Commit e3460ab

Browse files
committed
Now using common testing library
1 parent ece7918 commit e3460ab

File tree

9 files changed

+60
-117
lines changed

9 files changed

+60
-117
lines changed

CMakeLists.txt

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,12 @@ project(LangulusMath
55
HOMEPAGE_URL https://langulus.com
66
)
77

8-
# Check if this project is built as standalone, or a part of something else
8+
# Check if this project is built as standalone, or a part of something else
99
if(PROJECT_IS_TOP_LEVEL OR NOT LANGULUS)
1010
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
1111
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
12-
1312
include(LangulusUtilities.cmake)
14-
15-
# Add Langulus::Core/Logger/RTTI/SIMD/Fractalloc/Anyness/Flow libraries
16-
fetch_langulus_module(Core GIT_TAG 35756f11d2f9c475f27b094b8d4c82cd453969fc)
17-
fetch_langulus_module(Logger GIT_TAG dafbeb825071ec60d8403254143f75606151a7e6)
18-
fetch_langulus_module(RTTI GIT_TAG fc49750884ac943dff4261ac5b8dfb2c148423d7)
19-
if(LANGULUS_FEATURE_MANAGED_MEMORY)
20-
fetch_langulus_module(Fractalloc GIT_TAG 66408e8557b1bb3c80615909129342bcebd3fb9f)
21-
endif()
22-
fetch_langulus_module(SIMD GIT_TAG ead5493049e2800b4c3c02d385c0c6314efac69c)
23-
fetch_langulus_module(Anyness GIT_TAG 46a6513d6bcf3d532e9bf746b50d1299692eb96a)
24-
fetch_langulus_module(Flow GIT_TAG 06000427afccf13016738140d09850f0b8cf837b)
13+
fetch_langulus_module(Flow GIT_TAG d2167a978c03f8673e2172154cf85e8d327718b3)
2514
endif()
2615

2716
file(GLOB_RECURSE
@@ -30,7 +19,7 @@ file(GLOB_RECURSE
3019
source/*.cpp
3120
)
3221

33-
# Build and install Math library
22+
# Build and install Math library
3423
add_langulus_library(LangulusMath
3524
$<TARGET_OBJECTS:LangulusLogger>
3625
$<TARGET_OBJECTS:LangulusRTTI>
@@ -40,13 +29,14 @@ add_langulus_library(LangulusMath
4029
${LANGULUS_MATH_SOURCES}
4130
)
4231

43-
target_include_directories(LangulusMath PUBLIC include
44-
$<TARGET_PROPERTY:LangulusLogger,INTERFACE_INCLUDE_DIRECTORIES>
45-
$<TARGET_PROPERTY:LangulusRTTI,INTERFACE_INCLUDE_DIRECTORIES>
46-
$<$<BOOL:${LANGULUS_FEATURE_MANAGED_MEMORY}>:$<TARGET_PROPERTY:LangulusFractalloc,INTERFACE_INCLUDE_DIRECTORIES>>
47-
$<TARGET_PROPERTY:LangulusSIMD,INTERFACE_INCLUDE_DIRECTORIES>
48-
$<TARGET_PROPERTY:LangulusAnyness,INTERFACE_INCLUDE_DIRECTORIES>
49-
$<TARGET_PROPERTY:LangulusFlow,INTERFACE_INCLUDE_DIRECTORIES>
32+
target_include_directories(LangulusMath
33+
PUBLIC $<TARGET_PROPERTY:LangulusLogger,INTERFACE_INCLUDE_DIRECTORIES>
34+
$<TARGET_PROPERTY:LangulusRTTI,INTERFACE_INCLUDE_DIRECTORIES>
35+
$<$<BOOL:${LANGULUS_FEATURE_MANAGED_MEMORY}>:$<TARGET_PROPERTY:LangulusFractalloc,INTERFACE_INCLUDE_DIRECTORIES>>
36+
$<TARGET_PROPERTY:LangulusSIMD,INTERFACE_INCLUDE_DIRECTORIES>
37+
$<TARGET_PROPERTY:LangulusAnyness,INTERFACE_INCLUDE_DIRECTORIES>
38+
$<TARGET_PROPERTY:LangulusFlow,INTERFACE_INCLUDE_DIRECTORIES>
39+
include
5040
)
5141

5242
target_link_libraries(LangulusMath
@@ -59,6 +49,6 @@ target_compile_definitions(LangulusMath
5949
)
6050

6151
if(LANGULUS_TESTING)
62-
enable_testing()
52+
enable_testing()
6353
add_subdirectory(test)
6454
endif()

LangulusUtilities.cmake

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
include(FetchContent)
22

3+
4+
# Utility for fetching Langulus libraries using FetchContent
35
function(fetch_langulus_module NAME GIT_TAG TAG)
6+
if (LANGULUS)
7+
message(FATAL_ERROR "You can't fetch Langulus::${NAME}, because this build \
8+
indicates LANGULUS is being build along your project. The library you're \
9+
trying to fetch should already be available locally.")
10+
endif()
11+
412
if(NOT DEFINED LANGULUS_EXTERNAL_DIRECTORY)
513
set(LANGULUS_EXTERNAL_DIRECTORY "${CMAKE_SOURCE_DIR}/external" CACHE PATH
614
"Place where external dependencies will be downloaded")
7-
message(WARNING "LANGULUS_EXTERNAL_DIRECTORY not defined, using default: ${LANGULUS_EXTERNAL_DIRECTORY}")
15+
message(WARNING "LANGULUS_EXTERNAL_DIRECTORY not defined, using default: \
16+
${LANGULUS_EXTERNAL_DIRECTORY}")
817
endif()
918

10-
# Completely avoid downloading or updating anything, once the appropriate folder exists
19+
# Completely avoid downloading or updating anything, once the appropriate
20+
# folder exists
1121
string(TOUPPER ${NAME} UPPERCASE_NAME)
1222
if (EXISTS "${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src")
1323
set(FETCHCONTENT_SOURCE_DIR_LANGULUS${UPPERCASE_NAME} "${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src" CACHE INTERNAL "" FORCE)
14-
message(STATUS "Reusing external library Langulus::${NAME}... (delete ${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src manually in order to redownload)")
24+
message(STATUS "Reusing external library Langulus::${NAME}... \
25+
(delete ${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src manually in order to redownload)")
1526
else()
1627
unset(FETCHCONTENT_SOURCE_DIR_LANGULUS${UPPERCASE_NAME} CACHE)
1728
message(STATUS "Downloading external library Langulus::${NAME}...")
@@ -28,18 +39,23 @@ function(fetch_langulus_module NAME GIT_TAG TAG)
2839
FetchContent_MakeAvailable(Langulus${NAME})
2940
endfunction()
3041

42+
43+
# Utility for fetching external libraries using FetchContent
3144
function(fetch_external_module NAME GIT_REPOSITORY REPO GIT_TAG TAG)
3245
if(NOT DEFINED LANGULUS_EXTERNAL_DIRECTORY)
3346
set(LANGULUS_EXTERNAL_DIRECTORY "${CMAKE_SOURCE_DIR}/external" CACHE PATH
3447
"Place where external dependencies will be downloaded")
35-
message(WARNING "LANGULUS_EXTERNAL_DIRECTORY not defined, using default: ${LANGULUS_EXTERNAL_DIRECTORY}")
48+
message(WARNING "LANGULUS_EXTERNAL_DIRECTORY not defined, \
49+
using default: ${LANGULUS_EXTERNAL_DIRECTORY}")
3650
endif()
3751

38-
# Completely avoid downloading or updating anything, once the appropriate folder exists
52+
# Completely avoid downloading or updating anything, once the appropriate
53+
# folder exists
3954
string(TOUPPER ${NAME} UPPERCASE_NAME)
4055
if (EXISTS "${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src")
4156
set(FETCHCONTENT_SOURCE_DIR_${UPPERCASE_NAME} "${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src" CACHE INTERNAL "" FORCE)
42-
message(STATUS "Reusing external library ${NAME}... (delete ${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src manually in order to redownload)")
57+
message(STATUS "Reusing external library ${NAME}... \
58+
(delete ${LANGULUS_EXTERNAL_DIRECTORY}/${NAME}-src manually in order to redownload)")
4359
else()
4460
unset(FETCHCONTENT_SOURCE_DIR_${UPPERCASE_NAME} CACHE)
4561
message(STATUS "Downloading external library ${NAME}...")
@@ -59,4 +75,4 @@ function(fetch_external_module NAME GIT_REPOSITORY REPO GIT_TAG TAG)
5975
string(TOLOWER ${NAME} LOWERCASE_NAME)
6076
set(${NAME}_SOURCE_DIR "${${LOWERCASE_NAME}_SOURCE_DIR}" CACHE INTERNAL "${NAME} source directory")
6177
set(${NAME}_BINARY_DIR "${${LOWERCASE_NAME}_BINARY_DIR}" CACHE INTERNAL "${NAME} binary directory")
62-
endfunction()
78+
endfunction()

source/Common.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
/// SPDX-License-Identifier: GPL-3.0-or-later
77
///
88
#pragma once
9-
#include <Langulus/Core/Exceptions.hpp>
9+
#include <Langulus/Core/Except.hpp>
10+
#include <Langulus/Core/Lossless.hpp>
1011
#include <Langulus/Anyness/Trait.hpp>
11-
#include <Langulus/Flow/Code.hpp>
1212

1313
/// Make the rest of the code aware, that Langulus::Math has been included
1414
#define LANGULUS_LIBRARY_MATH() 1
@@ -171,8 +171,8 @@ namespace Langulus::CT
171171
/// Anything that doesn't have any of the above traits
172172
/// @maintenance keep this one up to date, if adding new math traits
173173
template<class...T>
174-
concept ScalarBased = Scalar<T...> and
175-
not ((QuaternionBased<T>
174+
concept ScalarBased = Scalar<T...> and not ((
175+
QuaternionBased<T>
176176
or VectorBased<T>
177177
or RangeBased<T>
178178
or MatrixBased<T>

source/Matrices/TMatrix.inl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ namespace Langulus::Math
740740

741741
const auto det = n11 * t11 + n21 * t12 + n31 * t13;
742742
if (det == 0)
743-
throw Except::DivisionByZero("Degenerate 3x3 matrix");
743+
throw Except::ZeroDivision("Degenerate 3x3 matrix");
744744

745745
const auto detInv = 1 / det;
746746

@@ -771,7 +771,7 @@ namespace Langulus::Math
771771

772772
const auto det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
773773
if (det == 0)
774-
throw Except::DivisionByZero("Degenerate 4x4 matrix");
774+
throw Except::ZeroDivision("Degenerate 4x4 matrix");
775775

776776
const auto detInv = 1 / det;
777777

@@ -901,7 +901,7 @@ namespace Langulus::A
901901
) -> Math::TMatrix<T, 4> {
902902
const auto range = far - near;
903903
if (range == 0 or width == 0 or height == 0)
904-
throw Except::DivisionByZero();
904+
throw Except::ZeroDivision();
905905

906906
auto result = Math::TMatrix<T, 4>::Null();
907907
result.mArray[ 0] = T { 2} / width;

source/Numbers/TNumber.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
///
88
#pragma once
99
#include "../Common.hpp"
10+
#include <Langulus/Flow/Code.hpp>
1011

1112

1213
namespace Langulus::Math

test/Main.cpp renamed to test/Common.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
///
66
/// SPDX-License-Identifier: GPL-3.0-or-later
77
///
8-
#include "Main.hpp"
98
#include <Langulus/Verbs/Associate.hpp>
109
#include <Langulus/Verbs/Catenate.hpp>
1110
#include <Langulus/Verbs/Conjunct.hpp>
@@ -22,7 +21,7 @@
2221
#include <Langulus/Math/Color.hpp>
2322

2423
#define CATCH_CONFIG_RUNNER
25-
#include <catch2/catch.hpp>
24+
#include "Common.hpp"
2625

2726
LANGULUS_RTTI_BOUNDARY(RTTI::MainBoundary)
2827

test/Common.hpp

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,16 @@
88

99
/// INTENTIONALLY NOT GUARDED
1010
/// Include this file once in each cpp file, after all other headers
11-
#ifdef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
12-
#error Catch has been included prior to this header
13-
#endif
14-
15-
#include "Main.hpp"
16-
#include <catch2/catch.hpp>
17-
18-
/// See https://github.com/catchorg/Catch2/blob/devel/docs/tostring.md
19-
CATCH_TRANSLATE_EXCEPTION(::Langulus::Exception const& ex) {
20-
const Text serialized {ex};
21-
return ::std::string {Token {serialized}};
22-
}
23-
24-
namespace Catch
25-
{
26-
27-
template<class T>
28-
concept StringifiableButNotRange = CT::Stringifiable<T> and not Catch::is_range<T>::value;
29-
30-
template<StringifiableButNotRange T>
31-
struct StringMaker<T> {
32-
static std::string convert(T const& value) {
33-
return ::std::string {Token {static_cast<Text>(value)}};
34-
}
35-
};
36-
37-
/// Save catch2 from doing infinite recursions with Block types
38-
template<CT::Block T>
39-
struct is_range<T> {
40-
static const bool value = false;
41-
};
42-
43-
}
44-
45-
using timer = Catch::Benchmark::Chronometer;
46-
47-
template<class T>
48-
using uninitialized = Catch::Benchmark::storage_for<T>;
11+
#include <Langulus/Math/Config.hpp>
12+
#include <Langulus/Flow/Resolvable.hpp>
13+
#include <Langulus/Testing.hpp>
14+
15+
using namespace Math;
16+
using namespace Flow;
17+
18+
/// A mockup of a fraction
19+
struct Fraction : public Flow::Resolvable {
20+
LANGULUS(ABSTRACT) false;
21+
LANGULUS_BASES(Resolvable);
22+
Fraction() : Resolvable {this} {}
23+
};

test/Main.hpp

Lines changed: 0 additions & 41 deletions
This file was deleted.

test/TestFlow.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
///
66
/// SPDX-License-Identifier: GPL-3.0-or-later
77
///
8+
#include <Langulus/Anyness/Many.hpp>
89
#include <Langulus/Math/Config.hpp>
910
#include <Langulus/Math/Vector.hpp>
1011
#include <Langulus/Math/Normal.hpp>
@@ -16,6 +17,8 @@
1617

1718

1819
SCENARIO("Parsing scripts", "[code]") {
20+
using Anyness::Many;
21+
1922
Many pastMissing;
2023
pastMissing.MakePast();
2124

0 commit comments

Comments
 (0)