summaryrefslogtreecommitdiff
path: root/src/test/ao_int64_test.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-05-22 17:08:55 -0700
committerKeith Packard <keithp@keithp.com>2013-08-25 22:24:01 -0700
commit5ccd902d0fd2adc40c72982babb60fac4da6a087 (patch)
tree1316443d33623b6cf7c82c3688bd3cfcdb0412c8 /src/test/ao_int64_test.c
parentf7602ae566a5cbf2d2cbb1d68bad7e2d1177a33a (diff)
altos: Add 64x64 multiply. Test 64 ops for dest same as either source
The test change is to ensure that the destination may be one of the 64 bit sources. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/test/ao_int64_test.c')
-rw-r--r--src/test/ao_int64_test.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/test/ao_int64_test.c b/src/test/ao_int64_test.c
index 67ba6ec5..4c88b1a1 100644
--- a/src/test/ao_int64_test.c
+++ b/src/test/ao_int64_test.c
@@ -22,17 +22,35 @@
int errors;
-#define test(op,func,a,b,ao_a,ao_b) do { \
+#define test_o(op,func,mod,a,b,ao_a,ao_b) do { \
r = (a) op (b); \
func(&ao_r, ao_a, ao_b); \
c = ao_cast64(&ao_r); \
if (c != r) { \
- printf ("trial %4d: %lld " #func " %lld = %lld (should be %lld)\n", \
+ printf ("trial %4d: %lld " #func mod " %lld = %lld (should be %lld)\n", \
trial, (int64_t) (a), (int64_t) b, c, r); \
++errors; \
} \
} while (0)
+#define test(op,func,a,b,ao_a,ao_b) test_o(op,func,"",a,b,ao_a,ao_b)
+
+#define test_a(op,func,a,b,ao_a,ao_b) do { \
+ ao_r = *ao_a; \
+ test_o(op,func,"_a",a,b,&ao_r,ao_b); \
+ } while (0)
+
+#define test_b(op,func,a,b,ao_a,ao_b) do { \
+ ao_r = *ao_b; \
+ test_o(op,func,"_b",a,b,ao_a,&ao_r); \
+ } while (0)
+
+#define test_x(op,func,a,b,ao_a,ao_b) do { \
+ ao_r = *ao_a; \
+ test_o(op,func,"_xa",a,a,&ao_r,&ao_r); \
+ ao_r = *ao_b; \
+ test_o(op,func,"_xb",b,b,&ao_r,&ao_r); \
+ } while (0)
void
do_test(int trial, int64_t a, int64_t b)
@@ -44,10 +62,20 @@ do_test(int trial, int64_t a, int64_t b)
ao_int64_init64(&ao_b, b >> 32, b);
test(+, ao_plus64, a, b, &ao_a, &ao_b);
- test(*, ao_mul64,(int64_t) (int32_t) a, (int32_t) b, (int32_t) a, (int32_t) b);
+ test_a(+, ao_plus64, a, b, &ao_a, &ao_b);
+ test_b(+, ao_plus64, a, b, &ao_a, &ao_b);
+ test_x(+, ao_plus64, a, b, &ao_a, &ao_b);
+ test(*, ao_mul64_32_32,(int64_t) (int32_t) a, (int32_t) b, (int32_t) a, (int32_t) b);
+ test(*, ao_mul64, a, b, &ao_a, &ao_b);
+ test_a(*, ao_mul64, a, b, &ao_a, &ao_b);
+ test_b(*, ao_mul64, a, b, &ao_a, &ao_b);
+ test_x(*, ao_mul64, a, b, &ao_a, &ao_b);
+ test(*, ao_mul64_64_16, a, (uint16_t) b, &ao_a, (uint16_t) b);
+ test_a(*, ao_mul64_64_16, a, (uint16_t) b, &ao_a, (uint16_t) b);
test(>>, ao_rshift64, a, (uint8_t) b & 0x3f, &ao_a, (uint8_t) b & 0x3f);
+ test_a(>>, ao_rshift64, a, (uint8_t) b & 0x3f, &ao_a, (uint8_t) b & 0x3f);
test(<<, ao_lshift64, a, (uint8_t) b & 0x3f, &ao_a, (uint8_t) b & 0x3f);
- test(*, ao_mul64_16, a, (uint16_t) b, &ao_a, (uint16_t) b);
+ test_a(<<, ao_lshift64, a, (uint8_t) b & 0x3f, &ao_a, (uint8_t) b & 0x3f);
}
#define TESTS 10000000