diff options
Diffstat (limited to 'test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp')
| -rw-r--r-- | test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp b/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp index 557c1b24d88f..69d08e6eb49a 100644 --- a/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp +++ b/test/std/experimental/filesystem/class.path/path.member/path.compare.pass.cpp @@ -73,6 +73,11 @@ const PathCompareTest CompareTestCases[] = #undef LONGC #undef LONGD +static inline int normalize_ret(int ret) +{ + return ret < 0 ? -1 : (ret > 0 ? 1 : 0); +} + int main() { using namespace fs; @@ -80,17 +85,18 @@ int main() const path p1(TC.LHS); const path p2(TC.RHS); const std::string R(TC.RHS); + const std::string_view RV(TC.RHS); const int E = TC.expect; { // compare(...) functions DisableAllocationGuard g; // none of these operations should allocate // check runtime results - int ret1 = p1.compare(p2); - int ret2 = p1.compare(R); - int ret3 = p1.compare(TC.RHS); - assert(ret1 == ret2 && ret1 == ret3); - int normalized_ret = ret1 < 0 ? -1 : (ret1 > 0 ? 1 : 0); - assert(normalized_ret == E); + int ret1 = normalize_ret(p1.compare(p2)); + int ret2 = normalize_ret(p1.compare(R)); + int ret3 = normalize_ret(p1.compare(TC.RHS)); + int ret4 = normalize_ret(p1.compare(RV)); + assert(ret1 == ret2 && ret1 == ret3 && ret1 == ret4); + assert(ret1 == E); // check signatures ASSERT_NOEXCEPT(p1.compare(p2)); |
