Skip to content

Commit 11c9a36

Browse files
committed
Updated submodule extlibs/Catch2 and adapted usage
1 parent c5b00ab commit 11c9a36

13 files changed

+94
-111
lines changed

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,12 @@ if(DYNAMICBITSET_BUILD_TESTS)
212212
if(NOT EXISTS "${CATCH2_CMAKELISTS_PATH}")
213213
message(FATAL_ERROR "Catch2 dependency is missing, maybe you didn't pull the git submodules")
214214
endif()
215-
add_subdirectory(extlibs/Catch2)
216-
include(extlibs/Catch2/contrib/Catch.cmake)
215+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.25)
216+
add_subdirectory(extlibs/Catch2 SYSTEM)
217+
else()
218+
add_subdirectory(extlibs/Catch2)
219+
endif()
220+
include(extlibs/Catch2/extras/Catch.cmake)
217221

218222
# Disable warnings on Catch2 headers
219223
get_target_property(Catch2_include_directories Catch2 INTERFACE_INCLUDE_DIRECTORIES)

extlibs/Catch2

Submodule Catch2 updated 751 files

tests/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,23 @@ target_sources(
3333
target_sources(
3434
dynamic_bitset_tests_libpopcnt PRIVATE
3535
${includes}
36-
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
3736
"${CMAKE_CURRENT_SOURCE_DIR}/src/count.cpp"
3837
)
3938
target_sources(
4039
dynamic_bitset_tests_std_bitops PRIVATE
4140
${includes}
42-
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
4341
"${CMAKE_CURRENT_SOURCE_DIR}/src/count.cpp"
4442
"${CMAKE_CURRENT_SOURCE_DIR}/src/find_first_find_next.cpp"
4543
)
4644
target_sources(
4745
dynamic_bitset_tests_builtins PRIVATE
4846
${includes}
49-
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
5047
"${CMAKE_CURRENT_SOURCE_DIR}/src/count.cpp"
5148
"${CMAKE_CURRENT_SOURCE_DIR}/src/find_first_find_next.cpp"
5249
)
5350
target_sources(
5451
dynamic_bitset_tests_builtins_msvc_32 PRIVATE
5552
${includes}
56-
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
5753
"${CMAKE_CURRENT_SOURCE_DIR}/src/find_first_find_next.cpp"
5854
)
5955
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${includes} ${sources})
@@ -79,7 +75,7 @@ foreach(
7975
target_link_libraries(${target} PRIVATE dynamic_bitset)
8076

8177
# Link Catch2
82-
target_link_libraries(${target} PRIVATE Catch2::Catch2)
78+
target_link_libraries(${target} PRIVATE Catch2::Catch2WithMain)
8379

8480
# Enable coverage information generation?
8581
if(DYNAMICBITSET_ENABLE_COVERAGE)

tests/include/MultiTakeGenerator.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#ifndef DYNAMIC_BITSET_MULTITAKEGENERATOR_HPP
99
#define DYNAMIC_BITSET_MULTITAKEGENERATOR_HPP
1010

11-
#include <catch2/catch.hpp>
11+
#include <catch2/generators/catch_generators.hpp>
1212

1313
#include <algorithm>
1414
#include <tuple>
@@ -120,7 +120,7 @@ constexpr Catch::Generators::GeneratorWrapper<std::tuple<T...>> multitake(
120120
Catch::Generators::GeneratorWrapper<T>&&... generators)
121121
{
122122
return Catch::Generators::GeneratorWrapper<std::tuple<T...>>(
123-
std::make_unique<MultiTakeGenerator<T...>>(target, std::move(generators)...));
123+
Catch::Detail::make_unique<MultiTakeGenerator<T...>>(target, std::move(generators)...));
124124
}
125125

126126
#endif //DYNAMIC_BITSET_MULTITAKEGENERATOR_HPP

tests/include/RandomBitsetStringGenerator.hpp

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@
88
#ifndef DYNAMIC_BITSET_RANDOMBITSETSTRINGGENERATOR_HPP
99
#define DYNAMIC_BITSET_RANDOMBITSETSTRINGGENERATOR_HPP
1010

11-
#include <catch2/catch.hpp>
11+
#include <catch2/generators/catch_generators.hpp>
12+
#include <catch2/catch_get_random_seed.hpp>
1213

