MCPcopy Create free account
hub / github.com/El-EnderJ/NeoCalculator / testCASIntBasic

Function testCASIntBasic

tests/BigIntTest.cpp:67–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65// ════════════════════════════════════════════════════════════════════
66
67static void testCASIntBasic() {
68 // T1: Default construction is zero
69 CASInt z;
70 check("T01 CASInt default = 0", z.isZero() && !z.hasError());
71
72 // T2: fromInt + toInt64
73 CASInt a = CASInt::fromInt(42);
74 check("T02 CASInt fromInt(42)", a.toInt64() == 42);
75
76 // T3: add
77 CASInt b = CASInt::fromInt(100);
78 CASInt c = CASInt::add(a, b);
79 check("T03 CASInt add(42,100)=142", c.toInt64() == 142);
80
81 // T4: sub
82 CASInt d = CASInt::sub(b, a);
83 check("T04 CASInt sub(100,42)=58", d.toInt64() == 58);
84
85 // T5: mul
86 CASInt e = CASInt::mul(a, CASInt::fromInt(3));
87 check("T05 CASInt mul(42,3)=126", e.toInt64() == 126);
88
89 // T6: div
90 CASInt f = CASInt::div(b, CASInt::fromInt(4));
91 check("T06 CASInt div(100,4)=25", f.toInt64() == 25);
92
93 // T7: neg
94 CASInt g = CASInt::neg(a);
95 check("T07 CASInt neg(42)=-42", g.toInt64() == -42 && g.isNegative());
96
97 // T8: absVal
98 CASInt h = CASInt::absVal(g);
99 check("T08 CASInt abs(-42)=42", h.toInt64() == 42 && !h.isNegative());
100}
101
102// ════════════════════════════════════════════════════════════════════
103// B — CASInt overflow detection, promotion, demotion

Callers 1

runBigIntTestsFunction · 0.85

Calls 7

addFunction · 0.85
subFunction · 0.85
checkFunction · 0.70
isZeroMethod · 0.45
hasErrorMethod · 0.45
toInt64Method · 0.45
isNegativeMethod · 0.45

Tested by

no test coverage detected