Last active
October 23, 2020 08:21
-
-
Save kasajian/98e5c12539474f48ea8742862662ad09 to your computer and use it in GitHub Desktop.
Approval Tests CPP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ApprovalTests.hpp" | |
#include <iostream> | |
void TestXyz() | |
{ | |
try | |
{ | |
TestName currentTest; | |
currentTest.setFileName(__FILE__); | |
currentTest.sections = { "TestXyz" }; | |
ApprovalTestNamer::currentTest(¤tTest); | |
Approvals::verify("Some\nMulti-line\noutput"); | |
} | |
catch (const ApprovalException& e) | |
{ | |
std::cout << e.what() << std::endl; | |
} | |
} | |
int main() | |
{ | |
TestXyz(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <codecvt> | |
#include <string> | |
#include "ApprovalTests.hpp" | |
#define APPROVAL_METHOD_START(methodName) \ | |
try \ | |
{ \ | |
TestName currentTest; \ | |
currentTest.setFileName(__FILE__); \ | |
currentTest.sections = { #methodName }; \ | |
ApprovalTestNamer::currentTest(¤tTest); | |
#define APPROVAL_METHOD_END \ | |
} \ | |
catch (const ApprovalException& e) \ | |
{ \ | |
Assert::Fail( \ | |
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t>() \ | |
.from_bytes(e.what()) \ | |
.c_str()); \ | |
} | |
inline static void ApprovalsVerify(const wchar_t* contents, const Reporter &reporter = DefaultReporter()) | |
{ | |
Approvals::verify(std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t>().to_bytes(contents), reporter); | |
} | |
inline static void ApprovalsVerify(const char* contents, const Reporter &reporter = DefaultReporter()) | |
{ | |
Approvals::verify(contents, reporter); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment