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

summaryrefslogtreecommitdiffhomepage
path: root/tests/Progmasoft/Snapshot.tests.cpp
diff options
context:
space:
mode:
authorLeitwolf2026-10-31 17:18:21 +0300
committerGitHub2026-10-31 17:18:21 +0300
commit326ea0c0213aeecb6b984bba3dabb0ebad97679e (patch)
tree5cec698f0bc0b8a60f45e866fb40f2fd8a358bd1 /tests/Progmasoft/Snapshot.tests.cpp
parent6a42cdf6461b2577106ef094d6f98025554b6077 (diff)
parentafe91797e9d50cd4712d3694a2e5fedfc0b966b1 (diff)
downloadcatch3-326ea0c0213aeecb6b984bba3dabb0ebad97679e.tar.gz
Merge pull request #22 from Progmasoft/build/cpp17
Build Catch3 as C++17
Diffstat (limited to 'tests/Progmasoft/Snapshot.tests.cpp')
-rw-r--r--tests/Progmasoft/Snapshot.tests.cpp77
1 files changed, 46 insertions, 31 deletions
diff --git a/tests/Progmasoft/Snapshot.tests.cpp b/tests/Progmasoft/Snapshot.tests.cpp
index 65ee732e..c29cb143 100644
--- a/tests/Progmasoft/Snapshot.tests.cpp
+++ b/tests/Progmasoft/Snapshot.tests.cpp
@@ -42,10 +42,11 @@ TEST_CASE( "Snapshot comparison does not write during ordinary runs",
using Progmasoft::Catch3::SnapshotStatus;
const TemporarySnapshotDirectory directory;
- const auto result =
- CompareSnapshot( "greeting",
- "hello\nworld\n",
- SnapshotOptions{ .Directory = directory.Path } );
+ const auto result = CompareSnapshot("greeting", "hello\nworld\n", [&] {
+ SnapshotOptions made;
+ made.Directory = directory.Path;
+ return made;
+ }());
CHECK( result.Status == SnapshotStatus::kMismatched );
CHECK_FALSE( result.Succeeded() );
@@ -62,10 +63,12 @@ TEST_CASE( "Snapshots normalize line endings and report precise differences",
using Progmasoft::Catch3::SnapshotUpdateMode;
const TemporarySnapshotDirectory directory;
- const SnapshotOptions createOptions{
- .Directory = directory.Path,
- .UpdateMode = SnapshotUpdateMode::kCreateMissing,
- };
+ const SnapshotOptions createOptions = [&] {
+ SnapshotOptions made;
+ made.Directory = directory.Path;
+ made.UpdateMode = SnapshotUpdateMode::kCreateMissing;
+ return made;
+ }();
const auto created =
CompareSnapshot( "multiline", "one\ntwo\n", createOptions );
REQUIRE( created.Status == SnapshotStatus::kCreated );
@@ -76,10 +79,11 @@ TEST_CASE( "Snapshots normalize line endings and report precise differences",
CHECK( normalized.Status == SnapshotStatus::kMatched );
CHECK( normalized.Expected == "one\ntwo\n" );
- const auto mismatch =
- CompareSnapshot( "multiline",
- "one\ntoo\n",
- SnapshotOptions{ .Directory = directory.Path } );
+ const auto mismatch = CompareSnapshot("multiline", "one\ntoo\n", [&] {
+ SnapshotOptions made;
+ made.Directory = directory.Path;
+ return made;
+ }());
CHECK( mismatch.Status == SnapshotStatus::kMismatched );
CHECK( mismatch.DifferenceLine == 2 );
CHECK( mismatch.DifferenceColumn == 2 );
@@ -94,10 +98,12 @@ TEST_CASE( "Snapshot creation and replacement require explicit update modes",
using Progmasoft::Catch3::SnapshotUpdateMode;
const TemporarySnapshotDirectory directory;
- const SnapshotOptions createMissing{
- .Directory = directory.Path,
- .UpdateMode = SnapshotUpdateMode::kCreateMissing,
- };
+ const SnapshotOptions createMissing = [&] {
+ SnapshotOptions made;
+ made.Directory = directory.Path;
+ made.UpdateMode = SnapshotUpdateMode::kCreateMissing;
+ return made;
+ }();
REQUIRE( CompareSnapshot( "answer", "first", createMissing ).Succeeded() );
const auto protectedMismatch =
@@ -105,10 +111,12 @@ TEST_CASE( "Snapshot creation and replacement require explicit update modes",
CHECK( protectedMismatch.Status == SnapshotStatus::kMismatched );
CHECK( protectedMismatch.Expected == "first" );
- const SnapshotOptions updateEverything{
- .Directory = directory.Path,
- .UpdateMode = SnapshotUpdateMode::kAlways,
- };
+ const SnapshotOptions updateEverything = [&] {
+ SnapshotOptions made;
+ made.Directory = directory.Path;
+ made.UpdateMode = SnapshotUpdateMode::kAlways;
+ return made;
+ }();
const auto updated =
CompareSnapshot( "answer", "second", updateEverything );
REQUIRE( updated.Status == SnapshotStatus::kUpdated );
@@ -125,7 +133,11 @@ TEST_CASE( "Snapshot names and I/O failures are returned as structured errors",
using Progmasoft::Catch3::SnapshotUpdateMode;
const TemporarySnapshotDirectory directory;
- const SnapshotOptions options{ .Directory = directory.Path };
+ const SnapshotOptions options = [&] {
+ SnapshotOptions made;
+ made.Directory = directory.Path;
+ return made;
+ }();
CHECK( CompareSnapshot( "../outside", "text", options ).Status ==
SnapshotStatus::kInvalidName );
CHECK( CompareSnapshot( "nested/name", "text", options ).Status ==
@@ -141,11 +153,12 @@ TEST_CASE( "Snapshot names and I/O failures are returned as structured errors",
REQUIRE( output.good() );
output << "file";
}
- const auto ioFailure = CompareSnapshot(
- "snapshot",
- "text",
- SnapshotOptions{ .Directory = blockingFile,
- .UpdateMode = SnapshotUpdateMode::kCreateMissing } );
+ const auto ioFailure = CompareSnapshot("snapshot", "text", [&] {
+ SnapshotOptions made;
+ made.Directory = blockingFile;
+ made.UpdateMode = SnapshotUpdateMode::kCreateMissing;
+ return made;
+ }());
CHECK( ioFailure.Status == SnapshotStatus::kIoError );
CHECK_FALSE( ioFailure.Message.empty() );
}
@@ -156,9 +169,11 @@ TEST_CASE( "Snapshot assertion macro reports successful explicit updates",
CATCH3_CHECK_SNAPSHOT(
"macro",
"stable value",
- ( Progmasoft::Catch3::SnapshotOptions{
- .Directory = directory.Path,
- .UpdateMode =
- Progmasoft::Catch3::SnapshotUpdateMode::kCreateMissing,
- } ) );
+ ([&] {
+ Progmasoft::Catch3::SnapshotOptions made;
+ made.Directory = directory.Path;
+ made.UpdateMode
+ = Progmasoft::Catch3::SnapshotUpdateMode::kCreateMissing;
+ return made;
+ }()));
}