Skip to content

Commit 69e7065

Browse files
committed
more tests
1 parent c4c59f7 commit 69e7065

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

test/swar/BasicOperations.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "catch2/catch.hpp"
44

5+
#include <initializer_list>
56
#include <type_traits>
67

78

@@ -69,8 +70,19 @@ TEST_CASE("Jamie's totally working exponentiation :D") {
6970
CHECK(expected.value() == actual.value());
7071
}
7172

73+
TEST_CASE("Jamie's enhanced exponentiation test for different lane widths") {
74+
using S = SWAR<16, u64>; // Change to 16-bit lane width
75+
constexpr auto base = S::fromLaneLiterals({10, 2, 7, 3});
76+
constexpr auto exponent = S::fromLaneLiterals({3, 5, 1, 4});
77+
constexpr auto expected = S::fromLaneLiterals({1000, 32, 7, 81});
78+
constexpr auto actual = exponentiation_OverflowUnsafe(base, exponent);
79+
static_assert(expected.value() == actual.value());
80+
CHECK(expected.value() == actual.value());
7281
}
7382

83+
};
84+
85+
7486
#define HE(nbits, t, v0, v1) \
7587
static_assert(horizontalEquality<nbits, t>(\
7688
SWAR<nbits, t>(v0),\
@@ -358,7 +370,7 @@ TEST_CASE(
358370
"BooleanSWAR MSBtoLaneMask",
359371
"[swar]"
360372
) {
361-
// BooleanSWAR as a mask:
373+
// BooleanSWAR as a mask:
362374
auto bswar =BooleanSWAR<4, u32>(0x0808'0000);
363375
auto mask = S4_32(0x0F0F'0000);
364376
CHECK(bswar.MSBtoLaneMask().value() == mask.value());
@@ -385,6 +397,6 @@ TEST_CASE(
385397
CHECK(SWAR<4, u16>(0x0400).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0100), SWAR<4, u16>(0x0300)).value());
386398
CHECK(SWAR<4, u16>(0x0B00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0300)).value());
387399
CHECK(SWAR<4, u16>(0x0F00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0700)).value());
388-
CHECK(SWAR<4, u16>(0x0F00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0800)).value());
389-
CHECK(S4_32(0x0F0C'F000).value() == saturatingUnsignedAddition(S4_32(0x0804'F000), S4_32(0x0808'F000)).value());
400+
CHECK(SWAR<4, u16>(0x0F00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0800)).value());
401+
CHECK(S4_32(0x0F0C'F000).value() == saturatingUnsignedAddition(S4_32(0x0804'F000), S4_32(0x0808'F000)).value());
390402
}

0 commit comments

Comments
 (0)