Skip to content

Commit 3faaff8

Browse files
authored
Merge pull request #49 from banditcpp/prepare-v5.0.0
Prepare v5.0.0
2 parents cd0761b + 23ed111 commit 3faaff8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+248
-317
lines changed

.appveyor.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
environment:
22
matrix:
3-
- CXX_STANDARD: 98
4-
- CXX_STANDARD: 03
53
- CXX_STANDARD: 11
64
- CXX_STANDARD: 14
75

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# before committing your changes.
66
---
77
Language: Cpp
8-
Standard: Cpp03
8+
Standard: Cpp11
99

1010
ColumnLimit: 0
1111
IndentWidth: 2

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
image: docker://banditcpp/build-environments:debian-bullseye-compilers
1010
strategy:
1111
matrix:
12-
cxx-standard: ["98", "03", "11", "14", "17"]
12+
cxx-standard: ["11", "14", "17"]
1313
compiler-env: ["CC=gcc-9 CXX=g++-9", "CC=clang-9 CXX=clang++-9"]
1414
steps:
1515
- name: Clone and checkout commit
@@ -22,7 +22,7 @@ jobs:
2222
runs-on: windows-2019
2323
strategy:
2424
matrix:
25-
# C++98, C++03 and C++11 is NOT supported by MSVC 2019
25+
# C++11 is NOT supported by MSVC 2019
2626
cxx-standard: ["14", "17"]
2727
steps:
2828
- name: Clone and checkout commit

.travis.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,6 @@ services:
66
- docker
77

88
env:
9-
- DOCKER_TAG=snowhouse-minimum CXX_STANDARD=98 CC=gcc-4.4 CXX=g++-4.4
10-
- DOCKER_TAG=snowhouse-minimum CXX_STANDARD=98 CC=gcc-4.6 CXX=g++-4.6
11-
- DOCKER_TAG=snowhouse-minimum CXX_STANDARD=03 CC=gcc-4.6 CXX=g++-4.6
12-
- DOCKER_TAG=snowhouse-minimum CXX_STANDARD=98 CC=clang CXX=clang++
13-
- DOCKER_TAG=snowhouse-minimum CXX_STANDARD=03 CC=clang CXX=clang++
14-
- DOCKER_TAG=snowhouse-minimum CXX_STANDARD=11 CC=clang CXX=clang++
15-
- DOCKER_TAG=debian-jessie-compilers CXX_STANDARD=98 CC=gcc-4.8 CXX=g++-4.8
16-
- DOCKER_TAG=debian-jessie-compilers CXX_STANDARD=03 CC=gcc-4.8 CXX=g++-4.8
17-
- DOCKER_TAG=debian-jessie-compilers CXX_STANDARD=11 CC=gcc-4.8 CXX=g++-4.8
18-
- DOCKER_TAG=debian-jessie-compilers CXX_STANDARD=98 CC=gcc-4.9 CXX=g++-4.9
19-
- DOCKER_TAG=debian-jessie-compilers CXX_STANDARD=11 CC=gcc-4.9 CXX=g++-4.9
20-
- DOCKER_TAG=debian-jessie-compilers CXX_STANDARD=98 CC=clang-3.5 CXX=clang++-3.5
21-
- DOCKER_TAG=debian-jessie-compilers CXX_STANDARD=11 CC=clang-3.5 CXX=clang++-3.5
229
- DOCKER_TAG=debian-stretch-compilers CXX_STANDARD=11 CC=gcc-6 CXX=g++-6
2310
- DOCKER_TAG=debian-stretch-compilers CXX_STANDARD=11 CC=clang-3.9 CXX=clang++-3.9
2411

CMakeLists.txt

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 3.1)
22

33
project(snowhouse)
44

55
option(SNOWHOUSE_BUILD_TESTS "Build the Snowhouse tests" OFF)
66
option(SNOWHOUSE_RUN_TESTS "Run the Snowhouse tests" OFF)
7-
set(SNOWHOUSE_CXX_STANDARD "C++03" CACHE STRING "The C++ standard the examples are compiled with")
8-
set_property(CACHE SNOWHOUSE_CXX_STANDARD PROPERTY STRINGS "C++98" "C++03" "C++11" "C++14" "C++17")
7+
set(SNOWHOUSE_CXX_STANDARD "C++11" CACHE STRING "The C++ standard the examples are compiled with")
8+
set_property(CACHE SNOWHOUSE_CXX_STANDARD PROPERTY STRINGS "C++11" "C++14" "C++17")
99

