1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
// Copyright (C) 2008 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#include <sstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <dlib/algs.h>
#include "tester.h"
namespace
{
using namespace test;
using namespace dlib;
using namespace std;
logger dlog("test.metaprogramming");
void metaprogramming_test (
)
/*!
ensures
- runs tests on template metaprogramming objects and functions for compliance with the specs
!*/
{
print_spinner();
DLIB_TEST(is_signed_type<signed char>::value == true);
DLIB_TEST(is_signed_type<signed short>::value == true);
DLIB_TEST(is_signed_type<signed int>::value == true);
DLIB_TEST(is_signed_type<signed long>::value == true);
DLIB_TEST(is_unsigned_type<signed char>::value == false);
DLIB_TEST(is_unsigned_type<signed short>::value == false);
DLIB_TEST(is_unsigned_type<signed int>::value == false);
DLIB_TEST(is_unsigned_type<signed long>::value == false);
DLIB_TEST(is_unsigned_type<unsigned char>::value == true);
DLIB_TEST(is_unsigned_type<unsigned short>::value == true);
DLIB_TEST(is_unsigned_type<unsigned int>::value == true);
DLIB_TEST(is_unsigned_type<unsigned long>::value == true);
DLIB_TEST(is_signed_type<unsigned char>::value == false);
DLIB_TEST(is_signed_type<unsigned short>::value == false);
DLIB_TEST(is_signed_type<unsigned int>::value == false);
DLIB_TEST(is_signed_type<unsigned long>::value == false);
COMPILE_TIME_ASSERT(is_signed_type<signed char>::value == true);
COMPILE_TIME_ASSERT(is_signed_type<signed short>::value == true);
COMPILE_TIME_ASSERT(is_signed_type<signed int>::value == true);
COMPILE_TIME_ASSERT(is_signed_type<signed long>::value == true);
COMPILE_TIME_ASSERT(is_unsigned_type<signed char>::value == false);
COMPILE_TIME_ASSERT(is_unsigned_type<signed short>::value == false);
COMPILE_TIME_ASSERT(is_unsigned_type<signed int>::value == false);
COMPILE_TIME_ASSERT(is_unsigned_type<signed long>::value == false);
COMPILE_TIME_ASSERT(is_unsigned_type<unsigned char>::value == true);
COMPILE_TIME_ASSERT(is_unsigned_type<unsigned short>::value == true);
COMPILE_TIME_ASSERT(is_unsigned_type<unsigned int>::value == true);
COMPILE_TIME_ASSERT(is_unsigned_type<unsigned long>::value == true);
COMPILE_TIME_ASSERT(is_signed_type<unsigned char>::value == false);
COMPILE_TIME_ASSERT(is_signed_type<unsigned short>::value == false);
COMPILE_TIME_ASSERT(is_signed_type<unsigned int>::value == false);
COMPILE_TIME_ASSERT(is_signed_type<unsigned long>::value == false);
}
class metaprogramming_tester : public tester
{
public:
metaprogramming_tester (
) :
tester ("test_metaprogramming",
"Runs tests on the metaprogramming objects and functions.")
{}
void perform_test (
)
{
metaprogramming_test();
}
} a;
}
|