diff options
Diffstat (limited to 'vendor/bandit/specs/reporters')
-rw-r--r-- | vendor/bandit/specs/reporters/colorizer.spec.cpp | 45 | ||||
-rw-r--r-- | vendor/bandit/specs/reporters/dots_reporter.spec.cpp | 202 | ||||
-rw-r--r-- | vendor/bandit/specs/reporters/single_line_reporter.spec.cpp | 201 | ||||
-rw-r--r-- | vendor/bandit/specs/reporters/xunit_reporter.spec.cpp | 161 |
4 files changed, 609 insertions, 0 deletions
diff --git a/vendor/bandit/specs/reporters/colorizer.spec.cpp b/vendor/bandit/specs/reporters/colorizer.spec.cpp new file mode 100644 index 00000000..7708ec81 --- /dev/null +++ b/vendor/bandit/specs/reporters/colorizer.spec.cpp @@ -0,0 +1,45 @@ +#ifndef _WIN32 +#include <specs/specs.h> + +go_bandit([](){ + + describe("colorizer: ", [&](){ + + describe("colors enabled", [&](){ + bandit::detail::colorizer colorizer; + + it("can set color to green", [&](){ + AssertThat(colorizer.green(), Equals("\033[1;32m")); + }); + + it("set color to red", [&](){ + AssertThat(colorizer.red(), Equals("\033[1;31m")); + }); + it("resets color", [&](){ + AssertThat(colorizer.reset(), Equals("\033[0m")); + }); + + }); + + describe("colors disabled", [&](){ + + bandit::detail::colorizer colorizer(false); + + it("ignores setting color to green", [&](){ + AssertThat(colorizer.green(), Equals("")); + }); + + it("ignores setting color to red", [&](){ + AssertThat(colorizer.red(), Equals("")); + }); + + it("ignores resetting colors", [&](){ + AssertThat(colorizer.reset(), Equals("")); + }); + + }); + + }); + +}); +#endif
\ No newline at end of file diff --git a/vendor/bandit/specs/reporters/dots_reporter.spec.cpp b/vendor/bandit/specs/reporters/dots_reporter.spec.cpp new file mode 100644 index 00000000..f06c8d77 --- /dev/null +++ b/vendor/bandit/specs/reporters/dots_reporter.spec.cpp @@ -0,0 +1,202 @@ +#include <specs/specs.h> +namespace bd = bandit::detail; + +go_bandit([](){ + + describe("dots_reporter:", [&](){ + std::unique_ptr<std::stringstream> stm; + std::unique_ptr<bd::dots_reporter> reporter; + bd::default_failure_formatter formatter; + bd::colorizer colorizer(false); + + before_each([&](){ + stm = std::unique_ptr<std::stringstream>(new std::stringstream()); + reporter = std::unique_ptr<bd::dots_reporter>( + new bd::dots_reporter(*stm, formatter, colorizer)); + }); + + auto output = [&](){ return stm->str(); }; + + describe("an empty test run", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->test_run_complete(); + }); + + it("reports no tests where run", [&](){ + AssertThat(output(), Equals("\nCould not find any tests.\n")); + }); + + it("is not considered successful", [&](){ + AssertThat(reporter->did_we_pass(), Equals(false)); + }); + + }); + + describe("a successful test run", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + reporter->it_starting("my test"); + reporter->it_succeeded("my test"); + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("reports a successful test run", [&](){ + AssertThat(output(), Contains("Success!")); + AssertThat(output(), EndsWith("Test run complete. 1 tests run. 1 succeeded.\n")); + }); + + it("displays a dot for the successful test", [&](){ + AssertThat(output(), StartsWith(".")); + }); + + it("reports a successful test run", [&](){ + AssertThat(reporter->did_we_pass(), Equals(true)); + }); + }); + + describe("a failing test run", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + reporter->it_starting("my test"); + + bd::assertion_exception exception("assertion failed!", "some_file", 123); + reporter->it_failed("my test", exception); + + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("reports a failing test run in summary", [&](){ + AssertThat(output(), EndsWith("Test run complete. 1 tests run. 0 succeeded. 1 failed.\n")); + }); + + it("reports the failed assertion", [&](){ + AssertThat(output(), Contains("my context my test:\nsome_file:123: assertion failed!")); + }); + + it("only reports assertion failure once", [&](){ + AssertThat(output(), Has().Exactly(1).EndingWith("assertion failed!")); + }); + + it("reports an 'F' for the failed assertion", [&](){ + AssertThat(output(), StartsWith("F")); + }); + + it("reports a failed test run", [&](){ + AssertThat(reporter->did_we_pass(), Equals(false)); + }); + }); + + describe("a test run with a non assertion_exception thrown", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + reporter->it_starting("my test"); + + reporter->it_unknown_error("my test"); + + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("reports an 'E' for the failed test", [&](){ + AssertThat(output(), StartsWith("E")); + }); + + it("reports the failed test", [&](){ + AssertThat(output(), Contains("my context my test:\nUnknown exception")) + }); + + }); + + describe("a failing test run with nested contexts", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + reporter->context_starting("a nested context"); + reporter->it_starting("my test"); + + bd::assertion_exception exception("assertion failed!", "some_file", 123); + reporter->it_failed("my test", exception); + + reporter->context_ended("a nested context"); + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("reports a failing test run in summary", [&](){ + AssertThat(output(), EndsWith("Test run complete. 1 tests run. 0 succeeded. 1 failed.\n")); + }); + + it("reports the failed assertion", [&](){ + AssertThat(output(), Contains("my context a nested context my test:\nsome_file:123: assertion failed!")); + }); + + it("reports an 'F' for the failed assertion", [&](){ + AssertThat(output(), StartsWith("F")); + }); + + it("reports a failed test run", [&](){ + AssertThat(reporter->did_we_pass(), Equals(false)); + }); + + }); + + describe("a context with test run errors", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + + bd::test_run_error error("we dun goofed!"); + reporter->test_run_error("my context", error); + + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("reports that the context has failed", [&](){ + AssertThat(output(), Contains("Failed to run \"my context\": error \"we dun goofed!\"")); + }); + + it("reports test run errors in summary", [&](){ + AssertThat(output(), EndsWith("Test run complete. 0 tests run. 0 succeeded. 1 test run errors.\n")) + }); + + it("reports a failed test run", [&](){ + AssertThat(reporter->did_we_pass(), Equals(false)); + }); + }); + + describe("a context with a skipped test", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + + reporter->it_starting("my test"); + reporter->it_succeeded("my test"); + reporter->it_skip("my skipped test"); + + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("reports that there is one skipped test in the summary", [&](){ + AssertThat(output(), EndsWith("Test run complete. 1 tests run. 1 succeeded. 1 skipped.\n")); + }); + + }); + }); + + +}); diff --git a/vendor/bandit/specs/reporters/single_line_reporter.spec.cpp b/vendor/bandit/specs/reporters/single_line_reporter.spec.cpp new file mode 100644 index 00000000..ef7b5206 --- /dev/null +++ b/vendor/bandit/specs/reporters/single_line_reporter.spec.cpp @@ -0,0 +1,201 @@ +#include <specs/specs.h> +namespace bd = bandit::detail; + +go_bandit([](){ + + describe("single line reporter", [&](){ + std::unique_ptr<std::stringstream> stm; + std::unique_ptr<bd::single_line_reporter> reporter; + bd::default_failure_formatter formatter; + bd::colorizer colorizer(false); + + before_each([&](){ + stm = std::unique_ptr<std::stringstream>(new std::stringstream()); + reporter = std::unique_ptr<bd::single_line_reporter>( + new bd::single_line_reporter(*stm, formatter, colorizer)); + }); + + auto output = [&](){ return stm->str(); }; + + describe("an empty test run", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->test_run_complete(); + }); + + it("reports that no tests were run", [&](){ + AssertThat(output(), Equals("\nCould not find any tests.\n")); + }); + + it("is not considered successful", [&](){ + AssertThat(reporter->did_we_pass(), Equals(false)); + }); + }); + + describe("a successful test run", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + reporter->it_starting("my test"); + reporter->it_succeeded("my test"); + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("reports a successful test run", [&](){ + AssertThat(output(), EndsWith("Test run complete. 1 tests run. 1 succeeded.\n")); + }); + + it("displays progress for the test", [&](){ + AssertThat(output(), StartsWith("\rExecuted 0 tests." + "\rExecuted 1 tests.")); + }); + + it("reports a successful test run", [&](){ + AssertThat(reporter->did_we_pass(), Equals(true)); + }); + }); + + describe("a failing test run", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + reporter->it_starting("my test"); + + bd::assertion_exception exception("assertion failed!", "some_file", 123); + reporter->it_failed("my test", exception); + + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("reports a failing test run in summary", [&](){ + AssertThat(output(), EndsWith("Test run complete. 1 tests run. 0 succeeded. 1 failed.\n")); + }); + + it("reports the failed assertion", [&](){ + AssertThat(output(), Contains("my context my test:\nsome_file:123: assertion failed!")); + }); + + it("reports failing test in progress", [&](){ + AssertThat(output(), StartsWith("\rExecuted 0 tests." + "\rExecuted 1 tests. 0 succeeded. 1 failed.")); + }); + + it("reports a failed test run", [&](){ + AssertThat(reporter->did_we_pass(), Equals(false)); + }); + }); + + describe("a test run with a non assertion_exception thrown", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + reporter->it_starting("my test"); + + reporter->it_unknown_error("my test"); + + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("reports failing test in progress", [&](){ + AssertThat(output(), StartsWith("\rExecuted 0 tests." + "\rExecuted 1 tests. 0 succeeded. 1 failed.")); + }); + + it("reports the failed test", [&](){ + AssertThat(output(), Contains("my context my test:\nUnknown exception")) + }); + + }); + + describe("a failing test run with nested contexts", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + reporter->context_starting("a nested context"); + reporter->it_starting("my test"); + + bd::assertion_exception exception("assertion failed!", "some_file", 123); + reporter->it_failed("my test", exception); + + reporter->context_ended("a nested context"); + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("reports a failing test run in summary", [&](){ + AssertThat(output(), EndsWith("Test run complete. 1 tests run. 0 succeeded. 1 failed.\n")); + }); + + it("reports the failed assertion", [&](){ + AssertThat(output(), Contains("my context a nested context my test:\nsome_file:123: assertion failed!")); + }); + + it("displays a failed test in progress report", [&](){ + AssertThat(output(), StartsWith("\rExecuted 0 tests." + "\rExecuted 1 tests. 0 succeeded. 1 failed.")); + }); + + it("reports a failed test run", [&](){ + AssertThat(reporter->did_we_pass(), Equals(false)); + }); + + }); + + describe("a context with test run errors", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + + bd::test_run_error error("we dun goofed!"); + reporter->test_run_error("my context", error); + + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("reports that the context has failed", [&](){ + AssertThat(output(), Contains("Failed to run \"my context\": error \"we dun goofed!\"")); + }); + + it("reports test run errors in summary", [&](){ + AssertThat(output(), EndsWith("Test run complete. 0 tests run. 0 succeeded. 1 test run errors.\n")) + }); + + it("reports a failed test run", [&](){ + AssertThat(reporter->did_we_pass(), Equals(false)); + }); + }); + + describe("a context with a skipped test", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + + reporter->it_starting("my test"); + reporter->it_succeeded("my test"); + reporter->it_skip("my skipped test"); + + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("reports that there is one skipped test in the summary", [&](){ + AssertThat(output(), EndsWith("Test run complete. 1 tests run. 1 succeeded. 1 skipped.\n")); + }); + + }); + + + }); + +}); diff --git a/vendor/bandit/specs/reporters/xunit_reporter.spec.cpp b/vendor/bandit/specs/reporters/xunit_reporter.spec.cpp new file mode 100644 index 00000000..07f0c3b7 --- /dev/null +++ b/vendor/bandit/specs/reporters/xunit_reporter.spec.cpp @@ -0,0 +1,161 @@ +#include <specs/specs.h> +namespace bd = bandit::detail; + +go_bandit([](){ + + describe("xunit_reporter:", [&](){ + std::unique_ptr<std::stringstream> stm; + bd::default_failure_formatter formatter; + std::unique_ptr<bd::xunit_reporter> reporter; + + auto output = [&](){ return stm->str(); }; + + before_each([&](){ + stm = std::unique_ptr<std::stringstream>(new std::stringstream()); + reporter = std::unique_ptr<bd::xunit_reporter>(new bd::xunit_reporter(*stm, formatter)); + }); + + describe("an empty test run", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->test_run_complete(); + }); + + it("adds a header to the output", [&](){ + AssertThat(output(), StartsWith("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")); + }); + + it("outputs an empty test report", [&](){ + AssertThat(output(), Contains( + "<testsuite name=\"bandit\" tests=\"0\" errors=\"0\" failures=\"0\">\n" + "</testsuite>\n")); + }); + + }); + + describe("a test run with one, successful, test", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + reporter->it_starting("my test"); + reporter->it_succeeded("my test"); + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("outputs info about the successful test", [&](){ + AssertThat(output(), Contains( + "<testsuite name=\"bandit\" tests=\"1\" errors=\"0\" failures=\"0\">\n" + "\t<testcase classname=\"my context\" name=\"my test\" time=\"0\">\n" + "\t</testcase>\n" + "</testsuite>\n")); + }); + }); + + describe("a test run with one, failing test", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + reporter->it_starting("my test"); + + bd::assertion_exception exception("assertion failed!", "some_file", 123); + reporter->it_failed("my test", exception); + + reporter->context_ended("my context"); + reporter->test_run_complete(); + + }); + + it("outputs the failing test", [&](){ + AssertThat(output(), Contains( + "<testsuite name=\"bandit\" tests=\"1\" errors=\"0\" failures=\"1\">\n" + "\t<testcase classname=\"my context\" name=\"my test\" time=\"0\">\n" + "\t\t<failure message=\"some_file:123: assertion failed!\" />\n" + "\t</testcase>\n" + "</testsuite>\n")); + }); + + }); + + describe("a test run with one test with an unknown error", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + reporter->it_starting("my test"); + + reporter->it_unknown_error("my test"); + + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("outputs the erroneous test", [&](){ + AssertThat(output(), Contains( + "<testsuite name=\"bandit\" tests=\"1\" errors=\"0\" failures=\"1\">\n" + "\t<testcase classname=\"my context\" name=\"my test\" time=\"0\">\n" + "\t\t<failure message=\"Unknown exception\" />\n" + "\t</testcase>\n" + "</testsuite>\n")); + }); + + }); + + describe("a test run with one test failing with characters that need escaping", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context & < > \\ \""); + reporter->it_starting("my test & < > \\ \""); + + bd::assertion_exception exception("assertion failed & < > \\ \"", "some_file", 123); + reporter->it_failed("my test & < > \\ \"", exception); + + reporter->context_ended("my context & < > \\ \""); + reporter->test_run_complete(); + }); + + it("outputs the escaped characters", [&](){ + AssertThat(output(), Contains( + "<testsuite name=\"bandit\" tests=\"1\" errors=\"0\" failures=\"1\">\n" + "\t<testcase classname=\"my context & < > ' "\" name=\"my test & < > ' "\" time=\"0\">\n" + "\t\t<failure message=\"some_file:123: assertion failed & < > ' "\" />\n" + "\t</testcase>\n" + "</testsuite>\n")); + }); + + }); + + describe("a context with a skipped test", [&](){ + + before_each([&](){ + reporter->test_run_starting(); + reporter->context_starting("my context"); + + reporter->it_starting("my test"); + reporter->it_succeeded("my test"); + reporter->it_skip("my skipped test"); + + reporter->context_ended("my context"); + reporter->test_run_complete(); + }); + + it("outputs info about the skipped test", [&](){ + AssertThat(output(), Contains( + "<testsuite name=\"bandit\" tests=\"1\" errors=\"0\" failures=\"0\" skipped=\"1\">\n" + "\t<testcase classname=\"my context\" name=\"my test\" time=\"0\">\n" + "\t</testcase>\n" + "\t<testcase classname=\"my context\" name=\"my skipped test\" time=\"0\">\n" + "\t\t<skipped />\n" + "\t</testcase>\n" + "</testsuite>\n")); + }); + + }); + + }); + +}); |