<commit_before>#include <UnitTest11.hpp>
#include <UnitTest11/TestFixtureRunner.hpp>

namespace ut11
{
	namespace Utility
	{
		template<> struct ParseToString<ut11::Output*>
		{
			inline std::string operator()(ut11::Output* value) const
			{
				std::stringstream stream;
				stream << value;
				return stream.str();
			}
		};
	}
}

namespace
{
	class FakeOutput : public ut11::Output
	{
	public:
		virtual ~FakeOutput() { }

		MockAction(Begin)
		MockAction(Finish, std::size_t, std::size_t)

		MockAction(BeginFixture, std::string)
		MockAction(EndFixture, std::string)

		MockAction(BeginGiven, std::string)
		MockAction(EndGiven, std::string)

		MockAction(BeginWhen, std::string)
		MockAction(EndWhen, std::string)

		MockAction(BeginThen, std::string)
		MockAction(EndThen, std::string)

		MockAction(BeginFinally, std::string)
		MockAction(EndFinally, std::string)

		MockAction(OnError, std::size_t, std::string, std::string)
		MockAction(OnUnknownError)

		ut11::Mock<void (std::exception)> mockOnError1;
		virtual void OnError(const std::exception& ex) { mockOnError1(ex); }
	};

	class FakeTestFixture : public ut11::TestFixtureAbstract
	{
	private:
		ut11::TestFixtureResults m_runResults;

	public:
		ut11::Output* RunOutputUsed;

		FakeTestFixture(ut11::TestFixtureResults runResults)
			: m_runResults(runResults), RunOutputUsed(nullptr)
		{
		}

        MockAction(Given, std::string, std::function<void(void)>);
        MockAction(When, std::string, std::function<void(void)>);
        MockAction(Then, std::string, std::function<void(void)>);
        MockAction(Finally, std::string, std::function<void(void)>);

        MockFunction(std::string, GetName);

        virtual ut11::TestFixtureResults Run(ut11::Output& output)
        {
        	RunOutputUsed = &output;
        	return m_runResults;
        }
	};
}

class TestFixtureRunnerTests : public ut11::TestFixture
{
private:
    ut11::TestFixtureRunner m_runner;
    FakeOutput m_output;

    int m_expectedResult;
    int m_result;

public:
    virtual void Run()
    {
        Given("a TestFixtureRunner with added Fixture with failing tests", [&]() {
            m_runner = ut11::TestFixtureRunner();

            ut11::TestFixtureResults fixtureResults;
            fixtureResults.ran = 5;
            fixtureResults.succeeded = 3;
            m_expectedResult = 2;

            FakeTestFixture* fixture = new FakeTestFixture(fixtureResults);
            fixture->mockGetName.SetReturn("name");

            m_runner.AddFixture(std::unique_ptr<ut11::TestFixtureAbstract>(fixture));

        });
        When("running the TestFixtureRunner", [&]() {
            m_result = m_runner.Run(m_output);
        });
        Then("the number of failing tests is returned", [&]() {
            AssertThat(m_result, ut11::Is::EqualTo(m_expectedResult));
        });
    }
};
DeclareFixture(TestFixtureRunnerTests);

