MCPcopy Create free account
hub / github.com/apache/qpid-proton / sortTests

Function sortTests

tests/include/catch.hpp:14225–14268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14223 } // end unnamed namespace
14224
14225 std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) {
14226 switch( config.runOrder() ) {
14227 case RunTests::InDeclarationOrder:
14228 // already in declaration order
14229 break;
14230
14231 case RunTests::InLexicographicalOrder: {
14232 std::vector<TestCase> sorted = unsortedTestCases;
14233 std::sort( sorted.begin(), sorted.end() );
14234 return sorted;
14235 }
14236
14237 case RunTests::InRandomOrder: {
14238 seedRng( config );
14239 TestHasher h{ config.rngSeed() };
14240
14241 using hashedTest = std::pair<TestHasher::hash_t, TestCase const*>;
14242 std::vector<hashedTest> indexed_tests;
14243 indexed_tests.reserve( unsortedTestCases.size() );
14244
14245 for (auto const& testCase : unsortedTestCases) {
14246 indexed_tests.emplace_back(h(testCase), &testCase);
14247 }
14248
14249 std::sort(indexed_tests.begin(), indexed_tests.end(),
14250 [](hashedTest const& lhs, hashedTest const& rhs) {
14251 if (lhs.first == rhs.first) {
14252 return lhs.second->name < rhs.second->name;
14253 }
14254 return lhs.first < rhs.first;
14255 });
14256
14257 std::vector<TestCase> sorted;
14258 sorted.reserve( indexed_tests.size() );
14259
14260 for (auto const& hashed : indexed_tests) {
14261 sorted.emplace_back(*hashed.second);
14262 }
14263
14264 return sorted;
14265 }
14266 }
14267 return unsortedTestCases;
14268 }
14269
14270 bool isThrowSafe( TestCase const& testCase, IConfig const& config ) {
14271 return !testCase.throws() || config.allowThrows();

Callers 1

catch.hppFile · 0.85

Calls 6

seedRngFunction · 0.85
runOrderMethod · 0.80
rngSeedMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected