#include <xtd/xtd.tunit>
#include <cstdint>
#include <limits>
using namespace tunit;
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<char>() {return 127;}
template<>
size_t get_max_value<long int>() {return 9223372036854775807;}
template<>
size_t get_max_value<unsigned char>() {return 255;}
namespace unit_tests {
template<typename type_t>
class test;
test_class_attribute<test<bool>> test_bool_class_attr {"test<bool>"};
test_class_attribute<test<int>> test_int_class_attr {"test<int>"};
test_class_attribute<test<long int>> test_double_class_attr {"test<long_int>"};
test_class_attribute<test<char>> test_int8_t_class_attr {"test<sbyte>"};
test_class_attribute<test<unsigned char>> test_uint8_t_class_attr {"test<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(char).name(), std::numeric_limits<char>::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();
}
#define test_method_(method_name)
Add test method to class test.
Definition test_method_attribute.hpp:73
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10