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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
// Licensed under the MIT License.
// Copyright David LeBlanc - dcl@dleblanc.net
#if defined _MSC_VER
// Inline expansion warnings
#pragma warning(disable:4710 4711)
#endif
#include "safe_math_test.h"
#include "../TestCase.h"
extern "C" void sub_test();
static void sub_test_uint64_uint64()
{
typedef bool (*test_fcn)(std::uint64_t, std::uint64_t, std::uint64_t*);
typedef std::uint64_t(*check_fcn)(std::uint64_t, std::uint64_t);
test_base<std::uint64_t, std::uint64_t, test_fcn, check_fcn, OpType::Sub>("uint64_uint64", &check_sub_uint64_uint64, &safe_sub_uint64_uint64);
}
static void sub_test_uint64_uint32()
{
typedef bool (*test_fcn)(std::uint64_t, std::uint32_t, std::uint64_t*);
typedef std::uint64_t(*check_fcn)(std::uint64_t, std::uint32_t);
test_base<std::uint64_t, std::uint32_t, test_fcn, check_fcn, OpType::Sub>("uint64_uint32", &check_sub_uint64_uint32, &safe_sub_uint64_uint32);
}
static void sub_test_uint64_int64()
{
typedef bool (*test_fcn)(std::uint64_t, std::int64_t, std::uint64_t*);
typedef std::uint64_t(*check_fcn)(std::uint64_t, std::int64_t);
test_base<std::uint64_t, std::int64_t, test_fcn, check_fcn, OpType::Sub>("uint64_int64", &check_sub_uint64_int64, &safe_sub_uint64_int64);
}
static void sub_test_uint64_int32()
{
typedef bool (*test_fcn)(std::uint64_t, std::int32_t, std::uint64_t*);
typedef std::uint64_t(*check_fcn)(std::uint64_t, std::int32_t);
test_base<std::uint64_t, std::int32_t, test_fcn, check_fcn, OpType::Sub>("uint64_int32", &check_sub_uint64_int32, &safe_sub_uint64_int32);
}
static void sub_test_int64_uint64()
{
typedef bool (*test_fcn)(std::int64_t, std::uint64_t, std::int64_t*);
typedef std::int64_t(*check_fcn)(std::int64_t, std::uint64_t);
test_base<std::int64_t, std::uint64_t, test_fcn, check_fcn, OpType::Sub>("int64_uint64", &check_sub_int64_uint64, &safe_sub_int64_uint64);
}
static void sub_test_int64_uint32()
{
typedef bool (*test_fcn)(std::int64_t, std::uint32_t, std::int64_t*);
typedef std::int64_t(*check_fcn)(std::int64_t, std::uint32_t);
test_base<std::int64_t, std::uint32_t, test_fcn, check_fcn, OpType::Sub>("int64_uint32", &check_sub_int64_uint32, &safe_sub_int64_uint32);
}
static void sub_test_int64_int64()
{
typedef bool (*test_fcn)(std::int64_t, std::int64_t, std::int64_t*);
typedef std::int64_t(*check_fcn)(std::int64_t, std::int64_t);
test_base<std::int64_t, std::int64_t, test_fcn, check_fcn, OpType::Sub>("int64_int64", &check_sub_int64_int64, &safe_sub_int64_int64);
}
static void sub_test_int64_int32()
{
typedef bool (*test_fcn)(std::int64_t, std::int32_t, std::int64_t*);
typedef std::int64_t(*check_fcn)(std::int64_t, std::int32_t);
test_base<std::int64_t, std::int32_t, test_fcn, check_fcn, OpType::Sub>("int64_int32", &check_sub_int64_int32, &safe_sub_int64_int32);
}
static void sub_test_uint32_uint64()
{
typedef bool (*test_fcn)(std::uint32_t, std::uint64_t, std::uint32_t*);
typedef std::uint32_t(*check_fcn)(std::uint32_t, std::uint64_t);
test_base<std::uint32_t, std::uint64_t, test_fcn, check_fcn, OpType::Sub>("uint32_uint64", &check_sub_uint32_uint64, &safe_sub_uint32_uint64);
}
static void sub_test_uint32_uint32()
{
typedef bool (*test_fcn)(std::uint32_t, std::uint32_t, std::uint32_t*);
typedef std::uint32_t(*check_fcn)(std::uint32_t, std::uint32_t);
test_base<std::uint32_t, std::uint32_t, test_fcn, check_fcn, OpType::Sub>("uint32_uint32", &check_sub_uint32_uint32, &safe_sub_uint32_uint32);
}
static void sub_test_uint32_int64()
{
typedef bool (*test_fcn)(std::uint32_t, std::int64_t, std::uint32_t*);
typedef std::uint32_t(*check_fcn)(std::uint32_t, std::int64_t);
test_base<std::uint32_t, std::int64_t, test_fcn, check_fcn, OpType::Sub>("uint32_int64", &check_sub_uint32_int64, &safe_sub_uint32_int64);
}
static void sub_test_uint32_int32()
{
typedef bool (*test_fcn)(std::uint32_t, std::int32_t, std::uint32_t*);
typedef std::uint32_t(*check_fcn)(std::uint32_t, std::int32_t);
test_base<std::uint32_t, std::int32_t, test_fcn, check_fcn, OpType::Sub>("uint32_int32", &check_sub_uint32_int32, &safe_sub_uint32_int32);
}
static void sub_test_int32_uint64()
{
typedef bool (*test_fcn)(std::int32_t, std::uint64_t, std::int32_t*);
typedef std::int32_t(*check_fcn)(std::int32_t, std::uint64_t);
test_base<std::int32_t, std::uint64_t, test_fcn, check_fcn, OpType::Sub>("int32_uint64", &check_sub_int32_uint64, &safe_sub_int32_uint64);
}
static void sub_test_int32_uint32()
{
trace t(false);
typedef bool (*test_fcn)(std::int32_t, std::uint32_t, std::int32_t*);
typedef std::int32_t(*check_fcn)(std::int32_t, std::uint32_t);
test_base<std::int32_t, std::uint32_t, test_fcn, check_fcn, OpType::Sub>("int32_uint32", &check_sub_int32_uint32, &safe_sub_int32_uint32);
t.trace_msg("completed sub_test_int32_uint64");
}
static void sub_test_int32_int64()
{
typedef bool (*test_fcn)(std::int32_t, std::int64_t, std::int32_t*);
typedef std::int32_t(*check_fcn)(std::int32_t, std::int64_t);
test_base<std::int32_t, std::int64_t, test_fcn, check_fcn, OpType::Sub>("int32_int64", &check_sub_int32_int64, &safe_sub_int32_int64);
}
static void sub_test_int32_int32()
{
typedef bool (*test_fcn)(std::int32_t, std::int32_t, std::int32_t*);
typedef std::int32_t(*check_fcn)(std::int32_t, std::int32_t);
test_base<std::int32_t, std::int32_t, test_fcn, check_fcn, OpType::Sub>("int32_int32", &check_sub_int32_int32, &safe_sub_int32_int32);
}
extern "C" void sub_test()
{
try
{
sub_test_uint64_uint64();
sub_test_uint64_uint32();
sub_test_uint64_int64();
sub_test_uint64_int32();
sub_test_int64_uint64();
sub_test_int64_uint32();
sub_test_int64_int64();
sub_test_int64_int32();
sub_test_uint32_uint64();
sub_test_uint32_uint32();
sub_test_uint32_int64();
sub_test_uint32_int32();
sub_test_int32_uint64();
sub_test_int32_uint32();
sub_test_int32_int64();
sub_test_int32_int32();
std::cout << "Subtraction tests completed" << std::endl;
}
catch (std::exception& err)
{
std::cout << "Subtraction tests failed - " << err.what() << std::endl;
}
return;
}
|