Skip to content

Commit 1884faa

Browse files
committed
#61: refactor tests for latest Boost (1.84) support
1 parent b3d6766 commit 1884faa

18 files changed

+89
-21
lines changed

CMakeLists.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,23 @@ if(BUILD_TESTING)
1515

1616
if(Boost_FOUND)
1717
include_directories(${Boost_INCLUDE_DIRS} include)
18-
add_executable(test_runner include/decimal.h tests/runner.cpp)
18+
add_executable(test_runner include/decimal.h
19+
tests/runner.cpp
20+
tests/decimalTest.cpp
21+
tests/decimalTestAbout.cpp
22+
tests/decimalTestArithmetic.cpp
23+
tests/decimalTestDiv.cpp
24+
tests/decimalTestEdgeCases.cpp
25+
tests/decimalTestModulo.cpp
26+
tests/decimalTestMult.cpp
27+
tests/decimalTestMultDiv.cpp
28+
tests/decimalTestRounding.cpp
29+
tests/decimalTestRoundOth.cpp
30+
tests/decimalTestString.cpp
31+
tests/decimalTestTypeLevel.cpp
32+
tests/decimalTestUtils.cpp
33+
tests/decimalTestWithExponent.cpp
34+
tests/decimalTestUtils.h)
1935
target_include_directories(test_runner PRIVATE ${BOOST_INCLUDE_DIRS})
2036
endif()
2137

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ Author: Piotr Likus
77

88
Created: 03/01/2011
99

10-
Modified: 19/07/2021
10+
Modified: 24/02/2024
1111

1212
Licence: BSD
1313

14-
Version: 1.19
14+
Version: 1.20
1515

1616

1717
This data type is designed to perform calculation with on-fly roundings
@@ -164,6 +164,11 @@ In order to test the library:
164164
# to execute specific runner
165165
./test_runner
166166
167+
# to list all test cases during runner execution
168+
./test_runner --log_level=test_suite
169+
170+
# to execute tests via ctest
171+
ctest -v
167172
168173
# Other information
169174
For more examples please see \test directory.
@@ -181,7 +186,7 @@ http://www.doxygen.org/
181186
Tested compilers:
182187
183188
- VS2019 Community (MSVC++ 14.2)
184-
- gcc 9.3.0
189+
- gcc 11.4.0
185190
186191
Uses C++11 by default, define DEC_NO_CPP11 symbol if your compiler does not support this standard.
187192
To use custom namespace, define DEC_NAMESPACE symbol which should contain your target namespace for decimal type.

include/decimal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <iomanip>
4545
#include <sstream>
4646
#include <locale>
47+
#include <cmath>
4748

4849
#ifndef DEC_TYPE_LEVEL
4950
#define DEC_TYPE_LEVEL 2

tests/decimalTest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
/////////////////////////////////////////////////////////////////////////////
99

1010
#include "decimal.h"
11+
12+
13+
#include <boost/test/unit_test.hpp>
1114
#include <boost/integer_traits.hpp>
1215

1316
#ifndef DEC_NO_CPP11

tests/decimalTestAbout.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//
2-
// Test features mentioned in project README
2+
// Demo of features mentioned in project README
33
// Created by piotr on 7/19/21.
44
//
55

66
#include "decimal.h"
7+
#include <boost/test/unit_test.hpp>
78

89
BOOST_AUTO_TEST_CASE(decimalAbout) {
910
using namespace dec;

tests/decimalTestArithmetic.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//
44

55
#include "decimal.h"
6+
#include <boost/test/unit_test.hpp>
67

78
BOOST_AUTO_TEST_CASE(decimalArithmetic)
89
{

tests/decimalTestDiv.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//
44

55
#include "decimal.h"
6+
#include <boost/test/unit_test.hpp>
67

78
BOOST_AUTO_TEST_CASE(decimalDivInt)
89
{

tests/decimalTestEdgeCases.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
//
44

55
#include "decimal.h"
6-
#include "decimalTestUtils.cpp"
6+
#include "decimalTestUtils.h"
7+
#include <boost/test/unit_test.hpp>
8+
9+
#include <boost/integer_traits.hpp>
10+
11+
#ifndef DEC_NO_CPP11
12+
#include <type_traits>
13+
#endif
14+
715

816
BOOST_AUTO_TEST_CASE(decimalHighEndVals)
917
{

tests/decimalTestModulo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//
44

55
#include "decimal.h"
6+
#include <boost/test/unit_test.hpp>
67

78
BOOST_AUTO_TEST_CASE(testModOperInt) {
89
BOOST_CHECK_EQUAL(dec::decimal_cast<2>(15) % 4, 3);

tests/decimalTestMult.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//
44

55
#include "decimal.h"
6+
#include <boost/test/unit_test.hpp>
67

78
BOOST_AUTO_TEST_CASE(decimalMultiplyPrec)
89
{

0 commit comments

Comments
 (0)