10-
if (NOT ${CMAKE_VERSION} VERSION_LESS "3.0.0")
11-
add_library(snowhouse INTERFACE)
12-
target_include_directories(snowhouse INTERFACE include)
13-
endif()
10+
add_library(snowhouse INTERFACE)
11+
target_include_directories(snowhouse INTERFACE include)
1412

15-
if(SNOWHOUSE_CXX_STANDARD STREQUAL "C++98")
16-
set(std_name "c++98")
17-
elseif(SNOWHOUSE_CXX_STANDARD STREQUAL "C++03")
18-
set(std_name "c++03")
19-
elseif(SNOWHOUSE_CXX_STANDARD STREQUAL "C++11")
20-
set(std_name "c++11")
13+
if(SNOWHOUSE_CXX_STANDARD STREQUAL "C++11")
14+
set(CMAKE_CXX_STANDARD 11)
2115
elseif(SNOWHOUSE_CXX_STANDARD STREQUAL "C++14")
22-
set(std_name "c++14")
16+
set(CMAKE_CXX_STANDARD 14)
2317
elseif(SNOWHOUSE_CXX_STANDARD STREQUAL "C++17")
24-
set(std_name "c++17")
18+
set(CMAKE_CXX_STANDARD 17)
2519
else()
2620
message(WARNING "C++ standard \"${SNOWHOUSE_CXX_STANDARD}\" not known, falling back to default")
2721
endif()
@@ -30,28 +24,19 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ./bin)
3024

3125
if (MSVC)
3226
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /MP ")
33-
if(DEFINED std_name)
34-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:${std_name}")
35-
endif()
3627
else()
3728
# Assume GCC-style arguments
38-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfatal-errors -Wall -Wextra -Werror -Wfloat-equal -Wundef -Wendif-labels -Wshadow -pedantic-errors")
39-
40-
if(DEFINED std_name)
41-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=${std_name}")
42-
endif()
29+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
30+
-Wall -Wextra -pedantic -Wdeprecated -Wdeprecated-declarations -Wnon-virtual-dtor \
31+
-Wshadow -Wfloat-equal -Wundef -Wendif-labels -Wno-error=unknown-pragmas")
4332
endif()
4433

4534
message(STATUS "C++ compiler flags: ${CMAKE_CXX_FLAGS}")
4635

