summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-01-23 13:55:37 -0500
committerJonathan Bradley <jcb@pikum.xyz>2025-01-23 13:55:37 -0500
commite780ba321897169ace90baa4b1d85190bc526065 (patch)
treef7a428767f6f0fb5daa76198ed7d4b0e6f2357b0 /test
parent4db94de7c5cd21e176a0b52374e28f7ee6451be3 (diff)
pkmacros: add TypeSafeInt operators: *,/
Diffstat (limited to 'test')
-rw-r--r--test/pkmacros.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/test/pkmacros.cpp b/test/pkmacros.cpp
index 8edcbfd..bbba6f0 100644
--- a/test/pkmacros.cpp
+++ b/test/pkmacros.cpp
@@ -25,6 +25,8 @@ template<typename T, typename T_T>
bool
tsi_test_operators()
{
+ T mtsi01 {0x01};
+ T mtsi10 {0x10};
T mtsi0F {0x0F};
T mtsiF0 {0xF0};
T r;
@@ -38,6 +40,10 @@ tsi_test_operators()
if (r == T{0}) return false;
r = mtsi0F - mtsiF0;
if (r == T{0}) return false;
+ r = mtsi0F * mtsiF0;
+ if (r == T{0}) return false;
+ r = mtsi10 / mtsi01;
+ if (r != T{0x10}) return false;
r = mtsi0F & mtsiF0;
if (r != T{0}) return false;
r = mtsi0F | mtsiF0;
@@ -60,6 +66,10 @@ tsi_test_operators()
if (r == T{0}) return false;
r = mtsi0F -= mtsiF0;
if (r == T{0}) return false;
+ r = mtsi0F *= mtsi01;
+ if (r == T{0}) return false;
+ r = mtsi10 /= mtsi01;
+ if (r != T{0x10}) return false;
r = mtsi0F &= mtsiF0;
if (r != T{0}) return false;
r = mtsi0F |= mtsiF0;
@@ -84,9 +94,13 @@ tsi_test_operators_constexpr()
constexpr T r02 = mtsi0F - T_T{static_cast<T_T>(mtsiF0)};
if constexpr (r02 == mtsi00) return false;
*/
- constexpr T r03 = mtsi0F + mtsiF0;
+ constexpr T r01 = mtsi0F + mtsiF0;
+ if constexpr (r01 == mtsi00) return false;
+ constexpr T r02 = mtsi0F - mtsiF0;
+ if constexpr (r02 == mtsi00) return false;
+ constexpr T r03 = mtsi0F * mtsiF0;
if constexpr (r03 == mtsi00) return false;
- constexpr T r04 = mtsi0F - mtsiF0;
+ constexpr T r04 = mtsiF0 / mtsi0F;
if constexpr (r04 == mtsi00) return false;
constexpr T r05 = mtsi0F & mtsiF0;
if constexpr (r05 != mtsi00) return false;