1314
#include <random>
1415
#include <string>
1516

1617
Catch::Generators::GeneratorWrapper<std::string> randomBitsetString(
17-
std::minstd_rand::result_type seed =
18-
static_cast<std::minstd_rand::result_type>(std::random_device{}()));
18+
uint32_t seed = Catch::getSeed());
1919

2020
Catch::Generators::GeneratorWrapper<std::string> randomBitsetString(
2121
std::string::size_type min_size,
2222
std::string::size_type max_size,
23-
std::minstd_rand::result_type seed =
24-
static_cast<std::minstd_rand::result_type>(std::random_device{}()));
23+
uint32_t seed = Catch::getSeed());
2524

2625
class RandomBitsetStringGenerator : public Catch::Generators::IGenerator<std::string>
2726
{
@@ -30,14 +29,10 @@ class RandomBitsetStringGenerator : public Catch::Generators::IGenerator<std::st
3029
static constexpr size_type default_min_size = 1;
3130
static constexpr size_type default_max_size = 8 * 32;
3231

33-
explicit RandomBitsetStringGenerator(
34-
std::minstd_rand::result_type seed =
35-
static_cast<std::minstd_rand::result_type>(std::random_device{}()));
36-
RandomBitsetStringGenerator(
37-
size_type min_size,
38-
size_type max_size,
39-
std::minstd_rand::result_type seed =
40-
static_cast<std::minstd_rand::result_type>(std::random_device{}()));
32+
explicit RandomBitsetStringGenerator(uint32_t seed = Catch::getSeed());
33+
RandomBitsetStringGenerator(size_type min_size,
34+
size_type max_size,
35+
uint32_t seed = Catch::getSeed());
4136

4237
const std::string& get() const override;
4338
bool next() override;
@@ -49,7 +44,7 @@ class RandomBitsetStringGenerator : public Catch::Generators::IGenerator<std::st
4944
std::string m_current_bitset;
5045
};
5146

52-
RandomBitsetStringGenerator::RandomBitsetStringGenerator(std::minstd_rand::result_type seed)
47+
RandomBitsetStringGenerator::RandomBitsetStringGenerator(uint32_t seed)
5348
: m_rand(seed), m_size_dist(default_min_size, default_max_size), m_bit_dist(), m_current_bitset()
5449
{
5550
next();
@@ -58,7 +53,7 @@ RandomBitsetStringGenerator::RandomBitsetStringGenerator(std::minstd_rand::resul
5853
RandomBitsetStringGenerator::RandomBitsetStringGenerator(
5954
RandomBitsetStringGenerator::size_type min_size,
6055
RandomBitsetStringGenerator::size_type max_size,
61-
std::minstd_rand::result_type seed)
56+
uint32_t seed)
6257
: m_rand(seed), m_size_dist(min_size, max_size), m_bit_dist(), m_current_bitset()
6358
{
6459
next();
@@ -81,20 +76,19 @@ bool RandomBitsetStringGenerator::next()
8176
return true;
8277
}
8378

84-
Catch::Generators::GeneratorWrapper<std::string> randomBitsetString(
85-
std::minstd_rand::result_type seed)
79+
Catch::Generators::GeneratorWrapper<std::string> randomBitsetString(uint32_t seed)
8680
{
8781
return Catch::Generators::GeneratorWrapper<std::string>(
88-
std::make_unique<RandomBitsetStringGenerator>(seed));
82+
Catch::Detail::make_unique<RandomBitsetStringGenerator>(seed));
8983
}
9084

9185
Catch::Generators::GeneratorWrapper<std::string> randomBitsetString(
9286
typename std::string::size_type min_size,
9387
typename std::string::size_type max_size,
94-
std::minstd_rand::result_type seed)
88+
uint32_t seed)
9589
{
9690
return Catch::Generators::GeneratorWrapper<std::string>(
97-
std::make_unique<RandomBitsetStringGenerator>(min_size, max_size, seed));
91+
Catch::Detail::make_unique<RandomBitsetStringGenerator>(min_size, max_size, seed));
9892
}
9993

10094
#endif //DYNAMIC_BITSET_RANDOMBITSETSTRINGGENERATOR_HPP

