diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/include/arithmetic_suite.hpp | 11 | ||||
| -rw-r--r-- | test/include/conversion_suite.hpp | 11 | ||||
| -rw-r--r-- | test/include/derivation_clause_suite.hpp | 11 | ||||
| -rw-r--r-- | test/include/equality_comparison_suite.hpp | 11 | ||||
| -rw-r--r-- | test/include/hash_suite.hpp | 11 | ||||
| -rw-r--r-- | test/include/io_operators_suite.hpp | 11 | ||||
| -rw-r--r-- | test/include/iterable_suite.hpp | 11 | ||||
| -rw-r--r-- | test/include/kawaii.hpp | 143 | ||||
| -rw-r--r-- | test/include/new_type_constructor_suite.hpp | 11 | ||||
| -rw-r--r-- | test/include/relational_operators_suite.hpp | 11 | ||||
| -rw-r--r-- | test/src/arithmetic_suite.cpp | 330 | ||||
| -rw-r--r-- | test/src/conversion_suite.cpp | 201 | ||||
| -rw-r--r-- | test/src/derivation_clause_suite.cpp | 312 | ||||
| -rw-r--r-- | test/src/driver.cpp | 101 | ||||
| -rw-r--r-- | test/src/equality_comparison_suite.cpp | 188 | ||||
| -rw-r--r-- | test/src/hash_suite.cpp | 69 | ||||
| -rw-r--r-- | test/src/io_operators_suite.cpp | 121 | ||||
| -rw-r--r-- | test/src/iterable_suite.cpp | 719 | ||||
| -rw-r--r-- | test/src/new_type_constructor_suite.cpp | 91 | ||||
| -rw-r--r-- | test/src/relational_operators_suite.cpp | 321 |
20 files changed, 0 insertions, 2695 deletions
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 <cute/cute_suite.h> - -#include <string> -#include <utility> - -auto arithmetic_suite() -> std::pair<cute::suite, std::string>; - -#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 <cute/cute_suite.h> - -#include <string> -#include <utility> - -auto conversion_suite() -> std::pair<cute::suite, std::string>; - -#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 <cute/cute_suite.h> - -#include <string> -#include <utility> - -auto derivation_clause_suite() -> std::pair<cute::suite, std::string>; - -#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 <cute/cute_suite.h> - -#include <string> -#include <utility> - -auto equality_comparison_suite() -> std::pair<cute::suite, std::string>; - -#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 <cute/cute_suite.h> - -#include <string> -#include <utility> - -auto hash_suite() -> std::pair<cute::suite, std::string>; - -#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 <cute/cute_suite.h> - -#include <string> -#include <utility> - -auto io_operators_suite() -> std::pair<cute::suite, std::string>; - -#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 <cute/cute_suite.h> - -#include <string> -#include <utility> - -auto iterable_suite() -> std::pair<cute::suite, std::string>; - -#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 <cute/cute_test.h> - -#include <algorithm> -#include <array> -#include <cctype> -#include <iterator> -#include <sstream> -#include <string> -#include <utility> - -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<char>(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 <cute/cute_suite.h> - -#include <string> -#include <utility> - -auto new_type_constructor_suite() -> std::pair<cute::suite, std::string>; - -#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 <cute/cute_suite.h> - -#include <string> -#include <utility> - -auto relational_operators_suite() -> std::pair<cute::suite, std::string>; - -#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 <cute/cute.h> - -#include <type_traits> - -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<int, struct tag>; - ASSERT(!(nt::impl::is_addable_v<type_alias>)); - } - - auto a_new__type_deriving_arithmetic_is_addable_with_instances_of_itself() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Arithmetic)>; - ASSERT(nt::impl::is_addable_v<type_alias>); - } - - template<typename T> - 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<T>, "Sanity Check"); - using type_alias = nt::new_type<T, struct tag, deriving(nt::Arithmetic)>; - ASSERT_EQUAL(nt::impl::is_addable_v<T>, nt::impl::is_addable_v<type_alias>); - } - - 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<int, struct tag, deriving(nt::Arithmetic)>; - ASSERT((std::is_same_v<type_alias, decltype(std::declval<type_alias const &>() + std::declval<type_alias const &>())>)); - } - - 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<int, struct tag, deriving(nt::Arithmetic)>; - 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<int, struct tag>; - ASSERT(!(nt::impl::is_subtractable_v<type_alias>)); - } - - auto a_new__type_deriving_arithmetic_is_subtractable_with_instances_of_itself() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Arithmetic)>; - ASSERT(nt::impl::is_subtractable_v<type_alias>); - } - - template<typename T> - 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<T>, "Sanity Check"); - using type_alias = nt::new_type<T, struct tag, deriving(nt::Arithmetic)>; - ASSERT_EQUAL(nt::impl::is_subtractable_v<T>, nt::impl::is_subtractable_v<type_alias>); - } - - 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<int, struct tag, deriving(nt::Arithmetic)>; - ASSERT((std::is_same_v<type_alias, decltype(std::declval<type_alias const &>() - std::declval<type_alias const &>())>)); - } - - 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<int, struct tag, deriving(nt::Arithmetic)>; - 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<int, struct tag>; - ASSERT(!(nt::impl::is_multipliable_v<type_alias>)); - } - - auto a_new__type_deriving_arithmetic_is_multipliable_with_instances_of_itself() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Arithmetic)>; - ASSERT(nt::impl::is_multipliable_v<type_alias>); - } - - template<typename T> - 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<T>, "Sanity Check"); - using type_alias = nt::new_type<T, struct tag, deriving(nt::Arithmetic)>; - ASSERT_EQUAL(nt::impl::is_multipliable_v<T>, nt::impl::is_multipliable_v<type_alias>); - } - - 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<int, struct tag, deriving(nt::Arithmetic)>; - ASSERT((std::is_same_v<type_alias, decltype(std::declval<type_alias const &>() * std::declval<type_alias const &>())>)); - } - - 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<int, struct tag, deriving(nt::Arithmetic)>; - 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<int, struct tag>; - ASSERT(!(nt::impl::is_dividable_v<type_alias>)); - } - - auto a_new__type_deriving_arithmetic_is_dividable_with_instances_of_itself() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Arithmetic)>; - ASSERT(nt::impl::is_dividable_v<type_alias>); - } - - template<typename T> - 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<T>, "Sanity Check"); - using type_alias = nt::new_type<T, struct tag, deriving(nt::Arithmetic)>; - ASSERT_EQUAL(nt::impl::is_dividable_v<T>, nt::impl::is_dividable_v<type_alias>); - } - - 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<int, struct tag, deriving(nt::Arithmetic)>; - ASSERT((std::is_same_v<type_alias, decltype(std::declval<type_alias const &>() / std::declval<type_alias const &>())>)); - } - - 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<int, struct tag, deriving(nt::Arithmetic)>; - 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<int, struct tag, deriving(nt::Arithmetic)>; - ASSERT((std::is_same_v<type_alias &, decltype(std::declval<type_alias &>() += std::declval<type_alias const &>())>)); - } - - 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<int, struct tag, deriving(nt::Arithmetic)>; - 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<int, struct tag, deriving(nt::Arithmetic)>; - ASSERT((std::is_same_v<type_alias &, decltype(std::declval<type_alias &>() -= std::declval<type_alias const &>())>)); - } - - 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<int, struct tag, deriving(nt::Arithmetic)>; - 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<int, struct tag, deriving(nt::Arithmetic)>; - ASSERT((std::is_same_v<type_alias &, decltype(std::declval<type_alias &>() *= std::declval<type_alias const &>())>)); - } - - 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<int, struct tag, deriving(nt::Arithmetic)>; - 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<int, struct tag, deriving(nt::Arithmetic)>; - ASSERT((std::is_same_v<type_alias &, decltype(std::declval<type_alias &>() /= std::declval<type_alias const &>())>)); - } - - 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<int, struct tag, deriving(nt::Arithmetic)>; - 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<cute::suite, std::string> -{ - 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<int>), - KAWAII(a_new__type_deriving_arithmetic_is_addable_with_instances_of_itself_if_the_base_type_is_addable<addable_type>), - 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<int>), - KAWAII(a_new__type_deriving_arithmetic_is_subtractable_with_instances_of_itself_if_the_base_type_is_subtractable<subtractable_type>), - 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<int>), - KAWAII(a_new__type_deriving_arithmetic_is_multipliable_with_instances_of_itself_if_the_base_type_is_multipliable<multipliable_type>), - 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<int>), - KAWAII(a_new__type_deriving_arithmetic_is_dividable_with_instances_of_itself_if_the_base_type_is_dividable<dividable_type>), - 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 <cute/cute.h> - -#include <algorithm> -#include <iterator> -#include <limits> -#include <random> -#include <string> -#include <type_traits> -#include <vector> - -inline namespace traits_extensions -{ - - template<typename To, typename From, typename = void> - struct is_implicitly_convertible : std::false_type - { - }; - - template<typename To, typename From> - struct is_implicitly_convertible<To, From, std::void_t<decltype(std::declval<To &>() = std::declval<From &>())>> : std::true_type - { - }; - - template<typename To, typename From> - auto constexpr is_implicitly_convertible_v = is_implicitly_convertible<To, From>::value; - -} // namespace traits_extensions - -inline namespace ddt_support -{ - - template<typename T> - struct datum - { - T value; - cute::test_failure failure; - }; - - template<typename ValueType> - auto generate_test_set(std::size_t size) -> std::vector<datum<ValueType>> - { - auto device = std::random_device{}; - auto generator = std::mt19937{device()}; - auto distribution = [&] { - auto min = std::numeric_limits<ValueType>::min(); - auto max = std::numeric_limits<ValueType>::max(); - if constexpr (std::is_floating_point_v<ValueType>) - { - return std::uniform_real_distribution<ValueType>(min, max); - } - else - { - return std::uniform_int_distribution<ValueType>(min, max); - } - }(); - - auto data = std::vector<datum<ValueType>>{}; - generate_n(std::back_inserter(data), size, [&] { - auto point = distribution(generator); - return datum<ValueType>{point, DDT()}; - }); - return data; - } - -} // namespace ddt_support - -inline namespace implicit_conversion_tests -{ - - template<typename T> - auto a_new__type_without_deriving_implicit_conversion_is_not_implicitly_convertible_to_the_base_type() -> void - { - using type_alias = nt::new_type<T, struct conversion_test_1_tag>; - ASSERT(!(is_implicitly_convertible_v<T, type_alias>)); - } - - template<typename T> - auto a_new__type_with_deriving_implicit_conversion_is_implicitly_convertible_to_the_base_type() -> void - { - using type_alias = nt::new_type<T, struct conversion_test_2_tag, deriving(nt::ImplicitConversion)>; - ASSERT((is_implicitly_convertible_v<T, type_alias>)); - } - -} // namespace implicit_conversion_tests - -inline namespace decay_tests -{ - - template<typename T> - auto decay_on_a_new__type_has_a_return_type_equal_to_the_base_type() -> void - { - using type_alias = nt::new_type<T, struct conversion_test_3_tag>; - ASSERT((std::is_same_v<T, decltype(std::declval<type_alias &>().decay())>)); - } - - template<typename T> - auto decay_on_a_new__type_returns_the_underlying_value() -> void - { - using type_alias = nt::new_type<T, struct conversion_test_4_tag>; - auto data = generate_test_set<T>(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<int>, "Sanity check"); - using type_alias = nt::new_type<int, struct conversion_test_5_tag>; - 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<strange_type>, "Sanity check"); - using type_alias = nt::new_type<strange_type, struct conversion_test_6_tag>; - 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<int>, "Sanity check"); - using type_alias = nt::new_type<int, struct conversion_test_5_tag>; - ASSERT(noexcept(static_cast<int>(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<strange_type>, "Sanity check"); - using type_alias = nt::new_type<strange_type, struct conversion_test_5_tag>; - ASSERT(!noexcept(static_cast<strange_type>(type_alias{}))); - } - -} // namespace conversion_operator_noexcept_tests - -auto conversion_suite() -> std::pair<cute::suite, std::string> -{ - return {{ - /// Implicit Conversion Tests - KAWAII(a_new__type_without_deriving_implicit_conversion_is_not_implicitly_convertible_to_the_base_type<bool>), - KAWAII(a_new__type_without_deriving_implicit_conversion_is_not_implicitly_convertible_to_the_base_type<char>), - KAWAII(a_new__type_without_deriving_implicit_conversion_is_not_implicitly_convertible_to_the_base_type<int>), - KAWAII(a_new__type_without_deriving_implicit_conversion_is_not_implicitly_convertible_to_the_base_type<double>), - KAWAII(a_new__type_without_deriving_implicit_conversion_is_not_implicitly_convertible_to_the_base_type<std::string>), - KAWAII(a_new__type_with_deriving_implicit_conversion_is_implicitly_convertible_to_the_base_type<bool>), - KAWAII(a_new__type_with_deriving_implicit_conversion_is_implicitly_convertible_to_the_base_type<char>), - KAWAII(a_new__type_with_deriving_implicit_conversion_is_implicitly_convertible_to_the_base_type<int>), - KAWAII(a_new__type_with_deriving_implicit_conversion_is_implicitly_convertible_to_the_base_type<double>), - KAWAII(a_new__type_with_deriving_implicit_conversion_is_implicitly_convertible_to_the_base_type<std::string>), - - /// Decay Tests - KAWAII(decay_on_a_new__type_has_a_return_type_equal_to_the_base_type<bool>), - KAWAII(decay_on_a_new__type_has_a_return_type_equal_to_the_base_type<char>), - KAWAII(decay_on_a_new__type_has_a_return_type_equal_to_the_base_type<int>), - KAWAII(decay_on_a_new__type_has_a_return_type_equal_to_the_base_type<double>), - KAWAII(decay_on_a_new__type_has_a_return_type_equal_to_the_base_type<std::string>), - KAWAII(decay_on_a_new__type_returns_the_underlying_value<char>), - KAWAII(decay_on_a_new__type_returns_the_underlying_value<int>), - KAWAII(decay_on_a_new__type_returns_the_underlying_value<double>), - - /// 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 <cute/cute.h> - -#include <string> - -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<cute::suite, std::string> -{ - 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 <cute/cute.h> -#include <cute/cute_runner.h> -#include <cute/tap_listener.h> - -#include <lyra/arg.hpp> -#include <lyra/cli_parser.hpp> -#include <lyra/help.hpp> -#include <lyra/opt.hpp> - -#include <algorithm> -#include <cstdlib> -#include <iostream> -#include <iterator> -#include <numeric> -#include <string> -#include <utility> -#include <vector> - -using suite_list = std::vector<std::pair<cute::suite, std::string>>; - -auto get_test_selectors(suite_list const & suites) -> std::vector<std::string> -{ - auto selectors = std::vector<std::string>{}; - - 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<std::string>{}; - - 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::string>{std::cout, "\n"}); - } - if (list_suites) - { - transform(cbegin(suites), cend(suites), std::ostream_iterator<std::string>{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 <cute/cute.h> - -#include <string> -#include <type_traits> -#include <utility> - -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<int, struct tag>; - - 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<int, struct tag>; - - 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<int, struct tag>; - - 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<int, struct tag>; - - 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<int, struct tag>; - static_assert(noexcept(std::declval<int &>() == std::declval<int &>()), "Sanity Check"); - ASSERT(noexcept(std::declval<type_alias &>() == std::declval<type_alias &>())); - } - - 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<strange_type, struct tag>; - static_assert(!noexcept(std::declval<strange_type &>() == std::declval<strange_type &>()), "Sanity Check"); - ASSERT(!noexcept(std::declval<type_alias &>() == std::declval<type_alias &>())); - } - - auto inequality_comparison_on_a_new__type_is_noexcept_if_the_base_type_is_noexcept_comparable() -> void - { - using type_alias = nt::new_type<int, struct tag>; - static_assert(noexcept(std::declval<int &>() != std::declval<int &>()), "Sanity Check"); - ASSERT(noexcept(std::declval<type_alias &>() != std::declval<type_alias &>())); - } - - 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<strange_type, struct tag>; - static_assert(!noexcept(std::declval<strange_type &>() != std::declval<strange_type &>()), "Sanity Check"); - ASSERT(!noexcept(std::declval<type_alias &>() != std::declval<type_alias &>())); - } - -} // 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<int, struct tag>; - ASSERT((std::is_same_v<bool, decltype(std::declval<type_alias &>() == std::declval<type_alias &>())>)); - } - - auto inequality_comparsion_of_two_new__type_instances_returns_bool() -> void - { - using type_alias = nt::new_type<int, struct tag>; - ASSERT((std::is_same_v<bool, decltype(std::declval<type_alias &>() != std::declval<type_alias &>())>)); - } - -} // 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<int, struct tag, deriving(nt::EqBase)>; - 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<int, struct tag, deriving(nt::EqBase)>; - 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<int, struct tag, deriving(nt::EqBase)>; - 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<int, struct tag, deriving(nt::EqBase)>; - auto lhs = 43; - auto rhs = type_alias{42}; - ASSERT(lhs != rhs); - } - -} // namespace base_type_equality_comparison_tests - -auto equality_comparison_suite() -> std::pair<cute::suite, std::string> -{ - 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 <cute/cute.h> - -#include <unordered_map> - -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<int, struct tag>; - ASSERT(!nt::impl::is_hashable_v<type_alias>); - } - - auto a_new__type_that_does_include_hash_in_its_derivation_clause_is_hashable() -> void - { - static_assert(nt::impl::is_hashable_v<int>, "Sanity Check"); - using type_alias = nt::new_type<int, struct tag, deriving(nt::Hash)>; - ASSERT(nt::impl::is_hashable_v<type_alias>); - } - - 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<not_hashable>, "Sanity Check"); - using type_alias = nt::new_type<not_hashable, struct tag, deriving(nt::Hash)>; - ASSERT(!nt::impl::is_hashable_v<type_alias>); - } - -} // 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<int>, "Sanity Check"); - using type_alias = nt::new_type<int, struct tag, deriving(nt::Hash)>; - - auto map = std::unordered_map<type_alias, int>{}; - map[type_alias{42}] = 43; - ASSERT_EQUAL(43, map[type_alias{42}]); - } - -} // namespace usage_tests - -auto hash_suite() -> std::pair<cute::suite, std::string> -{ - 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 <cute/cute.h> - -#include <iosfwd> -#include <sstream> -#include <string> -#include <type_traits> -#include <utility> - -inline namespace traits_extensions -{ - - template<typename T, typename = void> - struct has_stream_input : std::false_type - { - }; - - template<typename T> - struct has_stream_input<T, std::void_t<decltype(std::declval<std::istream &>() >> std::declval<T &>())>> : std::true_type - { - }; - - template<typename T> - auto constexpr has_stream_input_v = has_stream_input<T>::value; - - template<typename T, typename = void> - struct has_stream_output : std::false_type - { - }; - - template<typename T> - struct has_stream_output<T, std::void_t<decltype(std::declval<std::ostream &>() << std::declval<T &>())>> : std::true_type - { - }; - - template<typename T> - auto constexpr has_stream_output_v = has_stream_output<T>::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<int, struct input_op_test_tag_1, deriving(nt::Read)>; - ASSERT(has_stream_input_v<type_alias>); - } - - 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<int, struct input_op_test_tag_2>; - ASSERT(!has_stream_input_v<type_alias>); - } - - 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<int>, "Sanity Check"); - using type_alias = nt::new_type<int, struct input_op_test_tag_3, deriving(nt::Read)>; - - 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<int, struct output_op_test_tag_4, deriving(nt::Show)>; - ASSERT(has_stream_output_v<type_alias>); - } - - 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<int, struct output_op_test_tag_5>; - ASSERT(!has_stream_output_v<type_alias>); - } - - 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<int>, "Sanity Check"); - using type_alias = nt::new_type<int, struct output_op_test_tag_6, deriving(nt::Show)>; - - 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<cute::suite, std::string> -{ - 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 <cute/cute.h> - -#include <algorithm> -#include <array> -#include <iterator> -#include <numeric> - -namespace -{ - - struct with_member - { - using iterator = char *; - using const_iterator = char const *; - using reverse_iterator = std::reverse_iterator<iterator>; - using const_reverse_iterator = std::reverse_iterator<const_iterator>; - - auto begin() -> iterator; - auto begin() const -> const_iterator; - auto cbegin() const -> const_iterator; - auto rbegin() -> reverse_iterator; - auto rbegin() const -> const_reverse_iterator; - auto crbegin() const -> const_reverse_iterator; - - auto end() -> iterator; - auto end() const -> const_iterator; - auto cend() const -> const_iterator; - auto rend() -> reverse_iterator; - auto rend() const -> const_reverse_iterator; - auto crend() const -> const_reverse_iterator; - }; - - struct with_free - { - using iterator = char *; - using const_iterator = char const *; - using reverse_iterator = std::reverse_iterator<iterator>; - using const_reverse_iterator = std::reverse_iterator<const_iterator>; - }; - - auto begin(with_free &) -> with_free::iterator - { - return {}; - } - - auto begin(with_free const &) -> with_free::const_iterator - { - return {}; - } - - auto cbegin(with_free const &) -> with_free::const_iterator - { - return {}; - } - - auto rbegin(with_free &) -> with_free::reverse_iterator - { - return {}; - } - - auto rbegin(with_free const &) -> with_free::const_reverse_iterator - { - return {}; - } - - auto crbegin(with_free const &) -> with_free::const_reverse_iterator - { - return {}; - } - - auto end(with_free &) -> with_free::iterator - { - return {}; - } - - auto end(with_free const &) -> with_free::const_iterator - { - return {}; - } - - auto cend(with_free const &) -> with_free::const_iterator - { - return {}; - } - - auto rend(with_free &) -> with_free::reverse_iterator - { - return {}; - } - - auto rend(with_free const &) -> with_free::const_reverse_iterator - { - return {}; - } - - auto crend(with_free const &) -> with_free::const_reverse_iterator - { - return {}; - } - -} // namespace - -inline namespace combined_enablement_tests -{ - - auto a_new__type_not_deriving_iterable_has_no_begin() -> void - { - using type_alias = nt::new_type<int, struct tag>; - ASSERT(!(nt::impl::has_begin_v<type_alias>)); - } - - auto a_new__type_not_deriving_iterable_has_no_constant_begin() -> void - { - using type_alias = nt::new_type<int, struct tag>; - ASSERT(!(nt::impl::has_begin_v<type_alias const>)); - } - - auto a_new__type_not_deriving_iterable_has_no_cbegin() -> void - { - using type_alias = nt::new_type<int, struct tag>; - ASSERT(!(nt::impl::has_cbegin_v<type_alias>)); - } - - auto a_new__type_not_deriving_iterable_has_no_rbegin() -> void - { - using type_alias = nt::new_type<int, struct tag>; - ASSERT(!(nt::impl::has_rbegin_v<type_alias>)); - } - - auto a_new__type_not_deriving_iterable_has_no_constant_rbegin() -> void - { - using type_alias = nt::new_type<int, struct tag>; - ASSERT(!(nt::impl::has_rbegin_v<type_alias const>)); - } - - auto a_new__type_not_deriving_iterable_has_no_crbegin() -> void - { - using type_alias = nt::new_type<int, struct tag>; - ASSERT(!(nt::impl::has_crbegin_v<type_alias>)); - } - - auto a_new__type_not_deriving_iterable_has_no_end() -> void - { - using type_alias = nt::new_type<int, struct tag>; - ASSERT(!(nt::impl::has_end_v<type_alias>)); - } - - auto a_new__type_not_deriving_iterable_has_no_constant_end() -> void - { - using type_alias = nt::new_type<int, struct tag>; - ASSERT(!(nt::impl::has_end_v<type_alias const>)); - } - - auto a_new__type_not_deriving_iterable_has_no_cend() -> void - { - using type_alias = nt::new_type<int, struct tag>; - ASSERT(!(nt::impl::has_cend_v<type_alias>)); - } - - auto a_new__type_not_deriving_iterable_has_no_rend() -> void - { - using type_alias = nt::new_type<int, struct tag>; - ASSERT(!(nt::impl::has_rend_v<type_alias>)); - } - - auto a_new__type_not_deriving_iterable_has_no_constant_rend() -> void - { - using type_alias = nt::new_type<int, struct tag>; - ASSERT(!(nt::impl::has_rend_v<type_alias const>)); - } - - auto a_new__type_not_deriving_iterable_has_no_crend() -> void - { - using type_alias = nt::new_type<int, struct tag>; - ASSERT(!(nt::impl::has_crend_v<type_alias>)); - } - - auto a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_begin() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_begin_v<type_alias>)); - } - - auto a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_constant_begin() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_begin_v<type_alias const>)); - } - - auto a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_cbegin() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_cbegin_v<type_alias>)); - } - - auto a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_rbegin() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_rbegin_v<type_alias>)); - } - - auto a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_constant_rbegin() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_rbegin_v<type_alias const>)); - } - - auto a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_crbegin() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_crbegin_v<type_alias>)); - } - - auto a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_end() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_end_v<type_alias>)); - } - - auto a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_constant_end() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_end_v<type_alias const>)); - } - - auto a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_cend() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_cend_v<type_alias>)); - } - - auto a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_rend() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_rend_v<type_alias>)); - } - - auto a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_constant_rend() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_rend_v<type_alias const>)); - } - - auto a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_crend() -> void - { - using type_alias = nt::new_type<int, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_crend_v<type_alias>)); - } - -} // namespace combined_enablement_tests - -inline namespace member_enablement_tests -{ - - auto a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_begin() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_member_begin_v<type_alias>)); - } - - auto a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_constant_begin() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_member_begin_v<type_alias const>)); - } - - auto a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_cbegin() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_member_cbegin_v<type_alias>)); - } - - auto a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_rbegin() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_member_rbegin_v<type_alias>)); - } - - auto a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_constant_rbegin() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_member_rbegin_v<type_alias const>)); - } - - auto a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_crbegin() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_member_crbegin_v<type_alias>)); - } - - auto a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_end() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_member_end_v<type_alias>)); - } - - auto a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_constant_end() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_member_end_v<type_alias const>)); - } - - auto a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_cend() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_member_cend_v<type_alias>)); - } - - auto a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_rend() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_member_rend_v<type_alias>)); - } - - auto a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_constant_rend() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_member_rend_v<type_alias const>)); - } - - auto a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_crend() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_member_crend_v<type_alias>)); - } - - auto a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_begin() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_member_begin_v<type_alias>); - } - - auto a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_constant_begin() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_member_begin_v<type_alias const>); - } - - auto a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_cbegin() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_member_cbegin_v<type_alias>); - } - - auto a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_rbegin() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_member_rbegin_v<type_alias>); - } - - auto a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_constant_rbegin() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_member_rbegin_v<type_alias const>); - } - - auto a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_crbegin() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_member_crbegin_v<type_alias>); - } - - auto a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_end() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_member_end_v<type_alias>); - } - - auto a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_constant_end() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_member_end_v<type_alias const>); - } - - auto a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_cend() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_member_cend_v<type_alias>); - } - - auto a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_rend() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_member_rend_v<type_alias>); - } - - auto a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_constant_rend() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_member_rend_v<type_alias const>); - } - - auto a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_crend() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_member_crend_v<type_alias>); - } - -} // namespace member_enablement_tests - -inline namespace free_enablement_tests -{ - auto a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_begin() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_free_begin_v<type_alias>)); - } - - auto a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_constant_begin() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_free_begin_v<type_alias const>)); - } - - auto a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_cbegin() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_free_cbegin_v<type_alias>)); - } - - auto a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_rbegin() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_free_rbegin_v<type_alias>)); - } - - auto a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_constant_rbegin() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_free_rbegin_v<type_alias const>)); - } - - auto a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_crbegin() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_free_crbegin_v<type_alias>)); - } - - auto a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_end() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_free_end_v<type_alias>)); - } - - auto a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_constant_end() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_free_end_v<type_alias const>)); - } - - auto a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_cend() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_free_cend_v<type_alias>)); - } - - auto a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_rend() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_free_rend_v<type_alias>)); - } - - auto a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_constant_rend() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_free_rend_v<type_alias const>)); - } - - auto a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_crend() -> void - { - using type_alias = nt::new_type<with_member, struct tag, deriving(nt::Iterable)>; - ASSERT(!(nt::impl::has_free_crend_v<type_alias>)); - } - - auto a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_begin() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_free_begin_v<type_alias>); - } - - auto a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_constant_begin() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_free_begin_v<type_alias const>); - } - - auto a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_cbegin() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_free_cbegin_v<type_alias>); - } - - auto a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_rbegin() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_free_rbegin_v<type_alias>); - } - - auto a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_constant_rbegin() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_free_rbegin_v<type_alias const>); - } - - auto a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_crbegin() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_free_crbegin_v<type_alias>); - } - - auto a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_end() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_free_end_v<type_alias>); - } - - auto a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_constant_end() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_free_end_v<type_alias const>); - } - - auto a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_cend() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_free_cend_v<type_alias>); - } - - auto a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_rend() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_free_rend_v<type_alias>); - } - - auto a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_constant_rend() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_free_rend_v<type_alias const>); - } - - auto a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_crend() -> void - { - using type_alias = nt::new_type<with_free, struct tag, deriving(nt::Iterable)>; - ASSERT(nt::impl::has_free_crend_v<type_alias>); - } - -} // namespace free_enablement_tests - -inline namespace semantic_tests -{ - - auto a_non_const_object_of_iterable_new__type_can_be_used_in_value_range_for() -> void - { - using type_alias = nt::new_type<std::array<int, 3>, struct tag, deriving(nt::Iterable)>; - auto object = type_alias{{1, 2, 3}}; - for (auto e : object) - { - (void)e; - } - ASSERT(true); - } - - auto a_const_object_of_iterable_new__type_can_be_used_in_value_range_for() -> void - { - using type_alias = nt::new_type<std::array<int, 3>, struct tag, deriving(nt::Iterable)>; - auto const object = type_alias{{1, 2, 3}}; - for (auto e : object) - { - (void)e; - } - ASSERT(true); - } - - auto a_non_const_object_of_iterable_new__type_can_be_used_in_reference_range_for() -> void - { - using type_alias = nt::new_type<std::array<int, 3>, struct tag, deriving(nt::Iterable)>; - auto object = type_alias{{1, 2, 3}}; - for (auto & e : object) - { - (void)e; - } - ASSERT(true); - } - - auto a_const_object_of_iterable_new__type_can_be_used_in_const_reference_range_for() -> void - { - using type_alias = nt::new_type<std::array<int, 3>, struct tag, deriving(nt::Iterable)>; - auto const object = type_alias{{1, 2, 3}}; - for (auto const & e : object) - { - (void)e; - } - ASSERT(true); - } - - auto applying_accumulate_to_an_interable_new__type_yields_the_same_result_as_when_applied_to_the_base_type() -> void - { - using type_alias = nt::new_type<std::array<int, 3>, struct tag, deriving(nt::Iterable)>; - auto const nt_object = type_alias{{1, 2, 3}}; - auto const bt_object = type_alias::base_type{1, 2, 3}; - - auto nt_result = std::accumulate(std::cbegin(nt_object), std::cend(nt_object), 0); - auto bt_result = std::accumulate(std::cbegin(bt_object), std::cend(bt_object), 0); - - ASSERT_EQUAL(bt_result, nt_result); - } - - auto iterating_over_an_iterable_new__type_yields_the_elements_in_the_same_order_as_when_iterating_the_base_type() -> void - { - using std::cbegin, std::cend, std::equal; - using type_alias = nt::new_type<std::array<int, 3>, struct tag, deriving(nt::Iterable)>; - auto const nt_object = type_alias{{1, 2, 3}}; - auto const bt_object = type_alias::base_type{1, 2, 3}; - - ASSERT(equal(cbegin(nt_object), cend(nt_object), cbegin(bt_object), cend(bt_object))); - } - -} // namespace semantic_tests - -auto iterable_suite() -> std::pair<cute::suite, std::string> -{ - return {{ - /// Combined Enablement Tests - KAWAII(a_new__type_not_deriving_iterable_has_no_begin), - KAWAII(a_new__type_not_deriving_iterable_has_no_constant_begin), - KAWAII(a_new__type_not_deriving_iterable_has_no_cbegin), - KAWAII(a_new__type_not_deriving_iterable_has_no_rbegin), - KAWAII(a_new__type_not_deriving_iterable_has_no_constant_rbegin), - KAWAII(a_new__type_not_deriving_iterable_has_no_crbegin), - KAWAII(a_new__type_not_deriving_iterable_has_no_end), - KAWAII(a_new__type_not_deriving_iterable_has_no_constant_end), - KAWAII(a_new__type_not_deriving_iterable_has_no_cend), - KAWAII(a_new__type_not_deriving_iterable_has_no_rend), - KAWAII(a_new__type_not_deriving_iterable_has_no_constant_rend), - KAWAII(a_new__type_not_deriving_iterable_has_no_crend), - KAWAII(a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_begin), - KAWAII(a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_constant_begin), - KAWAII(a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_cbegin), - KAWAII(a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_rbegin), - KAWAII(a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_constant_rbegin), - KAWAII(a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_crbegin), - KAWAII(a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_end), - KAWAII(a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_constant_end), - KAWAII(a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_cend), - KAWAII(a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_rend), - KAWAII(a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_constant_rend), - KAWAII(a_new__type_on_a_non_iterable_type_deriving_iterable_has_no_crend), - - /// Member Enablement Tests - KAWAII(a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_begin), - KAWAII(a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_constant_begin), - KAWAII(a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_cbegin), - KAWAII(a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_rbegin), - KAWAII(a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_constant_rbegin), - KAWAII(a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_crbegin), - KAWAII(a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_end), - KAWAII(a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_constant_end), - KAWAII(a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_cend), - KAWAII(a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_rend), - KAWAII(a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_constant_rend), - KAWAII(a_new__type_on_a_non_member_iterable_type_deriving_iterable_has_no_member_crend), - KAWAII(a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_begin), - KAWAII(a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_constant_begin), - KAWAII(a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_cbegin), - KAWAII(a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_rbegin), - KAWAII(a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_constant_rbegin), - KAWAII(a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_crbegin), - KAWAII(a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_end), - KAWAII(a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_constant_end), - KAWAII(a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_cend), - KAWAII(a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_rend), - KAWAII(a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_constant_rend), - KAWAII(a_new__type_on_a_member_iterable_type_deriving_iterable_has_member_crend), - - /// Free Enablement Tests - KAWAII(a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_begin), - KAWAII(a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_constant_begin), - KAWAII(a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_cbegin), - KAWAII(a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_rbegin), - KAWAII(a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_constant_rbegin), - KAWAII(a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_crbegin), - KAWAII(a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_end), - KAWAII(a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_constant_end), - KAWAII(a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_cend), - KAWAII(a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_rend), - KAWAII(a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_constant_rend), - KAWAII(a_new__type_on_a_non_free_iterable_type_deriving_iterable_has_no_free_crend), - KAWAII(a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_begin), - KAWAII(a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_constant_begin), - KAWAII(a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_cbegin), - KAWAII(a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_rbegin), - KAWAII(a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_constant_rbegin), - KAWAII(a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_crbegin), - KAWAII(a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_end), - KAWAII(a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_constant_end), - KAWAII(a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_cend), - KAWAII(a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_rend), - KAWAII(a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_constant_rend), - KAWAII(a_new__type_on_a_free_iterable_type_deriving_iterable_has_free_crend), - - /// Semantic Tests - KAWAII(a_non_const_object_of_iterable_new__type_can_be_used_in_value_range_for), - KAWAII(a_const_object_of_iterable_new__type_can_be_used_in_value_range_for), - KAWAII(a_non_const_object_of_iterable_new__type_can_be_used_in_reference_range_for), - KAWAII(a_const_object_of_iterable_new__type_can_be_used_in_const_reference_range_for), - KAWAII(applying_accumulate_to_an_interable_new__type_yields_the_same_result_as_when_applied_to_the_base_type), - KAWAII(iterating_over_an_iterable_new__type_yields_the_elements_in_the_same_order_as_when_iterating_the_base_type), - }, - - "Iterable Tests"}; -}
\ No newline at end of file diff --git a/test/src/new_type_constructor_suite.cpp b/test/src/new_type_constructor_suite.cpp deleted file mode 100644 index fc3e9f6..0000000 --- a/test/src/new_type_constructor_suite.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include "new_type_constructor_suite.hpp" - -#include "kawaii.hpp" -#include "newtype/derivable.hpp" -#include "newtype/newtype.hpp" - -#include <cute/cute.h> - -#include <type_traits> - -inline namespace constructor_tests -{ - - struct not_default_constructible - { - not_default_constructible() = delete; - }; - - auto a_new__type_based_on_a_type_that_is_default_constructible_is_default_constructible_too() -> void - { - using nt_float = nt::new_type<float, struct nt_float_tag>; - - ASSERT(std::is_default_constructible_v<nt_float>); - } - - auto a_new__type_based_on_a_type_that_is_not_default_constructible_is_not_default_constructible_too() -> void - { - using nt_not_default_constructible = nt::new_type<not_default_constructible, struct nt_not_default_constructible_tag>; - - ASSERT(!std::is_default_constructible_v<nt_not_default_constructible>); - } - - template<typename OldType> - auto a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type() -> void - { - using nt_old = nt::new_type<OldType, struct nt_old_tag>; - - ASSERT((std::is_constructible_v<nt_old, OldType>)); - } - - auto a_new__type_instance_can_be_copy_constructed_if_the_base_type_can_be_copy_constructed() -> void - { - using type_alias = nt::new_type<int, struct tag_type>; - ASSERT((std::is_copy_constructible_v<type_alias>)); - } - - auto a_new__type_instance_can_not_be_copy_constructed_if_the_base_type_can_not_be_copy_constructed() -> void - { - struct not_copy_constructible - { - not_copy_constructible() = default; - not_copy_constructible(not_copy_constructible const &) = delete; - not_copy_constructible(not_copy_constructible &&) = default; - auto operator=(not_copy_constructible const &) -> not_copy_constructible & = default; - auto operator=(not_copy_constructible &&) -> not_copy_constructible & = default; - }; - - using type_alias = nt::new_type<not_copy_constructible, struct tag_type>; - ASSERT(!(std::is_copy_constructible_v<type_alias>)); - } - -} // namespace constructor_tests - -auto new_type_constructor_suite() -> std::pair<cute::suite, std::string> -{ - return {{ - KAWAII(a_new__type_based_on_a_type_that_is_default_constructible_is_default_constructible_too), - KAWAII(a_new__type_based_on_a_type_that_is_not_default_constructible_is_not_default_constructible_too), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<bool>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<char>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<unsigned char>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<signed char>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<wchar_t>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<char16_t>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<char32_t>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<short>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<unsigned short>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<int>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<unsigned int>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<long>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<unsigned long>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<long long>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<unsigned long long>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<float>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<double>), - KAWAII(a_new__type_based_on_a_fundamental_type_can_be_constructed_with_a_value_of_fundamental_type<long double>), - KAWAII(a_new__type_instance_can_be_copy_constructed_if_the_base_type_can_be_copy_constructed), - KAWAII(a_new__type_instance_can_not_be_copy_constructed_if_the_base_type_can_not_be_copy_constructed), - }, - "new_type Constructor Tests"}; -}
\ No newline at end of file diff --git a/test/src/relational_operators_suite.cpp b/test/src/relational_operators_suite.cpp deleted file mode 100644 index 64fcba0..0000000 --- a/test/src/relational_operators_suite.cpp +++ /dev/null @@ -1,321 +0,0 @@ -#include "relational_operators_suite.hpp" - -#include "kawaii.hpp" -#include "newtype/derivable.hpp" -#include "newtype/deriving.hpp" -#include "newtype/newtype.hpp" - -#include <cute/cute.h> - -#include <string> -#include <type_traits> -#include <utility> - -inline namespace traits_extensions -{ - - template<typename T, typename = void> - struct has_less_than : std::false_type - { - }; - - template<typename T> - struct has_less_than<T, std::void_t<decltype(std::declval<T const &>() < std::declval<T const &>())>> : std::true_type - { - }; - - template<typename T> - auto constexpr has_less_than_v = has_less_than<T>::value; - - template<typename T, typename = void> - struct has_greater_than : std::false_type - { - }; - - template<typename T> - struct has_greater_than<T, std::void_t<decltype(std::declval<T const &>() > std::declval<T const &>())>> : std::true_type - { - }; - - template<typename T> - auto constexpr has_greater_than_v = has_greater_than<T>::value; - - template<typename T, typename = void> - struct has_less_than_equal_to : std::false_type - { - }; - - template<typename T> - struct has_less_than_equal_to<T, std::void_t<decltype(std::declval<T const &>() <= std::declval<T const &>())>> : std::true_type - { - }; - - template<typename T> - auto constexpr has_less_than_equal_to_v = has_less_than_equal_to<T>::value; - - template<typename T, typename = void> - struct has_greater_than_equal_to : std::false_type - { - }; - - template<typename T> - struct has_greater_than_equal_to<T, std::void_t<decltype(std::declval<T const &>() >= std::declval<T const &>())>> : std::true_type - { - }; - - template<typename T> - auto constexpr has_greater_than_equal_to_v = has_greater_than_equal_to<T>::value; - -} // namespace traits_extensions - -inline namespace relational_operator_presence_tests -{ - - auto an_instance_of_new__type_has_less_than_if_its_derivation_clause_contains_relational() -> void - { - using type_alias = nt::new_type<int, struct relop_presensence_test_tag_1, deriving(nt::Relational)>; - ASSERT(has_less_than_v<type_alias>); - } - - auto an_instance_of_new__type_does_not_have_less_than_if_its_derivation_clause_does_not_contain_relational() -> void - { - using type_alias = nt::new_type<int, struct relop_presensence_test_tag_2>; - ASSERT(!has_less_than_v<type_alias>); - } - - auto an_instance_of_new__type_has_greater_than_if_its_derivation_clause_contains_relational() -> void - { - using type_alias = nt::new_type<int, struct relop_presensence_test_tag_3, deriving(nt::Relational)>; - ASSERT(has_greater_than_v<type_alias>); - } - - auto an_instance_of_new__type_does_not_have_greater_than_if_its_derivation_clause_does_not_contain_relational() -> void - { - using type_alias = nt::new_type<int, struct relop_presensence_test_tag_4>; - ASSERT(!has_greater_than_v<type_alias>); - } - - auto an_instance_of_new__type_has_less_than_or_equal_to_if_its_derivation_clause_contains_relational() -> void - { - using type_alias = nt::new_type<int, struct relop_presensence_test_tag_5, deriving(nt::Relational)>; - ASSERT(has_less_than_equal_to_v<type_alias>); - } - - auto an_instance_of_new__type_does_not_have_less_than_or_equal_to_if_its_derivation_clause_does_not_contain_relational() -> void - { - using type_alias = nt::new_type<int, struct relop_presensence_test_tag_6>; - ASSERT(!has_less_than_equal_to_v<type_alias>); - } - - auto an_instance_of_new__type_has_greater_than_or_equal_to_if_its_derivation_clause_contains_relational() -> void - { - using type_alias = nt::new_type<int, struct relop_presensence_test_tag_7, deriving(nt::Relational)>; - ASSERT(has_greater_than_equal_to_v<type_alias>); - } - - auto an_instance_of_new__type_does_not_have_greater_than_or_equal_to_if_its_derivation_clause_does_not_contain_relational() -> void - { - using type_alias = nt::new_type<int, struct relop_presensence_test_tag_8>; - ASSERT(!has_greater_than_equal_to_v<type_alias>); - } - -} // namespace relational_operator_presence_tests - -inline namespace less_than_tests -{ - - auto two_instances_of_the_same_new__type_compare_less_than_if_both_contained_values_would_compare_less_than() -> void - { - using type_alias = nt::new_type<int, struct less_than_test_tag_9, deriving(nt::Relational)>; - auto constexpr lhs{21}; - auto constexpr rhs{42}; - static_assert(lhs < rhs, "Sanity Check"); - ASSERT_LESS(type_alias{lhs}, type_alias{rhs}); - } - - auto two_instances_of_the_same_new__type_do_not_compare_less_than_if_both_contained_values_would_not_compare_less_than() -> void - { - using type_alias = nt::new_type<int, struct less_than_test_tag_10, deriving(nt::Relational)>; - auto constexpr lhs{44}; - auto constexpr rhs{42}; - static_assert(!(lhs < rhs), "Sanity Check"); - ASSERT(!(type_alias{lhs} < type_alias{rhs})); - } - - auto two_instances_of_the_same_new__type_compare_less_than_or_equal_if_both_contained_values_would_compare_less_than_or_equal() -> void - { - using type_alias = nt::new_type<int, struct less_than_test_tag_11, deriving(nt::Relational)>; - auto constexpr lhs{33}; - auto constexpr rhs{42}; - static_assert(lhs <= rhs, "Sanity Check"); - ASSERT_LESS_EQUAL(type_alias{lhs}, type_alias{rhs}); - } - - auto two_instances_of_the_same_new__type_do_not_compare_less_than_or_equal_if_both_contained_values_would_not_compare_less_than_or_equal() - -> void - { - using type_alias = nt::new_type<int, struct less_than_test_tag_12, deriving(nt::Relational)>; - auto constexpr lhs{87}; - auto constexpr rhs{42}; - static_assert(!(lhs < rhs), "Sanity Check"); - ASSERT(!(type_alias{lhs} < type_alias{rhs})); - } - -} // namespace less_than_tests - -inline namespace greater_than_tests -{ - - auto two_instances_of_the_same_new__type_compare_greater_than_if_both_contained_values_would_compare_greater_than() -> void - { - using type_alias = nt::new_type<int, struct greater_than_test_tag_13, deriving(nt::Relational)>; - auto constexpr lhs{42}; - auto constexpr rhs{21}; - static_assert(lhs > rhs, "Sanity Check"); - ASSERT_GREATER(type_alias{lhs}, type_alias{rhs}); - } - - auto two_instances_of_the_same_new__type_do_not_compare_greater_than_if_both_contained_values_would_not_compare_greater_than() -> void - { - using type_alias = nt::new_type<int, struct greater_than_test_tag_14, deriving(nt::Relational)>; - auto constexpr lhs{42}; - auto constexpr rhs{44}; - static_assert(!(lhs > rhs), "Sanity Check"); - ASSERT(!(type_alias{lhs} > type_alias{rhs})); - } - - auto two_instances_of_the_same_new__type_compare_greater_than_or_equal_if_both_contained_values_would_compare_greater_than_or_equal() -> void - { - using type_alias = nt::new_type<int, struct greater_than_test_tag_15, deriving(nt::Relational)>; - auto constexpr lhs{42}; - auto constexpr rhs{33}; - static_assert(lhs >= rhs, "Sanity Check"); - ASSERT_GREATER_EQUAL(type_alias{lhs}, type_alias{rhs}); - } - - auto - two_instances_of_the_same_new__type_do_not_compare_greater_than_or_equal_if_both_contained_values_would_not_compare_greater_than_or_equal() - -> void - { - using type_alias = nt::new_type<int, struct greater_than_test_tag_16, deriving(nt::Relational)>; - auto constexpr lhs{42}; - auto constexpr rhs{87}; - static_assert(!(lhs > rhs), "Sanity Check"); - ASSERT(!(type_alias{lhs} > type_alias{rhs})); - } - -} // namespace greater_than_tests - -inline namespace relational_operator_noexcept_tests -{ - - struct strange_type - { - auto constexpr operator<(strange_type const & other) const noexcept(false) -> bool; - auto constexpr operator>(strange_type const & other) const noexcept(false) -> bool; - auto constexpr operator<=(strange_type const & other) const noexcept(false) -> bool; - auto constexpr operator>=(strange_type const & other) const noexcept(false) -> bool; - }; - - auto less_than_comparison_of_two_intances_of_the_same_new__type_is_noexcept_if_comparison_of_the_base_type_is_noexcept() -> void - { - using type_alias = nt::new_type<int, struct greater_than_test_tag_17, deriving(nt::Relational)>; - static_assert(noexcept(std::declval<int const &>() < std::declval<int const &>()), "Sanity Check"); - ASSERT(noexcept(std::declval<type_alias const &>() < std::declval<type_alias const &>())); - } - - auto less_than_comparison_of_two_intances_of_the_same_new__type_is_not_noexcept_if_comparison_of_the_base_type_is_not_noexcept() -> void - { - using type_alias = nt::new_type<strange_type, struct greater_than_test_tag_18, deriving(nt::Relational)>; - static_assert(!noexcept(std::declval<strange_type const &>() < std::declval<strange_type const &>()), "Sanity Check"); - ASSERT(!noexcept(std::declval<type_alias const &>() < std::declval<type_alias const &>())); - } - - auto less_than_equal_to_comparison_of_two_intances_of_the_same_new__type_is_noexcept_if_comparison_of_the_base_type_is_noexcept() -> void - { - using type_alias = nt::new_type<int, struct greater_than_test_tag_19, deriving(nt::Relational)>; - static_assert(noexcept(std::declval<int const &>() <= std::declval<int const &>()), "Sanity Check"); - ASSERT(noexcept(std::declval<type_alias const &>() <= std::declval<type_alias const &>())); - } - - auto less_than_equal_to_comparison_of_two_intances_of_the_same_new__type_is_not_noexcept_if_comparison_of_the_base_type_is_not_noexcept() - -> void - { - using type_alias = nt::new_type<strange_type, struct greater_than_test_tag_20, deriving(nt::Relational)>; - static_assert(!noexcept(std::declval<strange_type const &>() <= std::declval<strange_type const &>()), "Sanity Check"); - ASSERT(!noexcept(std::declval<type_alias const &>() <= std::declval<type_alias const &>())); - } - - auto greater_than_comparison_of_two_intances_of_the_same_new__type_is_noexcept_if_comparison_of_the_base_type_is_noexcept() -> void - { - using type_alias = nt::new_type<int, struct greater_than_test_tag_21, deriving(nt::Relational)>; - static_assert(noexcept(std::declval<int const &>() > std::declval<int const &>()), "Sanity Check"); - ASSERT(noexcept(std::declval<type_alias const &>() > std::declval<type_alias const &>())); - } - - auto greater_than_comparison_of_two_intances_of_the_same_new__type_is_not_noexcept_if_comparison_of_the_base_type_is_not_noexcept() -> void - { - using type_alias = nt::new_type<strange_type, struct greater_than_test_tag_22, deriving(nt::Relational)>; - static_assert(!noexcept(std::declval<strange_type const &>() > std::declval<strange_type const &>()), "Sanity Check"); - ASSERT(!noexcept(std::declval<type_alias const &>() > std::declval<type_alias const &>())); - } - - auto greater_than_equal_to_comparison_of_two_intances_of_the_same_new__type_is_noexcept_if_comparison_of_the_base_type_is_noexcept() -> void - { - using type_alias = nt::new_type<int, struct greater_than_test_tag_23, deriving(nt::Relational)>; - static_assert(noexcept(std::declval<int const &>() >= std::declval<int const &>()), "Sanity Check"); - ASSERT(noexcept(std::declval<type_alias const &>() >= std::declval<type_alias const &>())); - } - - auto greater_than_equal_to_comparison_of_two_intances_of_the_same_new__type_is_not_noexcept_if_comparison_of_the_base_type_is_not_noexcept() - -> void - { - using type_alias = nt::new_type<strange_type, struct greater_than_test_tag_24, deriving(nt::Relational)>; - static_assert(!noexcept(std::declval<strange_type const &>() >= std::declval<strange_type const &>()), "Sanity Check"); - ASSERT(!noexcept(std::declval<type_alias const &>() >= std::declval<type_alias const &>())); - } - -} // namespace relational_operator_noexcept_tests - -auto relational_operators_suite() -> std::pair<cute::suite, std::string> -{ - return { - { - // clang-format off - - // Relational Operator Presensence Tests - KAWAII(an_instance_of_new__type_has_less_than_if_its_derivation_clause_contains_relational), - KAWAII(an_instance_of_new__type_does_not_have_less_than_if_its_derivation_clause_does_not_contain_relational), - KAWAII(an_instance_of_new__type_has_greater_than_if_its_derivation_clause_contains_relational), - KAWAII(an_instance_of_new__type_does_not_have_greater_than_if_its_derivation_clause_does_not_contain_relational), - KAWAII(an_instance_of_new__type_has_less_than_or_equal_to_if_its_derivation_clause_contains_relational), - KAWAII(an_instance_of_new__type_does_not_have_less_than_or_equal_to_if_its_derivation_clause_does_not_contain_relational), - KAWAII(an_instance_of_new__type_has_greater_than_or_equal_to_if_its_derivation_clause_contains_relational), - KAWAII(an_instance_of_new__type_does_not_have_greater_than_or_equal_to_if_its_derivation_clause_does_not_contain_relational), - - // Less-than Comparison Tests - KAWAII(two_instances_of_the_same_new__type_compare_less_than_if_both_contained_values_would_compare_less_than), - KAWAII(two_instances_of_the_same_new__type_do_not_compare_less_than_if_both_contained_values_would_not_compare_less_than), - KAWAII(two_instances_of_the_same_new__type_compare_less_than_or_equal_if_both_contained_values_would_compare_less_than_or_equal), - KAWAII(two_instances_of_the_same_new__type_do_not_compare_less_than_or_equal_if_both_contained_values_would_not_compare_less_than_or_equal), - - // Greater-than Comparison Tests - KAWAII(two_instances_of_the_same_new__type_compare_greater_than_if_both_contained_values_would_compare_greater_than), - KAWAII(two_instances_of_the_same_new__type_do_not_compare_greater_than_if_both_contained_values_would_not_compare_greater_than), - KAWAII(two_instances_of_the_same_new__type_compare_greater_than_or_equal_if_both_contained_values_would_compare_greater_than_or_equal), - KAWAII(two_instances_of_the_same_new__type_do_not_compare_greater_than_or_equal_if_both_contained_values_would_not_compare_greater_than_or_equal), - - // Relational Operators noexcept Tests - KAWAII(less_than_comparison_of_two_intances_of_the_same_new__type_is_noexcept_if_comparison_of_the_base_type_is_noexcept), - KAWAII(less_than_comparison_of_two_intances_of_the_same_new__type_is_not_noexcept_if_comparison_of_the_base_type_is_not_noexcept), - KAWAII(less_than_equal_to_comparison_of_two_intances_of_the_same_new__type_is_noexcept_if_comparison_of_the_base_type_is_noexcept), - KAWAII(less_than_equal_to_comparison_of_two_intances_of_the_same_new__type_is_not_noexcept_if_comparison_of_the_base_type_is_not_noexcept), - KAWAII(greater_than_comparison_of_two_intances_of_the_same_new__type_is_noexcept_if_comparison_of_the_base_type_is_noexcept), - KAWAII(greater_than_comparison_of_two_intances_of_the_same_new__type_is_not_noexcept_if_comparison_of_the_base_type_is_not_noexcept), - KAWAII(greater_than_equal_to_comparison_of_two_intances_of_the_same_new__type_is_noexcept_if_comparison_of_the_base_type_is_noexcept), - KAWAII(greater_than_equal_to_comparison_of_two_intances_of_the_same_new__type_is_not_noexcept_if_comparison_of_the_base_type_is_not_noexcept), - - // clang-format on - }, - "Relational Operators Tests"}; -}
\ No newline at end of file |
