#include <xtd/xtd.tunit>
#include <cstdint>
#include <limits>
template<typename type_t>
size_t get_max_value() {return 0;}
template<>
size_t get_max_value<bool>() {return 1;}
template<>
size_t get_max_value<int>() {return 2147483647;}
template<>
size_t get_max_value<sbyte>() {return 127;}
template<>
size_t get_max_value<long int>() {return 9223372036854775807;}
template<>
size_t get_max_value<byte>() {return 255;}
namespace unit_tests {
template<typename type_t>
class test;
auto register_test = register_test_class_types<test, bool, int, long int, sbyte, byte> {};
template<typename type_t>
class test : public test_class {
static auto expected_max_values = std::map<std::string, size_t> {{
typeid(bool).
name(), std::numeric_limits<bool>::max()}, {
typeid(int).
name(), std::numeric_limits<int>::max()}, {
typeid(
long int).
name(), std::numeric_limits<long int>::max()}, {
typeid(
sbyte).
name(), std::numeric_limits<sbyte>::max()}};
if (expected_max_values.find(typeid(type_t).name()) == expected_max_values.end())
assert::fail("expect max value for this type is not defined.");
assert::are_equal(expected_max_values[
typeid(type_t).
name()], get_max_value<type_t>());
}
};
}
auto main() -> int {
return console_unit_test().run();
}
xtd::string name() noexcept
Gets the thread name of the current thread.
#define test_method_(method_name)
Add test method to class test.
Definition test_method_attribute.hpp:72
std::int8_t sbyte
Represents a 8-bit signed integer.
Definition sbyte.hpp:23
The tunit namespace contains a unit test library.
Definition abort_error.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8