tests/include/RandomChunkGenerator.hpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
#ifndef DYNAMIC_BITSET_RANDOMCHUNKGENERATOR_HPP
99
#define DYNAMIC_BITSET_RANDOMCHUNKGENERATOR_HPP
1010

11-
#include <catch2/catch.hpp>
11+
#include <catch2/generators/catch_generators.hpp>
12+
#include <catch2/catch_get_random_seed.hpp>
1213

1314
#include <algorithm>
1415
#include <tuple>
@@ -20,19 +21,16 @@ constexpr Catch::Generators::GeneratorWrapper<std::vector<T>> randomChunk(
2021
size_t min_chunk_size,
2122
size_t max_chunk_size,
2223
Catch::Generators::GeneratorWrapper<T>&& generator,
23-
std::minstd_rand::result_type seed =
24-
static_cast<std::minstd_rand::result_type>(std::random_device{}()));
24+
uint32_t seed = Catch::getSeed());
2525

2626
template<typename T>
2727
class RandomChunkGenerator final : public Catch::Generators::IGenerator<std::vector<T>>
2828
{
2929
public:
30-
constexpr RandomChunkGenerator(
31-
size_t min_chunk_size,
32-
size_t max_chunk_size,
33-
Catch::Generators::GeneratorWrapper<T>&& generator,
34-
std::minstd_rand::result_type seed =
35-
static_cast<std::minstd_rand::result_type>(std::random_device{}()));
30+
constexpr RandomChunkGenerator(size_t min_chunk_size,
31+
size_t max_chunk_size,
32+
Catch::Generators::GeneratorWrapper<T>&& generator,
33+
uint32_t seed = Catch::getSeed());
3634

3735
constexpr std::vector<T> const& get() const override;
3836

@@ -50,7 +48,7 @@ constexpr RandomChunkGenerator<T>::RandomChunkGenerator(
5048
size_t min_chunk_size,
5149
size_t max_chunk_size,
5250
Catch::Generators::GeneratorWrapper<T>&& generator,
53-
std::minstd_rand::result_type seed)
51+
uint32_t seed)
5452
: m_rand(seed)
5553
, m_size_dist(min_chunk_size, max_chunk_size)
5654
, m_chunk()
@@ -106,10 +104,10 @@ constexpr Catch::Generators::GeneratorWrapper<std::vector<T>> randomChunk(
106104
size_t min_chunk_size,
107105
size_t max_chunk_size,
108106
Catch::Generators::GeneratorWrapper<T>&& generator,
109-
std::minstd_rand::result_type seed)
107+
uint32_t seed)
110108
{
111109
return Catch::Generators::GeneratorWrapper<std::vector<T>>(
112-
std::make_unique<RandomChunkGenerator<T>>(
110+
Catch::Detail::make_unique<RandomChunkGenerator<T>>(
113111
min_chunk_size, max_chunk_size, std::move(generator), seed));
114112
}
115113

tests/include/RandomDynamicBitsetGenerator.hpp

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@
88
#ifndef DYNAMIC_BITSET_RANDOMDYNAMICBITSETGENERATOR_HPP
99
#define DYNAMIC_BITSET_RANDOMDYNAMICBITSETGENERATOR_HPP
1010

11-
#include <catch2/catch.hpp>
11+
#include <catch2/generators/catch_generators.hpp>
12+
#include <catch2/catch_get_random_seed.hpp>
1213
#include <sul/dynamic_bitset.hpp>
1314

1415
#include <random>
1516

1617
template<typename Block>
1718
constexpr Catch::Generators::GeneratorWrapper<sul::dynamic_bitset<Block>> randomDynamicBitset(
18-
std::minstd_rand::result_type seed =
19-
static_cast<std::minstd_rand::result_type>(std::random_device{}()));
19+
uint32_t seed = Catch::getSeed());
2020

2121
template<typename Block>
2222
constexpr Catch::Generators::GeneratorWrapper<sul::dynamic_bitset<Block>> randomDynamicBitset(
2323
typename sul::dynamic_bitset<Block>::size_type min_size,
2424
typename sul::dynamic_bitset<Block>::size_type max_size,
25-
std::minstd_rand::result_type seed =
26-
static_cast<std::minstd_rand::result_type>(std::random_device{}()));
25+
uint32_t seed = Catch::getSeed());
2726

