<commit_before>#ifndef TEST_CORE_TESTS_HPP
#define TEST_CORE_TESTS_HPP


#include <stdexcept>

#include <test/core/ScopedTest.hpp>
#include <test/core/utils/TypeInfo.hpp>


#define TEST_REPORT_SUCCESS(Message_) \
		::test::ScopedTest::GetCurrentContext().TestSucceeded(TEST_LOCATION, Message_)

#define TEST_REPORT_ERROR(Message_) \
		::test::ScopedTest::GetCurrentContext().TestFailed(TEST_LOCATION, Message_)


#define TEST_THROWS_ANYTHING(...) \
		do { \
			try { __VA_ARGS__; TEST_REPORT_ERROR(std::string("Expected this code to throw: '" #__VA_ARGS__ "'")); } \
			catch (...) \
			{ TEST_REPORT_SUCCESS("'" #__VA_ARGS__ "' throws"); } \
		} while (false)

#define TEST_THROWS(ExceptionType_, ...) \
		do { \
			try { __VA_ARGS__; TEST_REPORT_ERROR(std::string("Expected this code to throw: '" #__VA_ARGS__ "'")); } \
			catch (const ExceptionType_& ex) \
			{ TEST_REPORT_SUCCESS("'" #__VA_ARGS__ "' throws " #ExceptionType_); } \
			catch (const std::exception& ex) \
			{ TEST_REPORT_ERROR(std::string("Expected this code to throw " #ExceptionType_ ": '" #__VA_ARGS__ "', got ") + ::test::TypeInfo(typeid(ex)).ToString() + (": ") + ex.what()); } \
			catch (...) \
			{ TEST_REPORT_ERROR(std::string("Expected this code to throw " #ExceptionType_ ": '" #__VA_ARGS__ "', got unknown exception")); } \
		} while (false)

#define TEST_DOES_NOT_THROW_INTERNAL(...) \
		do { \
			try { __VA_ARGS__; } \
			catch (const std::exception& ex) \
			{ TEST_REPORT_ERROR(std::string("Expected this code not to throw: '" #__VA_ARGS__ "', got exception: ") + ex.what()); } \
			catch (...) \
			{ TEST_REPORT_ERROR(std::string("Expected this code not to throw: '" #__VA_ARGS__ "', got unknown exception")); } \
		} while (false)

#define TEST_THROWS_NOTHING(...) \
		do { \
			TEST_DOES_NOT_THROW_INTERNAL(__VA_ARGS__; TEST_REPORT_SUCCESS(#__VA_ARGS__)); \
		} while (false)

#define TEST_EQUALS(Val_, ...) \
		TEST_DOES_NOT_THROW_INTERNAL({ \
				if (!(Val_ == __VA_ARGS__)) \
					TEST_REPORT_ERROR(#Val_ " != " #__VA_ARGS__); \<commit_msg>Fixed test framework output<commit_after>#ifndef TEST_CORE_TESTS_HPP
#define TEST_CORE_TESTS_HPP


#include <stdexcept>

#include <test/core/ScopedTest.hpp>
#include <test/core/utils/TypeInfo.hpp>


#define TEST_REPORT_SUCCESS(Message_) \
		::test::ScopedTest::GetCurrentContext().TestSucceeded(TEST_LOCATION, Message_)

#define TEST_REPORT_ERROR(Message_) \
		::test::ScopedTest::GetCurrentContext().TestFailed(TEST_LOCATION, Message_)


#define TEST_THROWS_ANYTHING(...) \
		do { \
			try { __VA_ARGS__; TEST_REPORT_ERROR(std::string("Expected this code to throw: '" #__VA_ARGS__ "'")); } \
			catch (...) \
			{ TEST_REPORT_SUCCESS("'" #__VA_ARGS__ "' throws"); } \
		} while (false)

#define TEST_THROWS(ExceptionType_, ...) \
		do { \
			try { __VA_ARGS__; TEST_REPORT_ERROR(std::string("Expected this code to throw: '" #__VA_ARGS__ "'")); } \
			catch (const ExceptionType_& ex) \
			{ TEST_REPORT_SUCCESS("'" #__VA_ARGS__ "' throws " #ExceptionType_); } \
			catch (const std::exception& ex) \
			{ TEST_REPORT_ERROR(std::string("Expected this code to throw " #ExceptionType_ ": '" #__VA_ARGS__ "', got ") + ::test::TypeInfo(typeid(ex)).ToString() + (": ") + ex.what()); } \
			catch (...) \
			{ TEST_REPORT_ERROR(std::string("Expected this code to throw " #ExceptionType_ ": '" #__VA_ARGS__ "', got unknown exception")); } \
		} while (false)

#define TEST_DOES_NOT_THROW_INTERNAL(Str_, ...) \
		do { \
			try { __VA_ARGS__; } \
			catch (const std::exception& ex) \
			{ TEST_REPORT_ERROR(std::string("Expected this code not to throw: '" Str_ "', got exception: ") + ex.what()); } \
			catch (...) \
			{ TEST_REPORT_ERROR(std::string("Expected this code not to throw: '" Str_ "', got unknown exception")); } \
		} while (false)

#define TEST_THROWS_NOTHING(...) \
		do { \
			TEST_DOES_NOT_THROW_INTERNAL(#__VA_ARGS__, __VA_ARGS__; TEST_REPORT_SUCCESS(#__VA_ARGS__)); \
		} while (false)

#define TEST_EQUALS(Val_, ...) \
		TEST_DOES_NOT_THROW_INTERNAL("TEST_EQUALS(" #Val_ ", " #__VA_ARGS__ ")", { \
				if (!(Val_ == __VA_ARGS__)) \
					TEST_REPORT_ERROR(#Val_ " != " #__VA_ARGS__); \
{'fraction_non_alphanumeric': 0.17295597484276728, 'fraction_numerical': 0.0, 'mean_word_length': 4.412303664921466, 'pattern_counts': {'":': 6, '<': 9, '<?xml version=': 0, '>': 9, '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': '5131967', 'n_tokens_mistral': 1589, 'n_tokens_neox': 1474, 'n_words': 262}