class TestFixtureRunnerMultipleFixturesTests : public ut11::TestFixture
{
private:
	ut11::TestFixtureRunner m_runner;
    FakeOutput m_output;
    FakeTestFixture* m_fixtureOne;
    FakeTestFixture* m_fixtureTwo;

public:
	virtual void Run()
	{
		Given("a TestFixtureRunner where two fixtures with the same names are added", [&]() {
			m_runner = ut11::TestFixtureRunner();
			m_output = FakeOutput();

			m_fixtureOne = new FakeTestFixture(ut11::TestFixtureResults());
			m_fixtureTwo = new FakeTestFixture(ut11::TestFixtureResults());

			m_fixtureOne->mockGetName.SetReturn("name");
			m_fixtureTwo->mockGetName.SetReturn("name");

			m_runner.AddFixture(std::unique_ptr<ut11::TestFixtureAbstract>(m_fixtureOne));
			m_runner.AddFixture(std::unique_ptr<ut11::TestFixtureAbstract>(m_fixtureTwo));
		});
		When("Running the test fixture runner", [&]() {
			m_runner.Run(m_output);
		});
		Then("only the first test fixture is ran", [&]() {
			AssertThat(m_fixtureOne->RunOutputUsed, ut11::Is::Not::Null);
			AssertThat(m_fixtureTwo->RunOutputUsed, ut11::Is::Null);<commit_msg>Minor refactoring to split two asserts into two tests<commit_after>#include <UnitTest11.hpp>
#include <UnitTest11/TestFixtureRunner.hpp>

namespace ut11
{
	namespace Utility
	{
		template<> struct ParseToString<ut11::Output*>
		{
			inline std::string operator()(ut11::Output* value) const
			{
				std::stringstream stream;
				stream << value;
				return stream.str();
			}
		};
	}
}

namespace
{
	class FakeOutput : public ut11::Output
	{
	public:
		virtual ~FakeOutput() { }

		MockAction(Begin)
		MockAction(Finish, std::size_t, std::size_t)

		MockAction(BeginFixture, std::string)
		MockAction(EndFixture, std::string)

		MockAction(BeginGiven, std::string)
		MockAction(EndGiven, std::string)

		MockAction(BeginWhen, std::string)
		MockAction(EndWhen, std::string)

		MockAction(BeginThen, std::string)
		MockAction(EndThen, std::string)

		MockAction(BeginFinally, std::string)
		MockAction(EndFinally, std::string)

		MockAction(OnError, std::size_t, std::string, std::string)
		MockAction(OnUnknownError)

		ut11::Mock<void (std::exception)> mockOnError1;
		virtual void OnError(const std::exception& ex) { mockOnError1(ex); }
	};

	class FakeTestFixture : public ut11::TestFixtureAbstract
	{
	private:
		ut11::TestFixtureResults m_runResults;

	public:
		ut11::Output* RunOutputUsed;

		FakeTestFixture(ut11::TestFixtureResults runResults)
			: m_runResults(runResults), RunOutputUsed(nullptr)
		{
		}

        MockAction(Given, std::string, std::function<void(void)>);
        MockAction(When, std::string, std::function<void(void)>);
        MockAction(Then, std::string, std::function<void(void)>);
        MockAction(Finally, std::string, std::function<void(void)>);

        MockFunction(std::string, GetName);

        virtual ut11::TestFixtureResults Run(ut11::Output& output)
        {
        	RunOutputUsed = &output;
        	return m_runResults;
        }
	};
}

class TestFixtureRunnerTests : public ut11::TestFixture
{
private:
    ut11::TestFixtureRunner m_runner;
    FakeOutput m_output;

    int m_expectedResult;
    int m_result;

public:
    virtual void Run()
    {
        Given("a TestFixtureRunner with added Fixture with failing tests", [&]() {
            m_runner = ut11::TestFixtureRunner();

            ut11::TestFixtureResults fixtureResults;
            fixtureResults.ran = 5;
            fixtureResults.succeeded = 3;
            m_expectedResult = 2;

            FakeTestFixture* fixture = new FakeTestFixture(fixtureResults);
            fixture->mockGetName.SetReturn(std::string("name"));

            m_runner.AddFixture(std::unique_ptr<ut11::TestFixtureAbstract>(fixture));

        });
        When("running the TestFixtureRunner", [&]() {
            m_result = m_runner.Run(m_output);
        });
        Then("the number of failing tests is returned", [&]() {
            AssertThat(m_result, ut11::Is::EqualTo(m_expectedResult));
        });
    }
};
DeclareFixture(TestFixtureRunnerTests);

class TestFixtureRunnerMultipleFixturesTests : public ut11::TestFixture
{
private:
	ut11::TestFixtureRunner m_runner;
    FakeOutput m_output;
    FakeTestFixture* m_fixtureOne;
    FakeTestFixture* m_fixtureTwo;

public:
	virtual void Run()
	{
		Given("a TestFixtureRunner where two fixtures with the same names are added", [&]() {
			m_runner = ut11::TestFixtureRunner();
			m_output = FakeOutput();

			m_fixtureOne = new FakeTestFixture(ut11::TestFixtureResults());
			m_fixtureTwo = new FakeTestFixture(ut11::TestFixtureResults());

			m_fixtureOne->mockGetName.SetReturn("name");
			m_fixtureTwo->mockGetName.SetReturn("name");

			m_runner.AddFixture(std::unique_ptr<ut11::TestFixtureAbstract>(m_fixtureOne));
			m_runner.AddFixture(std::unique_ptr<ut11::TestFixtureAbstract>(m_fixtureTwo));
		});
		When("Running the test fixture runner", [&]() {
			m_runner.Run(m_output);
		});
		Then("the first test fixture is ran", [&]() {
			AssertThat(m_fixtureOne->RunOutputUsed, ut11::Is::Not::Null);
		});
		Then("the second test fixture is not ran", [&](){
			AssertThat(m_fixtureTwo->RunOutputUsed, ut11::Is::Null);
{'fraction_non_alphanumeric': 0.12982325118247448, 'fraction_numerical': 0.015185461787403536, 'mean_word_length': 4.289664252797893, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '672060', 'n_tokens_mistral': 2863, 'n_tokens_neox': 2591, 'n_words': 451}