2827
template<typename Block>
2928
class RandomDynamicBitsetGenerator
@@ -34,14 +33,10 @@ class RandomDynamicBitsetGenerator
3433
static constexpr size_type default_min_size = 1;
3534
static constexpr size_type default_max_size = 8 * std::numeric_limits<Block>::digits;
3635

37-
constexpr explicit RandomDynamicBitsetGenerator(
38-
std::minstd_rand::result_type seed =
39-
static_cast<std::minstd_rand::result_type>(std::random_device{}()));
40-
constexpr RandomDynamicBitsetGenerator(
41-
size_type min_size,
42-
size_type max_size,
43-
std::minstd_rand::result_type seed =
44-
static_cast<std::minstd_rand::result_type>(std::random_device{}()));
36+
constexpr explicit RandomDynamicBitsetGenerator(uint32_t seed = Catch::getSeed());
37+
constexpr RandomDynamicBitsetGenerator(size_type min_size,
38+
size_type max_size,
39+
uint32_t seed = Catch::getSeed());
4540

4641
constexpr const sul::dynamic_bitset<Block>& get() const override;
4742
constexpr bool next() override;
@@ -54,8 +49,7 @@ class RandomDynamicBitsetGenerator
5449
};
5550

5651
template<typename Block>
57-
constexpr RandomDynamicBitsetGenerator<Block>::RandomDynamicBitsetGenerator(
58-
std::minstd_rand::result_type seed)
52+
constexpr RandomDynamicBitsetGenerator<Block>::RandomDynamicBitsetGenerator(uint32_t seed)
5953
: m_rand(seed)
6054
, m_size_dist(default_min_size, default_max_size)
6155
, m_block_dist()
@@ -65,10 +59,9 @@ constexpr RandomDynamicBitsetGenerator<Block>::RandomDynamicBitsetGenerator(
6559
}
6660

6761
template<typename Block>
68-
constexpr RandomDynamicBitsetGenerator<Block>::RandomDynamicBitsetGenerator(
69-
RandomDynamicBitsetGenerator::size_type min_size,
70-
RandomDynamicBitsetGenerator::size_type max_size,
71-
std::minstd_rand::result_type seed)
62+
constexpr RandomDynamicBitsetGenerator<Block>::RandomDynamicBitsetGenerator(size_type min_size,
63+
size_type max_size,
64+
uint32_t seed)
7265
: m_rand(seed), m_size_dist(min_size, max_size), m_block_dist(), m_current_bitset()
7366
{
7467
next();
@@ -95,20 +88,20 @@ constexpr bool RandomDynamicBitsetGenerator<Block>::next()
9588

9689
template<typename Block>
9790
constexpr Catch::Generators::GeneratorWrapper<sul::dynamic_bitset<Block>> randomDynamicBitset(
98-
std::minstd_rand::result_type seed)
91+
uint32_t seed)
9992
{
10093
return Catch::Generators::GeneratorWrapper<sul::dynamic_bitset<Block>>(
101-
std::make_unique<RandomDynamicBitsetGenerator<Block>>(seed));
94+
Catch::Detail::make_unique<RandomDynamicBitsetGenerator<Block>>(seed));
10295
}
10396

10497
template<typename Block>
10598
constexpr Catch::Generators::GeneratorWrapper<sul::dynamic_bitset<Block>> randomDynamicBitset(
10699
typename sul::dynamic_bitset<Block>::size_type min_size,
107100
typename sul::dynamic_bitset<Block>::size_type max_size,
108-
std::minstd_rand::result_type seed)
101+
uint32_t seed)
109102
{
110103
return Catch::Generators::GeneratorWrapper<sul::dynamic_bitset<Block>>(
111-
std::make_unique<RandomDynamicBitsetGenerator<Block>>(min_size, max_size, seed));
104+
Catch::Detail::make_unique<RandomDynamicBitsetGenerator<Block>>(min_size, max_size, seed));
112105
}
113106

114107
#endif //DYNAMIC_BITSET_RANDOMDYNAMICBITSETGENERATOR_HPP

0 commit comments

Comments
 (0)