-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
F!! Created untested seam for EmptyFileCreator #172
Co-Authored-By: Clare Macrae <[email protected]>
- Loading branch information
1 parent
ffdf91b
commit 419265e
Showing
7 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <sstream> | ||
#include "EmptyFileCreatorDisposer.h" | ||
|
||
namespace ApprovalTests | ||
{ | ||
|
||
EmptyFileCreatorDisposer::EmptyFileCreatorDisposer(EmptyFileCreator creator) | ||
{ | ||
previous_result = std::move(EmptyFileCreatorFactory::currentCreator); | ||
EmptyFileCreatorFactory::currentCreator = std::move(creator); | ||
} | ||
|
||
EmptyFileCreatorDisposer::~EmptyFileCreatorDisposer() | ||
{ | ||
EmptyFileCreatorFactory::currentCreator = std::move(previous_result); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include "ApprovalTests/utilities/Macros.h" | ||
#include "EmptyFileCreatorFactory.h" | ||
|
||
namespace ApprovalTests | ||
{ | ||
class APPROVAL_TESTS_NO_DISCARD EmptyFileCreatorDisposer | ||
{ | ||
private: | ||
EmptyFileCreator previous_result; | ||
|
||
public: | ||
explicit EmptyFileCreatorDisposer(EmptyFileCreator creator); | ||
EmptyFileCreatorDisposer(const EmptyFileCreatorDisposer&) = default; | ||
|
||
~EmptyFileCreatorDisposer(); | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "ApprovalTests/writers/StringWriter.h" | ||
#include "EmptyFileCreatorFactory.h" | ||
namespace ApprovalTests | ||
{ | ||
|
||
void EmptyFileCreatorFactory::defaultCreator(std::string fullFilePath) | ||
{ | ||
StringWriter s("", ""); | ||
s.write(fullFilePath); | ||
} | ||
|
||
EmptyFileCreator EmptyFileCreatorFactory::currentCreator = | ||
EmptyFileCreatorFactory::defaultCreator; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
#include <functional> | ||
|
||
namespace ApprovalTests | ||
{ | ||
using EmptyFileCreator = std::function<void(std::string)>; | ||
|
||
class EmptyFileCreatorFactory | ||
{ | ||
public: | ||
static void defaultCreator(std::string fullFilePath); | ||
static EmptyFileCreator currentCreator; | ||
}; | ||
} |
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
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