-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathDocTestApprovalTestTests.cpp
55 lines (49 loc) · 1.43 KB
/
DocTestApprovalTestTests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "ApprovalTests/reporters/QuietReporter.h"
#include "doctest/doctest.h"
#include "ApprovalTests/Approvals.h"
#include "ApprovalTests/writers/StringWriter.h"
using namespace ApprovalTests;
TEST_CASE("YouCanUseAWriter")
{
using HtmlWriter = StringWriter;
// begin-snippet: use_custom_writer
HtmlWriter writer("<h1>hello world</h1>", ".html");
Approvals::verify(writer);
// end-snippet
}
TEST_CASE("YouCanSpecifyYourFileExtension")
{
// begin-snippet: use_custom_file_extension
Approvals::verify("<h1>hello world</h1>",
Options().fileOptions().withFileExtension(".html"));
// end-snippet
}
TEST_CASE("YouCanSpecifyYourFileExtensionWithToString")
{
Approvals::verify(1337, Options().fileOptions().withFileExtension(".csv"));
}
TEST_CASE("YouCanSpecifyYourFileExtensionWithFormatter")
{
Approvals::verify(
1337,
[](auto value, auto& os) { os << "**value:** " << value; },
Options().fileOptions().withFileExtension(".md"));
}
TEST_CASE("YouCanSpecifyAllOptions")
{
Approvals::verify(
R"({
name: frances
id: 05f77de3-3790-4d45-b045-def96c9cd371
}
)",
// clang-format off
// begin-snippet: specify_all_the_options
Options()
.withReporter(QuietReporter())
.withScrubber(Scrubbers::scrubGuid)
.fileOptions().withFileExtension(".json")
// end-snippet
// clang-format on
);
}