aboutsummaryrefslogtreecommitdiffstats
path: root/libj2_j2u_has_ju.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2025-12-05 20:43:23 +0100
committerMattias Andrée <m@maandree.se>2025-12-05 20:48:59 +0100
commitf05fdeb727a2fc8052900a159c225d328d603acc (patch)
tree9c56ef8fea9964decd3c24f5b03f1341266f779b /libj2_j2u_has_ju.c
parentFirst commit (diff)
downloadlibj2-f05fdeb727a2fc8052900a159c225d328d603acc.tar.gz
libj2-f05fdeb727a2fc8052900a159c225d328d603acc.tar.bz2
libj2-f05fdeb727a2fc8052900a159c225d328d603acc.tar.xz
Second commit
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libj2_j2u_has_ju.c')
-rw-r--r--libj2_j2u_has_ju.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/libj2_j2u_has_ju.c b/libj2_j2u_has_ju.c
new file mode 100644
index 0000000..b531c50
--- /dev/null
+++ b/libj2_j2u_has_ju.c
@@ -0,0 +1,40 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifndef TEST
+
+extern inline int libj2_j2u_has_ju(const struct libj2_j2u *a, uintmax_t b);
+/* TODO Add man page */
+
+
+#else
+
+int
+main(void)
+{
+ struct libj2_j2u a;
+ uintmax_t h, i, j, b;
+ int expected;
+
+ for (h = 0; h < 10; h++) {
+ a.high = h;
+ for (i = 0; i < 128; i++) {
+ a.low = i;
+ for (b = 0; b < 128; b++) {
+ expected = 1;
+ for (j = 0; j < LIBJ2_JU_BIT; j++) {
+ if (((b & ~a.low) >> j) & 1U) {
+ expected = 0;
+ break;
+ }
+ }
+ EXPECT(libj2_j2u_has_ju(&a, b) == expected);
+ EXPECT(a.high == h);
+ EXPECT(a.low == i);
+ }
+ }
+ }
+
+ return 0;
+}
+
+#endif