summaryrefslogtreecommitdiff
path: root/vendor/bandit/specs/fakes
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/bandit/specs/fakes')
-rw-r--r--vendor/bandit/specs/fakes/fake_context.h69
-rw-r--r--vendor/bandit/specs/fakes/fake_reporter.h78
-rw-r--r--vendor/bandit/specs/fakes/fakes.h8
-rw-r--r--vendor/bandit/specs/fakes/logging_fake.h32
4 files changed, 187 insertions, 0 deletions
diff --git a/vendor/bandit/specs/fakes/fake_context.h b/vendor/bandit/specs/fakes/fake_context.h
new file mode 100644
index 00000000..e5d1d870
--- /dev/null
+++ b/vendor/bandit/specs/fakes/fake_context.h
@@ -0,0 +1,69 @@
+#ifndef BANDIT_FAKE_CONTEXT_H
+#define BANDIT_FAKE_CONTEXT_H
+
+namespace bandit { namespace fakes {
+
+ struct fake_context : public bandit::detail::context, public bandit::specs::logging_fake
+ {
+ fake_context() : hard_skip_(false), name_("fake_context"),
+ custom_after_each_([](){}), custom_before_each_([](){})
+ {}
+
+ const std::string& name()
+ {
+ log() << "name" << std::endl;
+ return name_;
+ }
+
+ void execution_is_starting()
+ {
+ log() << "execution_is_starting" << std::endl;
+ }
+
+ void register_before_each(detail::voidfunc_t)
+ {
+ log() << "register_before_each" << std::endl;
+ }
+
+ void register_after_each(detail::voidfunc_t)
+ {
+ log() << "register_after_each" << std::endl;
+ }
+
+ void run_before_eaches()
+ {
+ log() << "run_before_eaches" << std::endl;
+ custom_before_each_();
+ }
+
+ void run_after_eaches()
+ {
+ log() << "run_after_eaches" << std::endl;
+ custom_after_each_();
+ }
+
+ bool hard_skip()
+ {
+ log() << "hard_skip: returning " << hard_skip_ << std::endl;
+ return hard_skip_;
+ }
+
+ void with_after_each(detail::voidfunc_t call)
+ {
+ custom_after_each_ = call;
+ }
+
+ void with_before_each(detail::voidfunc_t call)
+ {
+ custom_before_each_ = call;
+ }
+
+ private:
+ bool hard_skip_;
+ std::string name_;
+ detail::voidfunc_t custom_after_each_;
+ detail::voidfunc_t custom_before_each_;
+ };
+}}
+
+#endif
diff --git a/vendor/bandit/specs/fakes/fake_reporter.h b/vendor/bandit/specs/fakes/fake_reporter.h
new file mode 100644
index 00000000..032ed44d
--- /dev/null
+++ b/vendor/bandit/specs/fakes/fake_reporter.h
@@ -0,0 +1,78 @@
+#ifndef BANDIT_SPECS_FAKE_REPORTER_H
+#define BANDIT_SPECS_FAKE_REPORTER_H
+
+namespace bandit { namespace fakes {
+ struct fake_reporter :
+ public bandit::detail::listener,
+ public bandit::specs::logging_fake
+ {
+ fake_reporter() : test_run_status_(true)
+ {}
+
+ void test_run_starting()
+ {
+ log() << "test_run_starting" << std::endl;
+ }
+
+ void test_run_complete()
+ {
+ log() << "test_run_complete" << std::endl;
+ }
+
+ void context_starting(const char* desc)
+ {
+ log() << "context_starting: " << desc << std::endl;
+ }
+
+ void context_ended(const char* desc)
+ {
+ log() << "context_ended: " << desc << std::endl;
+ }
+
+ void test_run_error(const char* desc, const struct bandit::detail::test_run_error& err)
+ {
+ log() << "test_run_error: " << desc << " (" << strip_newline(err.what()) << ")" << std::endl;
+ }
+
+ void it_starting(const char* desc)
+ {
+ log() << "it_starting: " << desc << std::endl;
+ }
+
+ void it_succeeded(const char* desc)
+ {
+ log() << "it_succeeded: " << desc << std::endl;
+ }
+
+ void it_failed(const char* desc, const bandit::detail::assertion_exception& ex)
+ {
+ log() << "it_failed: " << desc << " (" << strip_newline(ex.what()) << ")" << std::endl;
+ }
+
+ void it_unknown_error(const char* desc)
+ {
+ log() << "it_unknown_error: " << desc << std::endl;
+ }
+
+ void it_skip(const char* desc)
+ {
+ log() << "it_skip: " << desc << std::endl;
+ }
+
+ bool did_we_pass() const
+ {
+ return test_run_status_;
+ }
+
+ void set_test_run_status(bool status)
+ {
+ test_run_status_ = status;
+ }
+
+ private:
+ bool test_run_status_;
+ };
+ typedef std::unique_ptr<fake_reporter> fake_reporter_ptr;
+}}
+
+#endif
diff --git a/vendor/bandit/specs/fakes/fakes.h b/vendor/bandit/specs/fakes/fakes.h
new file mode 100644
index 00000000..a48517f6
--- /dev/null
+++ b/vendor/bandit/specs/fakes/fakes.h
@@ -0,0 +1,8 @@
+#ifndef BANDIT_SPECS_FAKES_H
+#define BANDIT_SPECS_FAKES_H
+
+#include <specs/fakes/logging_fake.h>
+#include <specs/fakes/fake_reporter.h>
+#include <specs/fakes/fake_context.h>
+
+#endif
diff --git a/vendor/bandit/specs/fakes/logging_fake.h b/vendor/bandit/specs/fakes/logging_fake.h
new file mode 100644
index 00000000..ac1d3dd0
--- /dev/null
+++ b/vendor/bandit/specs/fakes/logging_fake.h
@@ -0,0 +1,32 @@
+#ifndef BANDIT_SPECS_LOGGING_FAKE_H
+#define BANDIT_SPECS_LOGGING_FAKE_H
+#include <sstream>
+
+namespace bandit { namespace specs {
+
+ struct logging_fake
+ {
+ std::ostream& log()
+ {
+ return logstm_;
+ }
+
+ std::string strip_newline(const char* val)
+ {
+ std::string no_newline = val;
+ std::transform(no_newline.begin(), no_newline.end(), no_newline.begin(), [](const char& c) {
+ return (c == '\n' || c == '\r') ? ' ' : c;
+ });
+ return no_newline;
+ }
+
+ std::string call_log()
+ {
+ return logstm_.str();
+ }
+
+ private:
+ std::stringstream logstm_;
+ };
+}}
+#endif