-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathCombinationsSampleCode.cpp
47 lines (42 loc) · 1.57 KB
/
CombinationsSampleCode.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
#include "doctest/doctest.h"
#include <vector>
#include "ApprovalTests/CombinationApprovals.h"
namespace
{
double functionThatReturnsSomethingOutputStreamable(const std::string& /*input1*/,
const int input2,
const double input3)
{
return input2 * input3;
}
}
TEST_CASE("YouCanVerifyCombinationsOf3")
{
std::vector<std::string> listOfInput1s{"a", "b"};
std::vector<int> listOfInput2s{1, 2, 3};
std::vector<double> listOfInput3s{1.1, 2.2};
// begin-snippet: sample_combinations_of_three
ApprovalTests::CombinationApprovals::verifyAllCombinations(
[](const std::string& input1, const int input2, const double input3) {
return functionThatReturnsSomethingOutputStreamable(input1, input2, input3);
}, // This is the converter function
listOfInput1s,
listOfInput2s,
listOfInput3s);
// end-snippet
}
TEST_CASE("YouCanVerifyCombinationsOf3WithAuto")
{
std::vector<std::string> listOfInput1s{"a", "b"};
std::vector<int> listOfInput2s{1, 2, 3};
std::vector<double> listOfInput3s{1.1, 2.2};
// begin-snippet: sample_combinations_of_three_with_auto
ApprovalTests::CombinationApprovals::verifyAllCombinations(
[](auto& input1, auto& input2, auto& input3) {
return functionThatReturnsSomethingOutputStreamable(input1, input2, input3);
}, // This is the converter function
listOfInput1s,
listOfInput2s,
listOfInput3s);
// end-snippet
}