From aa7c021962f529f3ed2f482fd6f02e5497532a8a Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Wed, 7 Jun 2023 16:41:32 +0200 Subject: project: begin restructuring --- test/include/arithmetic_suite.hpp | 11 - test/include/conversion_suite.hpp | 11 - test/include/derivation_clause_suite.hpp | 11 - test/include/equality_comparison_suite.hpp | 11 - test/include/hash_suite.hpp | 11 - test/include/io_operators_suite.hpp | 11 - test/include/iterable_suite.hpp | 11 - test/include/kawaii.hpp | 143 ------ test/include/new_type_constructor_suite.hpp | 11 - test/include/relational_operators_suite.hpp | 11 - test/src/arithmetic_suite.cpp | 330 ------------- test/src/conversion_suite.cpp | 201 -------- test/src/derivation_clause_suite.cpp | 312 ------------ test/src/driver.cpp | 101 ---- test/src/equality_comparison_suite.cpp | 188 -------- test/src/hash_suite.cpp | 69 --- test/src/io_operators_suite.cpp | 121 ----- test/src/iterable_suite.cpp | 719 ---------------------------- test/src/new_type_constructor_suite.cpp | 91 ---- test/src/relational_operators_suite.cpp | 321 ------------- 20 files changed, 2695 deletions(-) delete mode 100644 test/include/arithmetic_suite.hpp delete mode 100644 test/include/conversion_suite.hpp delete mode 100644 test/include/derivation_clause_suite.hpp delete mode 100644 test/include/equality_comparison_suite.hpp delete mode 100644 test/include/hash_suite.hpp delete mode 100644 test/include/io_operators_suite.hpp delete mode 100644 test/include/iterable_suite.hpp delete mode 100644 test/include/kawaii.hpp delete mode 100644 test/include/new_type_constructor_suite.hpp delete mode 100644 test/include/relational_operators_suite.hpp delete mode 100644 test/src/arithmetic_suite.cpp delete mode 100644 test/src/conversion_suite.cpp delete mode 100644 test/src/derivation_clause_suite.cpp delete mode 100644 test/src/driver.cpp delete mode 100644 test/src/equality_comparison_suite.cpp delete mode 100644 test/src/hash_suite.cpp delete mode 100644 test/src/io_operators_suite.cpp delete mode 100644 test/src/iterable_suite.cpp delete mode 100644 test/src/new_type_constructor_suite.cpp delete mode 100644 test/src/relational_operators_suite.cpp (limited to 'test') diff --git a/test/include/arithmetic_suite.hpp b/test/include/arithmetic_suite.hpp deleted file mode 100644 index 1eb4af8..0000000 --- a/test/include/arithmetic_suite.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef NEWTYPE_TEST_ARITHMETIC_SUITE_HPP -#define NEWTYPE_TEST_ARITHMETIC_SUITE_HPP - -#include - -#include -#include - -auto arithmetic_suite() -> std::pair; - -#endif \ No newline at end of file diff --git a/test/include/conversion_suite.hpp b/test/include/conversion_suite.hpp deleted file mode 100644 index 8b9c337..0000000 --- a/test/include/conversion_suite.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef NEWTYPE_TEST_CONVERSION_SUITE_HPP -#define NEWTYPE_TEST_CONVERSION_SUITE_HPP - -#include - -#include -#include - -auto conversion_suite() -> std::pair; - -#endif \ No newline at end of file diff --git a/test/include/derivation_clause_suite.hpp b/test/include/derivation_clause_suite.hpp deleted file mode 100644 index b5ef5c2..0000000 --- a/test/include/derivation_clause_suite.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef NEWTYPE_TEST_DERIVATION_CLAUSE_SUITE_HPP -#define NEWTYPE_TEST_DERIVATION_CLAUSE_SUITE_HPP - -#include - -#include -#include - -auto derivation_clause_suite() -> std::pair; - -#endif \ No newline at end of file diff --git a/test/include/equality_comparison_suite.hpp b/test/include/equality_comparison_suite.hpp deleted file mode 100644 index 80abbe7..0000000 --- a/test/include/equality_comparison_suite.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef NEWTYPE_TEST_EQUALITY_COMPARISON_SUITE_HPP -#define NEWTYPE_TEST_EQUALITY_COMPARISON_SUITE_HPP - -#include - -#include -#include - -auto equality_comparison_suite() -> std::pair; - -#endif \ No newline at end of file diff --git a/test/include/hash_suite.hpp b/test/include/hash_suite.hpp deleted file mode 100644 index 0ef51bc..0000000 --- a/test/include/hash_suite.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef NEWTYPE_TEST_HASH_SUITE_HPP -#define NEWTYPE_TEST_HASH_SUITE_HPP - -#include - -#include -#include - -auto hash_suite() -> std::pair; - -#endif \ No newline at end of file diff --git a/test/include/io_operators_suite.hpp b/test/include/io_operators_suite.hpp deleted file mode 100644 index c7af2ee..0000000 --- a/test/include/io_operators_suite.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef NEWTYPE_TEST_IO_OPERATORS_SUITE_HPP -#define NEWTYPE_TEST_IO_OPERATORS_SUITE_HPP - -#include - -#include -#include - -auto io_operators_suite() -> std::pair; - -#endif \ No newline at end of file diff --git a/test/include/iterable_suite.hpp b/test/include/iterable_suite.hpp deleted file mode 100644 index c2bbc6e..0000000 --- a/test/include/iterable_suite.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef NEWTYPE_TEST_ITERABLE_SUITE_HPP -#define NEWTYPE_TEST_ITERABLE_SUITE_HPP - -#include - -#include -#include - -auto iterable_suite() -> std::pair; - -#endif \ No newline at end of file diff --git a/test/include/kawaii.hpp b/test/include/kawaii.hpp deleted file mode 100644 index 9084b56..0000000 --- a/test/include/kawaii.hpp +++ /dev/null @@ -1,143 +0,0 @@ -#ifndef NEWTYPE_TEST_KAWAII_HPP -#define NEWTYPE_TEST_KAWAII_HPP - -#include - -#include -#include -#include -#include -#include -#include -#include - -namespace nt::test -{ - - namespace impl - { - auto constexpr prepositions = std::array{"a", "an", "and", "as", "at", "by", "for", "in", "of", "on", "or", "the", "to"}; - auto constexpr keywords = std::array{"noexcept"}; - auto constexpr type_names = std::array{"new_type", "derivation_clause", "unordered_map"}; - - auto inline replace_template_argument_syntax(std::string const & name) -> std::string - { - using namespace std::string_literals; - - auto template_argument_start = find(cbegin(name), cend(name), '<'); - - if (template_argument_start == cend(name)) - { - return name; - } - - auto replaced{""s}; - - copy(cbegin(name), template_argument_start, back_inserter(replaced)); - - replaced += " [ T = "; - - auto template_argument_end = find(template_argument_start, cend(name), '>'); - - copy(template_argument_start + 1, template_argument_end, back_inserter(replaced)); - - return replaced + " ]"; - } - - auto inline is_prefix(std::string const & suspect, std::string const & of) -> bool - { - if (suspect.size() > of.size()) - { - return false; - } - return equal(cbegin(suspect), cend(suspect), cbegin(of)); - } - - auto inline is_type_name_prefix(std::string const & suspect) -> bool - { - return std::any_of(cbegin(type_names), cend(type_names), [&](auto type_name) { return is_prefix(suspect, type_name); }); - } - - auto inline wordify(std::string const & name) - { - using namespace std::string_literals; - using namespace impl; - - auto stream = std::stringstream{name}; - auto output{""s}; - - while (stream) - { - auto current_char = static_cast(stream.get()); - - if (current_char == '_') - { - if (stream.peek() != '_') - { - output += ' '; - } - else - { - output += current_char; - stream.ignore(); - } - } - else if (current_char != EOF) - { - output += current_char; - } - } - - return output; - } - - auto inline titelize(std::string const & name) -> std::string - { - using namespace std::string_literals; - - auto stream = std::istringstream{name}; - auto buffer{""s}; - auto word{""s}; - auto first{false}; - - while (stream >> word && word != "[") - { - auto is_preposition = std::find(cbegin(prepositions), cend(prepositions), word) != cend(prepositions); - auto is_keyword = std::find(cbegin(keywords), cend(keywords), word) != cend(keywords); - auto is_type_name = std::find(cbegin(type_names), cend(type_names), word) != cend(type_names); - if ((!(is_preposition || is_keyword) || buffer.empty()) && !is_type_name) - { - word.front() = std::toupper(word.front()); - } - buffer += (first ? "" : " ") + word; - first = false; - } - - auto rest{""s}; - - if (stream) - { - buffer += " " + word; - std::getline(stream, rest); - } - - return buffer + rest; - } - - } // namespace impl - - auto inline go_full_kawaii(std::string kowai) -> std::string - { - using namespace impl; - - auto template_free = replace_template_argument_syntax(kowai); - auto wordified = wordify(template_free); - - return titelize(wordified); - } - -} // namespace nt::test - -#define KAWAII(name) cute::test((&name), nt::test::go_full_kawaii(#name)) - -#endif \ No newline at end of file diff --git a/test/include/new_type_constructor_suite.hpp b/test/include/new_type_constructor_suite.hpp deleted file mode 100644 index 38c3cba..0000000 --- a/test/include/new_type_constructor_suite.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef NEWTYPE_TEST_NEW_TYPE_SUITE_HPP -#define NEWTYPE_TEST_NEW_TYPE_SUITE_HPP - -#include - -#include -#include - -auto new_type_constructor_suite() -> std::pair; - -#endif \ No newline at end of file diff --git a/test/include/relational_operators_suite.hpp b/test/include/relational_operators_suite.hpp deleted file mode 100644 index 259834b..0000000 --- a/test/include/relational_operators_suite.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef NEWTYPE_TEST_RELATIONAL_OPERATORS_SUITE_HPP -#define NEWTYPE_TEST_RELATIONAL_OPERATORS_SUITE_HPP - -#include - -#include -#include - -auto relational_operators_suite() -> std::pair; - -#endif \ No newline at end of file diff --git a/test/src/arithmetic_suite.cpp b/test/src/arithmetic_suite.cpp deleted file mode 100644 index 0d8cfa8..0000000 --- a/test/src/arithmetic_suite.cpp +++ /dev/null @@ -1,330 +0,0 @@ -#include "arithmetic_suite.hpp" - -#include "kawaii.hpp" -#include "newtype/derivable.hpp" -#include "newtype/deriving.hpp" -#include "newtype/impl/type_traits_extensions.hpp" -#include "newtype/newtype.hpp" - -#include - -#include - -namespace -{ - - struct addable_type - { - auto constexpr operator+(addable_type const &) const -> addable_type - { - return {}; - }; - }; - - struct subtractable_type - { - auto constexpr operator-(subtractable_type const &) const -> subtractable_type - { - return {}; - }; - }; - - struct multipliable_type - { - auto constexpr operator*(multipliable_type const &)const -> multipliable_type - { - return {}; - }; - }; - - struct dividable_type - { - auto constexpr operator/(dividable_type const &) const -> dividable_type - { - return {}; - }; - }; - -} // namespace - -inline namespace addition_tests -{ - - auto a_new__type_not_deriving_arithmetic_is_not_addable_with_instances_of_itself() -> void - { - using type_alias = nt::new_type; - ASSERT(!(nt::impl::is_addable_v)); - } - - auto a_new__type_deriving_arithmetic_is_addable_with_instances_of_itself() -> void - { - using type_alias = nt::new_type; - ASSERT(nt::impl::is_addable_v); - } - - template - auto a_new__type_deriving_arithmetic_is_addable_with_instances_of_itself_if_the_base_type_is_addable() -> void - { - static_assert(nt::impl::is_addable_v, "Sanity Check"); - using type_alias = nt::new_type; - ASSERT_EQUAL(nt::impl::is_addable_v, nt::impl::is_addable_v); - } - - auto addition_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type() -> void - { - using type_alias = nt::new_type; - ASSERT((std::is_same_v() + std::declval())>)); - } - - auto addition_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type() -> void - { - using type_alias = nt::new_type; - auto lhs = type_alias{24}; - auto rhs = type_alias{18}; - ASSERT_EQUAL(24 + 18, (lhs + rhs).decay()); - } - -} // namespace addition_tests - -inline namespace subtraction_tests -{ - - auto a_new__type_not_deriving_arithmetic_is_not_subtractable_with_instances_of_itself() -> void - { - using type_alias = nt::new_type; - ASSERT(!(nt::impl::is_subtractable_v)); - } - - auto a_new__type_deriving_arithmetic_is_subtractable_with_instances_of_itself() -> void - { - using type_alias = nt::new_type; - ASSERT(nt::impl::is_subtractable_v); - } - - template - auto a_new__type_deriving_arithmetic_is_subtractable_with_instances_of_itself_if_the_base_type_is_subtractable() -> void - { - static_assert(nt::impl::is_subtractable_v, "Sanity Check"); - using type_alias = nt::new_type; - ASSERT_EQUAL(nt::impl::is_subtractable_v, nt::impl::is_subtractable_v); - } - - auto subtraction_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type() -> void - { - using type_alias = nt::new_type; - ASSERT((std::is_same_v() - std::declval())>)); - } - - auto subtraction_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type() -> void - { - using type_alias = nt::new_type; - auto lhs = type_alias{24}; - auto rhs = type_alias{18}; - ASSERT_EQUAL(24 - 18, (lhs - rhs).decay()); - } - -} // namespace subtraction_tests - -inline namespace multiplication_tests -{ - - auto a_new__type_not_deriving_arithmetic_is_not_multipliable_with_instances_of_itself() -> void - { - using type_alias = nt::new_type; - ASSERT(!(nt::impl::is_multipliable_v)); - } - - auto a_new__type_deriving_arithmetic_is_multipliable_with_instances_of_itself() -> void - { - using type_alias = nt::new_type; - ASSERT(nt::impl::is_multipliable_v); - } - - template - auto a_new__type_deriving_arithmetic_is_multipliable_with_instances_of_itself_if_the_base_type_is_multipliable() -> void - { - static_assert(nt::impl::is_multipliable_v, "Sanity Check"); - using type_alias = nt::new_type; - ASSERT_EQUAL(nt::impl::is_multipliable_v, nt::impl::is_multipliable_v); - } - - auto multiplication_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type() -> void - { - using type_alias = nt::new_type; - ASSERT((std::is_same_v() * std::declval())>)); - } - - auto multiplication_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type() -> void - { - using type_alias = nt::new_type; - auto lhs = type_alias{24}; - auto rhs = type_alias{18}; - ASSERT_EQUAL(24 * 18, (lhs * rhs).decay()); - } - -} // namespace multiplication_tests - -inline namespace division_tests -{ - - auto a_new__type_not_deriving_arithmetic_is_not_dividable_with_instances_of_itself() -> void - { - using type_alias = nt::new_type; - ASSERT(!(nt::impl::is_dividable_v)); - } - - auto a_new__type_deriving_arithmetic_is_dividable_with_instances_of_itself() -> void - { - using type_alias = nt::new_type; - ASSERT(nt::impl::is_dividable_v); - } - - template - auto a_new__type_deriving_arithmetic_is_dividable_with_instances_of_itself_if_the_base_type_is_dividable() -> void - { - static_assert(nt::impl::is_dividable_v, "Sanity Check"); - using type_alias = nt::new_type; - ASSERT_EQUAL(nt::impl::is_dividable_v, nt::impl::is_dividable_v); - } - - auto division_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type() -> void - { - using type_alias = nt::new_type; - ASSERT((std::is_same_v() / std::declval())>)); - } - - auto division_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type() -> void - { - using type_alias = nt::new_type; - auto lhs = type_alias{24}; - auto rhs = type_alias{2}; - ASSERT_EQUAL(24 / 2, (lhs / rhs).decay()); - } - -} // namespace division_tests - -inline namespace compound_arithmetic -{ - - auto addition_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type() -> void - { - using type_alias = nt::new_type; - ASSERT((std::is_same_v() += std::declval())>)); - } - - auto addition_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type() - -> void - { - using type_alias = nt::new_type; - auto elhs = 42; - auto erhs = 18; - auto lhs = type_alias{elhs}; - auto rhs = type_alias{erhs}; - ASSERT_EQUAL(elhs += erhs, (lhs += rhs).decay()); - } - - auto subtraction_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type() -> void - { - using type_alias = nt::new_type; - ASSERT((std::is_same_v() -= std::declval())>)); - } - - auto subtraction_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type() - -> void - { - using type_alias = nt::new_type; - auto elhs = 42; - auto erhs = 18; - auto lhs = type_alias{elhs}; - auto rhs = type_alias{erhs}; - ASSERT_EQUAL(elhs -= erhs, (lhs -= rhs).decay()); - } - - auto multiplication_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type() -> void - { - using type_alias = nt::new_type; - ASSERT((std::is_same_v() *= std::declval())>)); - } - - auto multiplication_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type() - -> void - { - using type_alias = nt::new_type; - auto elhs = 42; - auto erhs = 18; - auto lhs = type_alias{elhs}; - auto rhs = type_alias{erhs}; - ASSERT_EQUAL(elhs *= erhs, (lhs *= rhs).decay()); - } - - auto division_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type() -> void - { - using type_alias = nt::new_type; - ASSERT((std::is_same_v() /= std::declval())>)); - } - - auto division_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type() - -> void - { - using type_alias = nt::new_type; - auto elhs = 42; - auto erhs = 18; - auto lhs = type_alias{elhs}; - auto rhs = type_alias{erhs}; - ASSERT_EQUAL(elhs /= erhs, (lhs /= rhs).decay()); - } - -} // namespace compound_arithmetic - -auto arithmetic_suite() -> std::pair -{ - return { - { - // clang-format off - - /// Addition Tests - KAWAII(a_new__type_not_deriving_arithmetic_is_not_addable_with_instances_of_itself), - KAWAII(a_new__type_deriving_arithmetic_is_addable_with_instances_of_itself), - KAWAII(a_new__type_deriving_arithmetic_is_addable_with_instances_of_itself_if_the_base_type_is_addable), - KAWAII(a_new__type_deriving_arithmetic_is_addable_with_instances_of_itself_if_the_base_type_is_addable), - KAWAII(addition_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type), - KAWAII(addition_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type), - - /// Subtraction Tests - KAWAII(a_new__type_not_deriving_arithmetic_is_not_subtractable_with_instances_of_itself), - KAWAII(a_new__type_deriving_arithmetic_is_subtractable_with_instances_of_itself), - KAWAII(a_new__type_deriving_arithmetic_is_subtractable_with_instances_of_itself_if_the_base_type_is_subtractable), - KAWAII(a_new__type_deriving_arithmetic_is_subtractable_with_instances_of_itself_if_the_base_type_is_subtractable), - KAWAII(subtraction_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type), - KAWAII(subtraction_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type), - - /// Multiplication Tests - KAWAII(a_new__type_not_deriving_arithmetic_is_not_multipliable_with_instances_of_itself), - KAWAII(a_new__type_deriving_arithmetic_is_multipliable_with_instances_of_itself), - KAWAII(a_new__type_deriving_arithmetic_is_multipliable_with_instances_of_itself_if_the_base_type_is_multipliable), - KAWAII(a_new__type_deriving_arithmetic_is_multipliable_with_instances_of_itself_if_the_base_type_is_multipliable), - KAWAII(multiplication_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type), - KAWAII(multiplication_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type), - - /// Division Tests - KAWAII(a_new__type_not_deriving_arithmetic_is_not_dividable_with_instances_of_itself), - KAWAII(a_new__type_deriving_arithmetic_is_dividable_with_instances_of_itself), - KAWAII(a_new__type_deriving_arithmetic_is_dividable_with_instances_of_itself_if_the_base_type_is_dividable), - KAWAII(a_new__type_deriving_arithmetic_is_dividable_with_instances_of_itself_if_the_base_type_is_dividable), - KAWAII(division_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type), - KAWAII(division_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type), - - /// Compound Arithmetic Tests - KAWAII(addition_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type), - KAWAII(addition_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type), - KAWAII(subtraction_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type), - KAWAII(subtraction_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type), - KAWAII(multiplication_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type), - KAWAII(multiplication_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type), - KAWAII(division_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_an_instance_of_the_same_new__type), - KAWAII(division_assignment_of_two_instances_of_a_new__type_deriving_arithmetic_produces_the_correct_value_with_respect_to_the_base_type), - - // clang-format on - }, - "Arithmetic Operators Tests"}; -} \ No newline at end of file diff --git a/test/src/conversion_suite.cpp b/test/src/conversion_suite.cpp deleted file mode 100644 index cbe2463..0000000 --- a/test/src/conversion_suite.cpp +++ /dev/null @@ -1,201 +0,0 @@ -#include "conversion_suite.hpp" - -#include "kawaii.hpp" -#include "newtype/derivable.hpp" -#include "newtype/deriving.hpp" -#include "newtype/newtype.hpp" - -#include - -#include -#include -#include -#include -#include -#include -#include - -inline namespace traits_extensions -{ - - template - struct is_implicitly_convertible : std::false_type - { - }; - - template - struct is_implicitly_convertible() = std::declval())>> : std::true_type - { - }; - - template - auto constexpr is_implicitly_convertible_v = is_implicitly_convertible::value; - -} // namespace traits_extensions - -inline namespace ddt_support -{ - - template - struct datum - { - T value; - cute::test_failure failure; - }; - - template - auto generate_test_set(std::size_t size) -> std::vector> - { - auto device = std::random_device{}; - auto generator = std::mt19937{device()}; - auto distribution = [&] { - auto min = std::numeric_limits::min(); - auto max = std::numeric_limits::max(); - if constexpr (std::is_floating_point_v) - { - return std::uniform_real_distribution(min, max); - } - else - { - return std::uniform_int_distribution(min, max); - } - }(); - - auto data = std::vector>{}; - generate_n(std::back_inserter(data), size, [&] { - auto point = distribution(generator); - return datum{point, DDT()}; - }); - return data; - } - -} // namespace ddt_support - -inline namespace implicit_conversion_tests -{ - - template - auto a_new__type_without_deriving_implicit_conversion_is_not_implicitly_convertible_to_the_base_type() -> void - { - using type_alias = nt::new_type; - ASSERT(!(is_implicitly_convertible_v)); - } - - template - auto a_new__type_with_deriving_implicit_conversion_is_implicitly_convertible_to_the_base_type() -> void - { - using type_alias = nt::new_type; - ASSERT((is_implicitly_convertible_v)); - } - -} // namespace implicit_conversion_tests - -inline namespace decay_tests -{ - - template - auto decay_on_a_new__type_has_a_return_type_equal_to_the_base_type() -> void - { - using type_alias = nt::new_type; - ASSERT((std::is_same_v().decay())>)); - } - - template - auto decay_on_a_new__type_returns_the_underlying_value() -> void - { - using type_alias = nt::new_type; - auto data = generate_test_set(2 << 16); - for_each(begin(data), end(data), [](auto & test) { ASSERT_EQUAL_DDT(test.value, type_alias{test.value}.decay(), test.failure); }); - } - -} // namespace decay_tests - -inline namespace decay_noexcept_tests -{ - - auto decay_on_a_new__type_is_noexcept_if_the_base_type_can_be_copied_without_throwing() -> void - { - static_assert(std::is_nothrow_copy_constructible_v, "Sanity check"); - using type_alias = nt::new_type; - ASSERT(noexcept(type_alias{}.decay())); - } - - auto decay_on_a_new__type_is_not_noexcept_if_the_base_type_can_be_not_copied_without_throwing() -> void - { - struct strange_type - { - strange_type() = default; - strange_type(strange_type const &) noexcept(false) - { - } - }; - - static_assert(!std::is_nothrow_copy_constructible_v, "Sanity check"); - using type_alias = nt::new_type; - ASSERT(!noexcept(type_alias{}.decay())); - } - -} // namespace decay_noexcept_tests - -inline namespace conversion_operator_noexcept_tests -{ - - auto new__type_conversion_operator_is_noexcept_if_the_base_type_can_be_copied_without_throwing() -> void - { - static_assert(std::is_nothrow_copy_constructible_v, "Sanity check"); - using type_alias = nt::new_type; - ASSERT(noexcept(static_cast(type_alias{}))); - } - - auto new__type_conversion_operator_is_not_noexcept_if_the_base_type_can_not_be_copied_without_throwing() -> void - { - struct strange_type - { - strange_type() = default; - strange_type(strange_type const &) noexcept(false) - { - } - }; - - static_assert(!std::is_nothrow_copy_constructible_v, "Sanity check"); - using type_alias = nt::new_type; - ASSERT(!noexcept(static_cast(type_alias{}))); - } - -} // namespace conversion_operator_noexcept_tests - -auto conversion_suite() -> std::pair -{ - return {{ - /// Implicit Conversion Tests - KAWAII(a_new__type_without_deriving_implicit_conversion_is_not_implicitly_convertible_to_the_base_type), - KAWAII(a_new__type_without_deriving_implicit_conversion_is_not_implicitly_convertible_to_the_base_type), - KAWAII(a_new__type_without_deriving_implicit_conversion_is_not_implicitly_convertible_to_the_base_type), - KAWAII(a_new__type_without_deriving_implicit_conversion_is_not_implicitly_convertible_to_the_base_type), - KAWAII(a_new__type_without_deriving_implicit_conversion_is_not_implicitly_convertible_to_the_base_type), - KAWAII(a_new__type_with_deriving_implicit_conversion_is_implicitly_convertible_to_the_base_type), - KAWAII(a_new__type_with_deriving_implicit_conversion_is_implicitly_convertible_to_the_base_type), - KAWAII(a_new__type_with_deriving_implicit_conversion_is_implicitly_convertible_to_the_base_type), - KAWAII(a_new__type_with_deriving_implicit_conversion_is_implicitly_convertible_to_the_base_type), - KAWAII(a_new__type_with_deriving_implicit_conversion_is_implicitly_convertible_to_the_base_type), - - /// Decay Tests - KAWAII(decay_on_a_new__type_has_a_return_type_equal_to_the_base_type), - KAWAII(decay_on_a_new__type_has_a_return_type_equal_to_the_base_type), - KAWAII(decay_on_a_new__type_has_a_return_type_equal_to_the_base_type), - KAWAII(decay_on_a_new__type_has_a_return_type_equal_to_the_base_type), - KAWAII(decay_on_a_new__type_has_a_return_type_equal_to_the_base_type), - KAWAII(decay_on_a_new__type_returns_the_underlying_value), - KAWAII(decay_on_a_new__type_returns_the_underlying_value), - KAWAII(decay_on_a_new__type_returns_the_underlying_value), - - /// Decay noexcept Tests - KAWAII(decay_on_a_new__type_is_noexcept_if_the_base_type_can_be_copied_without_throwing), - KAWAII(decay_on_a_new__type_is_not_noexcept_if_the_base_type_can_be_not_copied_without_throwing), - - /// Conversion Operator noexcept Tests - KAWAII(new__type_conversion_operator_is_noexcept_if_the_base_type_can_be_copied_without_throwing), - KAWAII(new__type_conversion_operator_is_not_noexcept_if_the_base_type_can_not_be_copied_without_throwing), - }, - "Conversion Tests"}; -} \ No newline at end of file diff --git a/test/src/derivation_clause_suite.cpp b/test/src/derivation_clause_suite.cpp deleted file mode 100644 index 86a34ab..0000000 --- a/test/src/derivation_clause_suite.cpp +++ /dev/null @@ -1,312 +0,0 @@ -#include "derivation_clause_suite.hpp" - -#include "kawaii.hpp" -#include "newtype/derivable.hpp" -#include "newtype/deriving.hpp" - -#include - -#include - -inline namespace subset_tests -{ - - auto an_empty_derivation_clause_does_not_contain_any_derivable() -> void - { - auto derivation_clause = nt::deriving(); - ASSERT(!derivation_clause(nt::Show)); - } - - auto a_derivation_clause_containing_only_show_does_not_contain_eqbase() -> void - { - auto derivation_clause = deriving(nt::Show); - ASSERT(!derivation_clause(nt::EqBase)); - } - - auto a_derivation_clause_containing_only_show_does_contain_show() -> void - { - auto derivation_clause = deriving(nt::Show); - ASSERT(derivation_clause(nt::Show)); - } - - auto a_derivation_clause_containing_only_show_and_eqbase_does_contain_show() -> void - { - auto derivation_clause = deriving(nt::Show, nt::EqBase); - ASSERT(derivation_clause(nt::Show)); - } - - auto a_derivation_clause_containing_only_show_and_eqbase_does_contain_both_show_and_eqbase() -> void - { - auto derivation_clause = deriving(nt::Show, nt::EqBase); - ASSERT(derivation_clause(nt::Show, nt::EqBase)); - } - - auto a_derivation_clause_containing_only_show_and_eqbase_does_not_contain_arithmetic() -> void - { - auto derivation_clause = deriving(nt::Show, nt::EqBase); - ASSERT(!derivation_clause(nt::Arithmetic)); - } - - auto a_derivation_clause_containing_only_show_and_eqbase_does_not_contain_both_show_and_arithmetic() -> void - { - auto derivation_clause = deriving(nt::Show, nt::EqBase); - ASSERT(!derivation_clause(nt::Show, nt::Arithmetic)); - } - -} // namespace subset_tests - -inline namespace less_than_tests -{ - - auto a_derivation_clause_containing_only_show_compares_less_than_one_containing_show_and_eqbase() -> void - { - auto only_show = deriving(nt::Show); - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - - ASSERT(only_show < show_and_eqbase); - } - - auto a_derivation_clause_containing_only_show_and_eqbase_does_not_compare_less_than_one_containing_show_and_eqbase() -> void - { - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - auto also_show_and_eqbase = deriving(nt::Show, nt::EqBase); - - ASSERT(!(show_and_eqbase < also_show_and_eqbase)); - } - - auto a_derivation_clause_containing_only_show_and_eqbase_does_not_compare_less_than_one_containing_eqbase_and_show() -> void - { - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - auto eqbase_and_show = deriving(nt::EqBase, nt::Show); - - ASSERT(!(show_and_eqbase < eqbase_and_show)); - } - - auto a_derivation_clause_containing_only_show_does_not_compare_less_than_one_containing_only_eqbase() -> void - { - auto show = deriving(nt::Show); - auto eqbase = deriving(nt::EqBase); - - ASSERT(!(show < eqbase)); - } - -} // namespace less_than_tests - -inline namespace greater_than_tests -{ - - auto a_derivation_clause_containing_only_show_and_eqbase_compares_greater_than_one_containing_only_show() -> void - { - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - auto show = deriving(nt::Show); - - ASSERT(show_and_eqbase > show); - } - - auto a_derivation_clause_containing_only_show_and_eqbase_does_not_compare_greater_than_one_containing_only_show_and_eqbase() -> void - { - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - auto also_show_and_eqbase = deriving(nt::Show, nt::EqBase); - - ASSERT(!(show_and_eqbase > also_show_and_eqbase)); - } - - auto a_derivation_clause_containing_only_show_and_eqbase_does_not_compare_greater_than_one_containing_only_eqbase_and_show() -> void - { - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - auto eqbase_and_show = deriving(nt::EqBase, nt::Show); - - ASSERT(!(show_and_eqbase > eqbase_and_show)); - } - - auto a_derivation_clause_containing_only_show_does_not_compare_greater_than_one_containing_only_eqbase() -> void - { - auto show = deriving(nt::Show); - auto eqbase = deriving(nt::EqBase); - - ASSERT(!(show > eqbase)); - } - -} // namespace greater_than_tests - -inline namespace eqbaseuals_tests -{ - - auto a_derivation_clause_containing_only_show_and_eqbase_is_eqbaseual_to_one_containing_only_show_and_eqbase() -> void - { - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - auto also_show_and_eqbase = deriving(nt::Show, nt::EqBase); - - ASSERT_EQUAL(show_and_eqbase, also_show_and_eqbase); - } - - auto a_derivation_clause_containing_only_show_and_eqbase_is_eqbaseual_to_one_containing_only_eqbase_and_show() -> void - { - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - auto eqbase_and_show = deriving(nt::EqBase, nt::Show); - - ASSERT_EQUAL(show_and_eqbase, eqbase_and_show); - } - - auto a_derivation_clause_containing_only_show_and_eqbase_is_not_eqbaseual_to_one_containing_only_arithmetic() -> void - { - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - auto arithmetic = deriving(nt::Arithmetic); - - ASSERT(!(show_and_eqbase == arithmetic)); - } - - auto a_derivation_clause_containing_only_show_is_not_eqbaseual_to_one_containing_only_arithmetic() -> void - { - auto show = deriving(nt::Show); - auto arithmetic = deriving(nt::Arithmetic); - - ASSERT(!(show == arithmetic)); - } - -} // namespace eqbaseuals_tests - -inline namespace not_eqbaseuals_tests -{ - - auto a_derivation_clause_containing_only_show_and_eqbase_is_not_not_eqbaseual_to_one_containing_only_show_and_eqbase() -> void - { - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - auto also_show_and_eqbase = deriving(nt::Show, nt::EqBase); - - ASSERT(!(show_and_eqbase != also_show_and_eqbase)); - } - - auto a_derivation_clause_containing_only_show_and_eqbase_is_not_not_eqbaseual_to_one_containing_only_eqbase_and_show() -> void - { - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - auto eqbase_and_show = deriving(nt::EqBase, nt::Show); - - ASSERT(!(show_and_eqbase != eqbase_and_show)); - } - - auto a_derivation_clause_containing_only_eqbase_and_show_is_not_eqbaseual_to_one_containing_only_arithmetic() -> void - { - auto eqbase_and_show = deriving(nt::EqBase, nt::Show); - auto arithmetic = deriving(nt::Arithmetic); - - ASSERT(eqbase_and_show != arithmetic); - } - - auto a_derivation_clause_containing_only_eqbase_is_not_eqbaseual_to_one_containing_only_arithmetic() -> void - { - auto eqbase = deriving(nt::EqBase); - auto arithmetic = deriving(nt::Arithmetic); - - ASSERT(eqbase != arithmetic); - } - -} // namespace not_eqbaseuals_tests - -inline namespace less_than_or_eqbaseual_tests -{ - - auto a_derivation_clause_containing_only_show_is_less_than_or_eqbaseual_to_one_containing_only_show_and_eqbase() -> void - { - auto only_show = deriving(nt::Show); - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - - ASSERT(only_show <= show_and_eqbase); - } - - auto a_derivation_clause_containing_only_show_and_eqbase_is_less_than_or_eqbaseual_to_one_containing_only_show_and_eqbase() -> void - { - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - auto also_show_and_eqbase = deriving(nt::Show, nt::EqBase); - - ASSERT(show_and_eqbase <= also_show_and_eqbase); - } - - auto a_derivation_clause_containing_only_arithmetic_is_neither_less_than_nor_eqbaseual_to_on_containing_only_show_and_eqbase() -> void - { - auto arithmetic = deriving(nt::Arithmetic); - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - - ASSERT(!(arithmetic <= show_and_eqbase)); - } - -} // namespace less_than_or_eqbaseual_tests - -inline namespace greater_than_or_eqbaseual_tests -{ - - auto a_derivation_clause_containing_only_show_and_eqbase_is_greater_than_or_eqbaseual_to_one_containing_only_show() -> void - { - auto only_show = deriving(nt::Show); - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - - ASSERT(show_and_eqbase >= only_show); - } - - auto a_derivation_clause_containing_only_show_and_eqbase_is_greater_than_or_eqbaseual_to_one_containing_only_show_and_eqbase() -> void - { - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - auto also_show_and_eqbase = deriving(nt::Show, nt::EqBase); - - ASSERT(show_and_eqbase >= also_show_and_eqbase); - } - - auto a_derivation_clause_containing_only_show_and_eqbase_is_neither_greater_than_nor_eqbaseual_to_on_containing_only_arithmetic() -> void - { - auto arithmetic = deriving(nt::Arithmetic); - auto show_and_eqbase = deriving(nt::Show, nt::EqBase); - - ASSERT(!(show_and_eqbase >= arithmetic)); - } - -} // namespace greater_than_or_eqbaseual_tests - -auto derivation_clause_suite() -> std::pair -{ - return { - { - /// Subset tests - KAWAII(an_empty_derivation_clause_does_not_contain_any_derivable), - KAWAII(a_derivation_clause_containing_only_show_does_not_contain_eqbase), - KAWAII(a_derivation_clause_containing_only_show_does_contain_show), - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_does_contain_show), - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_does_contain_both_show_and_eqbase), - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_does_not_contain_arithmetic), - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_does_not_contain_both_show_and_arithmetic), - - /// Less-than tests - KAWAII(a_derivation_clause_containing_only_show_compares_less_than_one_containing_show_and_eqbase), - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_does_not_compare_less_than_one_containing_show_and_eqbase), - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_does_not_compare_less_than_one_containing_eqbase_and_show), - KAWAII(a_derivation_clause_containing_only_show_does_not_compare_less_than_one_containing_only_eqbase), - - /// Greater-than tests - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_compares_greater_than_one_containing_only_show), - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_does_not_compare_greater_than_one_containing_only_show_and_eqbase), - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_does_not_compare_greater_than_one_containing_only_eqbase_and_show), - KAWAII(a_derivation_clause_containing_only_show_does_not_compare_greater_than_one_containing_only_eqbase), - - /// Equals tests - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_is_eqbaseual_to_one_containing_only_show_and_eqbase), - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_is_eqbaseual_to_one_containing_only_eqbase_and_show), - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_is_not_eqbaseual_to_one_containing_only_arithmetic), - KAWAII(a_derivation_clause_containing_only_show_is_not_eqbaseual_to_one_containing_only_arithmetic), - - /// Not-Equals tests - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_is_not_not_eqbaseual_to_one_containing_only_show_and_eqbase), - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_is_not_not_eqbaseual_to_one_containing_only_eqbase_and_show), - KAWAII(a_derivation_clause_containing_only_eqbase_and_show_is_not_eqbaseual_to_one_containing_only_arithmetic), - KAWAII(a_derivation_clause_containing_only_eqbase_is_not_eqbaseual_to_one_containing_only_arithmetic), - - /// Less-than or Equals tests - KAWAII(a_derivation_clause_containing_only_show_is_less_than_or_eqbaseual_to_one_containing_only_show_and_eqbase), - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_is_less_than_or_eqbaseual_to_one_containing_only_show_and_eqbase), - KAWAII(a_derivation_clause_containing_only_arithmetic_is_neither_less_than_nor_eqbaseual_to_on_containing_only_show_and_eqbase), - - /// Greater-than or Equals tests - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_is_greater_than_or_eqbaseual_to_one_containing_only_show), - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_is_greater_than_or_eqbaseual_to_one_containing_only_show_and_eqbase), - KAWAII(a_derivation_clause_containing_only_show_and_eqbase_is_neither_greater_than_nor_eqbaseual_to_on_containing_only_arithmetic), - }, - "Derivation Clause Tests"}; -} \ No newline at end of file diff --git a/test/src/driver.cpp b/test/src/driver.cpp deleted file mode 100644 index a0e8904..0000000 --- a/test/src/driver.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "arithmetic_suite.hpp" -#include "conversion_suite.hpp" -#include "derivation_clause_suite.hpp" -#include "equality_comparison_suite.hpp" -#include "hash_suite.hpp" -#include "io_operators_suite.hpp" -#include "iterable_suite.hpp" -#include "new_type_constructor_suite.hpp" -#include "relational_operators_suite.hpp" - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -using suite_list = std::vector>; - -auto get_test_selectors(suite_list const & suites) -> std::vector -{ - auto selectors = std::vector{}; - - for_each(cbegin(suites), cend(suites), [&](auto descriptor) { - auto const & [suite, name] = descriptor; - transform(cbegin(suite), cend(suite), std::back_inserter(selectors), [&, name = name](auto test) { return name + "#" + test.name(); }); - }); - - return selectors; -} - -auto do_run_tests(suite_list const & suites, int argc, char ** argv) -> bool -{ - auto listener = cute::tap_listener<>{}; - auto runner = cute::makeRunner(listener, argc, argv); - - return accumulate(cbegin(suites), cend(suites), true, [&](auto accumulator, auto const & descriptor) { - auto const & [suite, name] = descriptor; - return accumulator && runner(suite, name.c_str()); - }); -} - -int main(int argc, char ** argv) -{ - auto suites = std::vector{ - derivation_clause_suite(), - new_type_constructor_suite(), - conversion_suite(), - equality_comparison_suite(), - relational_operators_suite(), - io_operators_suite(), - arithmetic_suite(), - hash_suite(), - iterable_suite(), - }; - - auto selectors = get_test_selectors(suites); - - auto list_tests{false}; - auto list_suites{false}; - auto show_help{false}; - auto selected_tests = std::vector{}; - - auto cli = lyra::cli_parser() | // - lyra::opt(list_tests)["-t"]["--tests"]("List all registered tests") | // - lyra::opt(list_suites)["-s"]["--suites"]("List all registered suites") | // - lyra::arg(selected_tests, "test selector")("A pattern to select a specific test") | // - lyra::help(show_help); - auto result = cli.parse({argc, argv}); - - if (list_tests) - { - copy(cbegin(selectors), cend(selectors), std::ostream_iterator{std::cout, "\n"}); - } - if (list_suites) - { - transform(cbegin(suites), cend(suites), std::ostream_iterator{std::cout, "\n"}, [](auto descriptor) { - auto const & [_, name] = descriptor; - return name; - }); - } - else if (!result || show_help) - { - std::cout << cli; - } - else - { - return do_run_tests(suites, argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE; - } -} \ No newline at end of file diff --git a/test/src/equality_comparison_suite.cpp b/test/src/equality_comparison_suite.cpp deleted file mode 100644 index 4e484f4..0000000 --- a/test/src/equality_comparison_suite.cpp +++ /dev/null @@ -1,188 +0,0 @@ -#include "equality_comparison_suite.hpp" - -#include "kawaii.hpp" -#include "newtype/derivable.hpp" -#include "newtype/deriving.hpp" -#include "newtype/newtype.hpp" - -#include - -#include -#include -#include - -inline namespace basic_equality_comparsion_tests -{ - - auto two_instances_of_the_same_new__type_with_the_same_value_compare_equal() -> void - { - using type_alias = nt::new_type; - - auto constexpr lhs = type_alias{42}; - auto constexpr rhs = type_alias{42}; - - ASSERT_EQUAL(lhs, rhs); - } - - auto two_instances_of_the_same_new__type_with_the_same_value_do_not_compare_not_equal() -> void - { - using type_alias = nt::new_type; - - auto constexpr lhs = type_alias{42}; - auto constexpr rhs = type_alias{42}; - - ASSERT(!(lhs != rhs)); - } - - auto two_instances_of_the_same_new__type_with_differing_values_do_compare_not_equal() -> void - { - using type_alias = nt::new_type; - - auto constexpr lhs = type_alias{42}; - auto constexpr rhs = type_alias{43}; - - ASSERT_NOT_EQUAL_TO(lhs, rhs); - } - - auto two_instances_of_the_same_new__type_with_differing_values_do_not_compare_equal() -> void - { - using type_alias = nt::new_type; - - auto constexpr lhs = type_alias{42}; - auto constexpr rhs = type_alias{43}; - - ASSERT(!(lhs == rhs)); - } - -} // namespace basic_equality_comparsion_tests - -inline namespace equality_comparsion_noexcept_tests -{ - - auto equality_comparison_on_a_new__type_is_noexcept_if_the_base_type_is_noexcept_comparable() -> void - { - using type_alias = nt::new_type; - static_assert(noexcept(std::declval() == std::declval()), "Sanity Check"); - ASSERT(noexcept(std::declval() == std::declval())); - } - - auto equality_comparison_on_a_new__type_is_not_noexcept_if_the_base_type_is_not_noexcept_comparable() -> void - { - struct strange_type - { - auto constexpr operator==(strange_type const &) const noexcept(false) -> bool - { - return false; - } - }; - - using type_alias = nt::new_type; - static_assert(!noexcept(std::declval() == std::declval()), "Sanity Check"); - ASSERT(!noexcept(std::declval() == std::declval())); - } - - auto inequality_comparison_on_a_new__type_is_noexcept_if_the_base_type_is_noexcept_comparable() -> void - { - using type_alias = nt::new_type; - static_assert(noexcept(std::declval() != std::declval()), "Sanity Check"); - ASSERT(noexcept(std::declval() != std::declval())); - } - - auto inequality_comparison_on_a_new__type_is_not_noexcept_if_the_base_type_is_not_noexcept_comparable() -> void - { - struct strange_type - { - auto constexpr operator!=(strange_type const &) const noexcept(false) -> bool - { - return false; - } - }; - - using type_alias = nt::new_type; - static_assert(!noexcept(std::declval() != std::declval()), "Sanity Check"); - ASSERT(!noexcept(std::declval() != std::declval())); - } - -} // namespace equality_comparsion_noexcept_tests - -inline namespace equality_comparison_return_type_tests -{ - - auto equality_comparsion_of_two_new__type_instances_returns_bool() -> void - { - using type_alias = nt::new_type; - ASSERT((std::is_same_v() == std::declval())>)); - } - - auto inequality_comparsion_of_two_new__type_instances_returns_bool() -> void - { - using type_alias = nt::new_type; - ASSERT((std::is_same_v() != std::declval())>)); - } - -} // namespace equality_comparison_return_type_tests - -inline namespace base_type_equality_comparison_tests -{ - - auto an_instance_of_a_new__type_compares_equal_to_an_instance_of_its_base_type_with_the_same_value() -> void - { - using type_alias = nt::new_type; - auto lhs = type_alias{42}; - auto rhs = 42; - ASSERT_EQUAL(lhs, rhs); - } - - auto an_instance_of_the_base_type_of_a_new__type_compares_equal_to_an_instance_of_the_new__type_with_the_same_value() -> void - { - using type_alias = nt::new_type; - auto lhs = 42; - auto rhs = type_alias{42}; - ASSERT_EQUAL(lhs, rhs); - } - - auto an_instance_of_a_new__type_compares_not_equal_to_an_instance_of_its_base_type_with_a_differing_value() -> void - { - using type_alias = nt::new_type; - auto lhs = type_alias{42}; - auto rhs = 43; - ASSERT(lhs != rhs); - } - - auto an_instance_of_the_base_type_of_a_new__type_compares_not_equal_to_an_instance_of_the_new__type_with_a_differing_value() -> void - { - using type_alias = nt::new_type; - auto lhs = 43; - auto rhs = type_alias{42}; - ASSERT(lhs != rhs); - } - -} // namespace base_type_equality_comparison_tests - -auto equality_comparison_suite() -> std::pair -{ - return {{ - // Basic Equality Comparison Tests - KAWAII(two_instances_of_the_same_new__type_with_the_same_value_compare_equal), - KAWAII(two_instances_of_the_same_new__type_with_the_same_value_do_not_compare_not_equal), - KAWAII(two_instances_of_the_same_new__type_with_differing_values_do_compare_not_equal), - KAWAII(two_instances_of_the_same_new__type_with_differing_values_do_not_compare_equal), - - // Equality Comparison noexcept Tests - KAWAII(equality_comparison_on_a_new__type_is_noexcept_if_the_base_type_is_noexcept_comparable), - KAWAII(equality_comparison_on_a_new__type_is_not_noexcept_if_the_base_type_is_not_noexcept_comparable), - KAWAII(inequality_comparison_on_a_new__type_is_noexcept_if_the_base_type_is_noexcept_comparable), - KAWAII(inequality_comparison_on_a_new__type_is_not_noexcept_if_the_base_type_is_not_noexcept_comparable), - - // Equality Comparison Return Type Tests - KAWAII(equality_comparsion_of_two_new__type_instances_returns_bool), - KAWAII(inequality_comparsion_of_two_new__type_instances_returns_bool), - - // Base-type Equality Comparison Tests - KAWAII(an_instance_of_a_new__type_compares_equal_to_an_instance_of_its_base_type_with_the_same_value), - KAWAII(an_instance_of_the_base_type_of_a_new__type_compares_equal_to_an_instance_of_the_new__type_with_the_same_value), - KAWAII(an_instance_of_a_new__type_compares_not_equal_to_an_instance_of_its_base_type_with_a_differing_value), - KAWAII(an_instance_of_the_base_type_of_a_new__type_compares_not_equal_to_an_instance_of_the_new__type_with_a_differing_value), - }, - "Equality Comparison Tests"}; -} \ No newline at end of file diff --git a/test/src/hash_suite.cpp b/test/src/hash_suite.cpp deleted file mode 100644 index b482414..0000000 --- a/test/src/hash_suite.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "hash_suite.hpp" - -#include "kawaii.hpp" -#include "newtype/derivable.hpp" -#include "newtype/deriving.hpp" -#include "newtype/impl/type_traits_extensions.hpp" -#include "newtype/newtype.hpp" - -#include - -#include - -inline namespace hashable_tests -{ - - auto a_new__type_that_does_not_include_hash_in_its_derivation_clause_is_not_hashable() -> void - { - using type_alias = nt::new_type; - ASSERT(!nt::impl::is_hashable_v); - } - - auto a_new__type_that_does_include_hash_in_its_derivation_clause_is_hashable() -> void - { - static_assert(nt::impl::is_hashable_v, "Sanity Check"); - using type_alias = nt::new_type; - ASSERT(nt::impl::is_hashable_v); - } - - auto a_new__type_that_does_include_hash_in_its_derivation_clause_but_whose_base_type_is_not_hashable_is_also_not_hashable() -> void - { - struct not_hashable - { - }; - - static_assert(!nt::impl::is_hashable_v, "Sanity Check"); - using type_alias = nt::new_type; - ASSERT(!nt::impl::is_hashable_v); - } - -} // namespace hashable_tests - -inline namespace usage_tests -{ - - auto a_new__type_that_is_hashable_can_be_used_in_an_unordered__map() -> void - { - static_assert(nt::impl::is_hashable_v, "Sanity Check"); - using type_alias = nt::new_type; - - auto map = std::unordered_map{}; - map[type_alias{42}] = 43; - ASSERT_EQUAL(43, map[type_alias{42}]); - } - -} // namespace usage_tests - -auto hash_suite() -> std::pair -{ - return {{ - // Hashable Tests - KAWAII(a_new__type_that_does_not_include_hash_in_its_derivation_clause_is_not_hashable), - KAWAII(a_new__type_that_does_include_hash_in_its_derivation_clause_is_hashable), - KAWAII(a_new__type_that_does_include_hash_in_its_derivation_clause_but_whose_base_type_is_not_hashable_is_also_not_hashable), - - // Usage Tests - KAWAII(a_new__type_that_is_hashable_can_be_used_in_an_unordered__map), - }, - "std::hash Support Tests"}; -} \ No newline at end of file diff --git a/test/src/io_operators_suite.cpp b/test/src/io_operators_suite.cpp deleted file mode 100644 index 4e146a7..0000000 --- a/test/src/io_operators_suite.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include "io_operators_suite.hpp" - -#include "kawaii.hpp" -#include "newtype/derivable.hpp" -#include "newtype/deriving.hpp" -#include "newtype/newtype.hpp" - -#include - -#include -#include -#include -#include -#include - -inline namespace traits_extensions -{ - - template - struct has_stream_input : std::false_type - { - }; - - template - struct has_stream_input() >> std::declval())>> : std::true_type - { - }; - - template - auto constexpr has_stream_input_v = has_stream_input::value; - - template - struct has_stream_output : std::false_type - { - }; - - template - struct has_stream_output() << std::declval())>> : std::true_type - { - }; - - template - auto constexpr has_stream_output_v = has_stream_output::value; - -} // namespace traits_extensions - -inline namespace stream_input_operator_tests -{ - - auto a_new__type_has_the_stream_input_operator_if_the_derivation_clause_contains_read() -> void - { - using type_alias = nt::new_type; - ASSERT(has_stream_input_v); - } - - auto a_new__type_does_not_have_the_stream_input_operator_if_the_derivation_clause_does_not_contain_read() -> void - { - using type_alias = nt::new_type; - ASSERT(!has_stream_input_v); - } - - auto a_instance_of_a_new__type_can_be_read_from_an_istream_if_the_base_type_can_be_read_from_an_istream() -> void - { - static_assert(has_stream_input_v, "Sanity Check"); - using type_alias = nt::new_type; - - auto obj = type_alias{}; - auto input = std::istringstream{"42"}; - - input >> obj; - - ASSERT_EQUAL(42, obj.decay()); - } - -} // namespace stream_input_operator_tests - -inline namespace stream_output_operator_tests -{ - - auto a_new__type_has_the_stream_output_operator_if_the_derivation_clause_contains_show() -> void - { - using type_alias = nt::new_type; - ASSERT(has_stream_output_v); - } - - auto a_new__type_does_not_have_the_stream_output_operator_if_the_derivation_clause_does_not_contain_show() -> void - { - using type_alias = nt::new_type; - ASSERT(!has_stream_output_v); - } - - auto a_instance_of_a_new__type_can_be_written_to_an_ostream_if_the_base_type_can_be_written_to_an_ostream() -> void - { - static_assert(has_stream_output_v, "Sanity Check"); - using type_alias = nt::new_type; - - auto obj = type_alias{42}; - auto output = std::ostringstream{}; - - output << obj; - - ASSERT_EQUAL("42", output.str()); - } - -} // namespace stream_output_operator_tests - -auto io_operators_suite() -> std::pair -{ - return {{ - // Stream Input Operator Tests - KAWAII(a_new__type_has_the_stream_input_operator_if_the_derivation_clause_contains_read), - KAWAII(a_new__type_does_not_have_the_stream_input_operator_if_the_derivation_clause_does_not_contain_read), - KAWAII(a_instance_of_a_new__type_can_be_read_from_an_istream_if_the_base_type_can_be_read_from_an_istream), - - // Stream Ouput Operator Tests - KAWAII(a_new__type_has_the_stream_output_operator_if_the_derivation_clause_contains_show), - KAWAII(a_new__type_does_not_have_the_stream_output_operator_if_the_derivation_clause_does_not_contain_show), - KAWAII(a_instance_of_a_new__type_can_be_written_to_an_ostream_if_the_base_type_can_be_written_to_an_ostream), - }, - "I/O Operators Tests"}; -} \ No newline at end of file diff --git a/test/src/iterable_suite.cpp b/test/src/iterable_suite.cpp deleted file mode 100644 index add4696..0000000 --- a/test/src/iterable_suite.cpp +++ /dev/null @@ -1,719 +0,0 @@ -#include "iterable_suite.hpp" - -#include "kawaii.hpp" -#include "newtype/derivable.hpp" -#include "newtype/deriving.hpp" -#include "newtype/impl/type_traits_extensions.hpp" -#include "newtype/newtype.hpp" - -#include - -#include -#include -#include -#include - -namespace -{ - - struct with_member - { - using iterator = char *; - using const_iterator = char const *; - using reverse_iterator = std::reverse_iterator; - using const_reverse_iterator = std::reverse_iterator; - - auto begin() -> iterator; - auto begin() const -> const_iterator; - auto cbegin() const -> const_iterator; - a