Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/catch_test_case_info.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2024-09-13 11:16:20 +0200
committerMartin Hořeňovský2024-09-13 16:40:11 +0200
commit18df97df00848e91bfe1b63408bba19f8b8237ae (patch)
tree91b5056d1a6b945500c397eea60437b4a3ad79f1 /src/catch2/catch_test_case_info.cpp
parente97ebe62e700dad37fe460644e121ec462e75596 (diff)
downloadcatch3-18df97df00848e91bfe1b63408bba19f8b8237ae.tar.gz
Sprinkle some constexpr around to make Jason happy
Most of these will not matter in practice due to C++14 imposing significant limitations on what else we can make constexpr, and we cannot have references outliving the constexpr context either way.
Diffstat (limited to 'src/catch2/catch_test_case_info.cpp')
-rw-r--r--src/catch2/catch_test_case_info.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/catch2/catch_test_case_info.cpp b/src/catch2/catch_test_case_info.cpp
index 2a4fbd33..9d64e532 100644
--- a/src/catch2/catch_test_case_info.cpp
+++ b/src/catch2/catch_test_case_info.cpp
@@ -22,26 +22,26 @@ namespace Catch {
static_assert(sizeof(TestCaseProperties) == sizeof(TCP_underlying_type),
"The size of the TestCaseProperties is different from the assumed size");
- TestCaseProperties operator|(TestCaseProperties lhs, TestCaseProperties rhs) {
+ constexpr TestCaseProperties operator|(TestCaseProperties lhs, TestCaseProperties rhs) {
return static_cast<TestCaseProperties>(
static_cast<TCP_underlying_type>(lhs) | static_cast<TCP_underlying_type>(rhs)
);
}
- TestCaseProperties& operator|=(TestCaseProperties& lhs, TestCaseProperties rhs) {
+ constexpr TestCaseProperties& operator|=(TestCaseProperties& lhs, TestCaseProperties rhs) {
lhs = static_cast<TestCaseProperties>(
static_cast<TCP_underlying_type>(lhs) | static_cast<TCP_underlying_type>(rhs)
);
return lhs;
}
- TestCaseProperties operator&(TestCaseProperties lhs, TestCaseProperties rhs) {
+ constexpr TestCaseProperties operator&(TestCaseProperties lhs, TestCaseProperties rhs) {
return static_cast<TestCaseProperties>(
static_cast<TCP_underlying_type>(lhs) & static_cast<TCP_underlying_type>(rhs)
);
}
- bool applies(TestCaseProperties tcp) {
+ constexpr bool applies(TestCaseProperties tcp) {
static_assert(static_cast<TCP_underlying_type>(TestCaseProperties::None) == 0,
"TestCaseProperties::None must be equal to 0");
return tcp != TestCaseProperties::None;
@@ -80,7 +80,7 @@ namespace Catch {
return "Anonymous test case " + std::to_string(++counter);
}
- StringRef extractFilenamePart(StringRef filename) {
+ constexpr StringRef extractFilenamePart(StringRef filename) {
size_t lastDot = filename.size();
while (lastDot > 0 && filename[lastDot - 1] != '.') {
--lastDot;
@@ -98,7 +98,7 @@ namespace Catch {
}
// Returns the upper bound on size of extra tags ([#file]+[.])
- size_t sizeOfExtraTags(StringRef filepath) {
+ constexpr size_t sizeOfExtraTags(StringRef filepath) {
// [.] is 3, [#] is another 3
const size_t extras = 3 + 3;
return extractFilenamePart(filepath).size() + extras;
@@ -259,8 +259,4 @@ namespace Catch {
return lhs.tags < rhs.tags;
}
- TestCaseInfo const& TestCaseHandle::getTestCaseInfo() const {
- return *m_info;
- }
-
} // end namespace Catch