4736
if (SNOWHOUSE_BUILD_TESTS)
4837
FILE(GLOB SnowhouseSpecSourceFiles example/*.cpp)
4938
add_executable(snowhouse-tests ${SnowhouseSpecSourceFiles})
50-
if (NOT ${CMAKE_VERSION} VERSION_LESS "3.0.0")
51-
target_link_libraries(snowhouse-tests PRIVATE snowhouse)
52-
else()
53-
include_directories("${PROJECT_SOURCE_DIR}/include")
54-
endif()
39+
target_link_libraries(snowhouse-tests PRIVATE snowhouse)
5540
endif()
5641

5742
if (SNOWHOUSE_BUILD_TESTS AND SNOWHOUSE_RUN_TESTS)

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,26 @@ snowhouse
88
An assertion library for C++
99

1010
Snowhouse is a stand-alone assertion framework for C++.
11-
1211
It is a header-only library.
13-
You can simply use the `headers-only` branch as a submodule:
12+
13+
Snowhouse requires a C++11-compatible compiler since version 5.0.0.
14+
Feel free to use Snowhouse with major version 4 if you want to use it
15+
in a pre-C++11 setting.
16+
Major version 4 is still maintained in the `maint-v4` branch (bug fixes, etc.).
17+
18+
For inclusion in your projects, you have several options:
19+
20+
a) You can copy the code and just use it as the license allows.
21+
22+
b) You can use the `headers-only` branch as a submodule:
1423

1524
```sh
1625
git submodule add -b headers-only https://github.com/banditcpp/snowhouse snowhouse
1726
git submodule update --init --recursive
1827
```
1928

20-
As an alternative, CMake >= 3.0 users can use Snowhouse with the provided library target.
29+
c) If you use CMake >= 3.1 in your project,
30+
you can use Snowhouse with the provided library target.
2131
Assuming you have cloned the `master` branch into a `snowhouse` subdirectory,
2232
your `CMakeLists.txt` might contain lines like the following:
2333

@@ -43,10 +53,10 @@ int main()
4353
{
4454
AssertThat(12, Is().LessThan(11).And().GreaterThan(99));
4555
}
46-
catch(const AssertionException& ex)
56+
catch (const AssertionException& ex)
4757
{
4858
std::cout << "Apparently this failed:" << std::endl;
49-
std::cout << ex.GetMessage() << std::endl;
59+
std::cout << ex.what() << std::endl;
5060
}
5161

5262
return 0;
@@ -166,9 +176,6 @@ AssertThat(x, IsNull());
166176
AssertThat(x, Is().Null());
167177
```
168178

169-
Note that this feature is only available for C++11-compliant compilers.
170-
In this case, the `SNOWHOUSE_HAS_NULLPTR` macro is defined.
171-
172179
### String Constraints
173180

174181
String assertions in Snowhouse are used to verify the values of
@@ -518,6 +525,11 @@ Compatibility-breaking changes since version 3.0.0:
518525
Booleans are now displayed as `true` or `false`.
519526
Strings are put into quotation marks for improved readability.
520527

528+
* Since version 5.0.0, the support for C++ versions prior to C++11 are dropped.
529+
The definition of the macro `SNOWHOUSE_HAS_NULLPTR` is removed.
530+
Our exceptions are now derived from the `std::exception` hierarchy,
531+
thus their method names changed.
532+
521533
## Contributing
522534

523535
The development of Snowhouse takes place on [GitHub](//github.com/banditcpp/snowhouse).
@@ -533,7 +545,7 @@ Please make sure to be consistent with the project's coding style.
533545
The `.clang-format` file allows easy checking and implementation of the
534546
coding style.
535547

536-
C++ code should comply to C++98, C++03- and C++11.
548+
C++ code should comply to C++11.
537549
Please use `__cplusplus` guards if you want to use language features of
538550
a certain C++ version.
539551

example/basic_assertions.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ void BasicAssertions()
8888
}
8989
catch (const AssertionException& e)
9090
{
91-
line = e.GetLineNumber();
92-
file = e.GetFilename();
91+
line = e.line();
92+
file = e.file();
9393
}
9494

9595
AssertThat(line, Equals(32));
@@ -180,7 +180,6 @@ void BasicAssertions()
180180
"Expected: less than or equal to 5\nActual: 6\n");
181181
}
182182

183-
#ifdef SNOWHOUSE_HAS_NULLPTR
184183
it("handles IsNull()");
185184
{
186185
AssertThat(nullptr, IsNull());
@@ -220,5 +219,4 @@ void BasicAssertions()
220219

221220
AssertTestFails(AssertThat(nullptr, !IsNull()), message.str());
222221
}
223-
#endif
224222
}

example/exceptions_tests.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ struct ClassWithExceptions
2626
}
2727
};
2828

29+
struct ExpectedException : public std::exception
30+
{
31+
const char* what() const noexcept override
32+
{
33+
return "Description of the exception we expected";
34+
}
35+
};
36+
2937
void ExceptionTests()
3038
{
3139
ClassWithExceptions objectUnderTest;
@@ -87,6 +95,11 @@ void ExceptionTests()
8795
AssertThrows(std::logic_error, objectUnderTest.LogicError());
8896
}
8997
AssertThrows(AssertionException, LastException<std::logic_error>());
90-
AssertThat(LastException<AssertionException>().GetMessage(), Contains("No exception was stored"));
98+
AssertThat(LastException<AssertionException>().what(), Contains("No exception was stored"));
99+
}
100+
101+
it("prints description of unwanted exception");
102+
{
103+
AssertTestFails(AssertThrows(ExpectedException, objectUnderTest.LogicError()), "Expected ExpectedException. Wrong exception was thrown. Description of unwanted exception: not logical!");
91104
}
92105
}

example/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int main()
3737
catch (const AssertionException& e)
3838
{
3939
std::cout << "Tests failed!" << std::endl;
40-
std::cout << e.GetMessage() << std::endl;
40+
std::cout << e.what() << std::endl;
4141
return 1;
4242
}
4343

example/operator_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void OperatorTests()
9393
it("yields error on malformed expression");
9494
{
9595
AssertTestFails(AssertThat(4, Is().Not()),
96-
"The expression contains a not operator without any operand");
96+
"The expression contains a \"not\" operator without any operand");
9797
}
9898

9999
it("handles failing EqualsWithDelta() when larger than delta");

0 commit comments

Comments
 (0)