MCPcopy Create free account
hub / github.com/dcleblanc/SafeInt / InitializeCastArray

Function InitializeCastArray

Test/CastVerify.cpp:21–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19
20 template <typename T>
21 void InitializeCastArray(CastTest<T>* tests, size_t cTests)
22 {
23 for (unsigned long i = 0; i < cTests; ++i)
24 {
25 switch (i)
26 {
27 case 0:
28 tests[i].x = static_cast<T>(pow(2, 64));
29 tests[i].fExpected = false;
30 break;
31 case 1:
32 tests[i].x = static_cast<T>(pow(2, 63));
33 tests[i].fExpected = true;
34 break;
35 case 2:
36 tests[i].x = 0;
37 tests[i].fExpected = true;
38 break;
39 case 3:
40 // This is peculiar, but (-0.0 < 0.0) == false
41 tests[i].x = -0.0;
42 tests[i].fExpected = true;
43 break;
44 case 4:
45 tests[i].x = static_cast<T>(-0.01);
46 tests[i].fExpected = false;
47 break;
48 default:
49 assert(false);
50 break;
51 }
52 }
53 }
54
55 void TestDouble()
56 {

Callers 2

TestDoubleFunction · 0.85
TestFloatFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestDoubleFunction · 0.68
TestFloatFunction · 0.68