From b3a275b2addf9b74c83d3d931ae07a9486d59098 Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 23 Aug 2024 17:19:16 +0000 Subject: [PATCH] Putting Xs into squares is all the rage with statisticians. We should test that they can use bitstring macros for that. with & OK deraadt OK bluhm --- regress/include/bitstring/bitstring_test.c | 12 +++- regress/include/bitstring/good/27 | 29 +++++++++ regress/include/bitstring/good/32 | 34 +++++++++++ regress/include/bitstring/good/49 | 51 ++++++++++++++++ regress/include/bitstring/good/64 | 66 +++++++++++++++++++++ regress/include/bitstring/good/67 | 69 ++++++++++++++++++++++ regress/include/bitstring/good/8 | 10 ++++ 7 files changed, 270 insertions(+), 1 deletion(-) diff --git a/regress/include/bitstring/bitstring_test.c b/regress/include/bitstring/bitstring_test.c index 545a3cb7969..836c021bfea 100644 --- a/regress/include/bitstring/bitstring_test.c +++ b/regress/include/bitstring/bitstring_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bitstring_test.c,v 1.5 2003/07/31 21:48:02 deraadt Exp $ */ +/* $OpenBSD: bitstring_test.c,v 1.6 2024/08/23 17:19:16 florian Exp $ */ /* $NetBSD: bitstring_test.c,v 1.4 1995/04/29 05:44:35 cgd Exp $ */ /* @@ -210,6 +210,16 @@ main(int argc, char *argv[]) printbits(bs, TEST_LENGTH); } + (void) printf("\n"); + (void) printf("CHI square test\n"); + for (i = 0; i < TEST_LENGTH; i++) { + bit_nclear(bs, 0, TEST_LENGTH - 1); + bit_nset(bs, i, i); + bit_nset(bs, TEST_LENGTH - 1 - i, TEST_LENGTH - 1 - i); + (void) printf("%3d ", i); + printbits(bs, TEST_LENGTH); + } + (void) free(bs); (void) exit(0); } diff --git a/regress/include/bitstring/good/27 b/regress/include/bitstring/good/27 index 55ba39e774d..f1479dde88e 100644 --- a/regress/include/bitstring/good/27 +++ b/regress/include/bitstring/good/27 @@ -261,3 +261,32 @@ first 1 bit should move left 1 position each line 24 0 24 000000000000000000000000100 25 0 25 000000000000000000000000010 26 0 26 000000000000000000000000001 + +CHI square test + 0 1 0 100000000000000000000000001 + 1 0 1 010000000000000000000000010 + 2 0 2 001000000000000000000000100 + 3 0 3 000100000000000000000001000 + 4 0 4 000010000000000000000010000 + 5 0 5 000001000000000000000100000 + 6 0 6 000000100000000000001000000 + 7 0 7 000000010000000000010000000 + 8 0 8 000000001000000000100000000 + 9 0 9 000000000100000001000000000 + 10 0 10 000000000010000010000000000 + 11 0 11 000000000001000100000000000 + 12 0 12 000000000000101000000000000 + 13 0 13 000000000000010000000000000 + 14 0 12 000000000000101000000000000 + 15 0 11 000000000001000100000000000 + 16 0 10 000000000010000010000000000 + 17 0 9 000000000100000001000000000 + 18 0 8 000000001000000000100000000 + 19 0 7 000000010000000000010000000 + 20 0 6 000000100000000000001000000 + 21 0 5 000001000000000000000100000 + 22 0 4 000010000000000000000010000 + 23 0 3 000100000000000000000001000 + 24 0 2 001000000000000000000000100 + 25 0 1 010000000000000000000000010 + 26 1 0 100000000000000000000000001 diff --git a/regress/include/bitstring/good/32 b/regress/include/bitstring/good/32 index 2e1ca55d6e3..7474b966283 100644 --- a/regress/include/bitstring/good/32 +++ b/regress/include/bitstring/good/32 @@ -301,3 +301,37 @@ first 1 bit should move left 1 position each line 29 0 29 00000000000000000000000000000100 30 0 30 00000000000000000000000000000010 31 0 31 00000000000000000000000000000001 + +CHI square test + 0 1 0 10000000000000000000000000000001 + 1 0 1 01000000000000000000000000000010 + 2 0 2 00100000000000000000000000000100 + 3 0 3 00010000000000000000000000001000 + 4 0 4 00001000000000000000000000010000 + 5 0 5 00000100000000000000000000100000 + 6 0 6 00000010000000000000000001000000 + 7 0 7 00000001000000000000000010000000 + 8 0 8 00000000100000000000000100000000 + 9 0 9 00000000010000000000001000000000 + 10 0 10 00000000001000000000010000000000 + 11 0 11 00000000000100000000100000000000 + 12 0 12 00000000000010000001000000000000 + 13 0 13 00000000000001000010000000000000 + 14 0 14 00000000000000100100000000000000 + 15 0 15 00000000000000011000000000000000 + 16 0 15 00000000000000011000000000000000 + 17 0 14 00000000000000100100000000000000 + 18 0 13 00000000000001000010000000000000 + 19 0 12 00000000000010000001000000000000 + 20 0 11 00000000000100000000100000000000 + 21 0 10 00000000001000000000010000000000 + 22 0 9 00000000010000000000001000000000 + 23 0 8 00000000100000000000000100000000 + 24 0 7 00000001000000000000000010000000 + 25 0 6 00000010000000000000000001000000 + 26 0 5 00000100000000000000000000100000 + 27 0 4 00001000000000000000000000010000 + 28 0 3 00010000000000000000000000001000 + 29 0 2 00100000000000000000000000000100 + 30 0 1 01000000000000000000000000000010 + 31 1 0 10000000000000000000000000000001 diff --git a/regress/include/bitstring/good/49 b/regress/include/bitstring/good/49 index d63c0692dee..42e55b33788 100644 --- a/regress/include/bitstring/good/49 +++ b/regress/include/bitstring/good/49 @@ -437,3 +437,54 @@ first 1 bit should move left 1 position each line 46 0 46 0000000000000000000000000000000000000000000000100 47 0 47 0000000000000000000000000000000000000000000000010 48 0 48 0000000000000000000000000000000000000000000000001 + +CHI square test + 0 1 0 1000000000000000000000000000000000000000000000001 + 1 0 1 0100000000000000000000000000000000000000000000010 + 2 0 2 0010000000000000000000000000000000000000000000100 + 3 0 3 0001000000000000000000000000000000000000000001000 + 4 0 4 0000100000000000000000000000000000000000000010000 + 5 0 5 0000010000000000000000000000000000000000000100000 + 6 0 6 0000001000000000000000000000000000000000001000000 + 7 0 7 0000000100000000000000000000000000000000010000000 + 8 0 8 0000000010000000000000000000000000000000100000000 + 9 0 9 0000000001000000000000000000000000000001000000000 + 10 0 10 0000000000100000000000000000000000000010000000000 + 11 0 11 0000000000010000000000000000000000000100000000000 + 12 0 12 0000000000001000000000000000000000001000000000000 + 13 0 13 0000000000000100000000000000000000010000000000000 + 14 0 14 0000000000000010000000000000000000100000000000000 + 15 0 15 0000000000000001000000000000000001000000000000000 + 16 0 16 0000000000000000100000000000000010000000000000000 + 17 0 17 0000000000000000010000000000000100000000000000000 + 18 0 18 0000000000000000001000000000001000000000000000000 + 19 0 19 0000000000000000000100000000010000000000000000000 + 20 0 20 0000000000000000000010000000100000000000000000000 + 21 0 21 0000000000000000000001000001000000000000000000000 + 22 0 22 0000000000000000000000100010000000000000000000000 + 23 0 23 0000000000000000000000010100000000000000000000000 + 24 0 24 0000000000000000000000001000000000000000000000000 + 25 0 23 0000000000000000000000010100000000000000000000000 + 26 0 22 0000000000000000000000100010000000000000000000000 + 27 0 21 0000000000000000000001000001000000000000000000000 + 28 0 20 0000000000000000000010000000100000000000000000000 + 29 0 19 0000000000000000000100000000010000000000000000000 + 30 0 18 0000000000000000001000000000001000000000000000000 + 31 0 17 0000000000000000010000000000000100000000000000000 + 32 0 16 0000000000000000100000000000000010000000000000000 + 33 0 15 0000000000000001000000000000000001000000000000000 + 34 0 14 0000000000000010000000000000000000100000000000000 + 35 0 13 0000000000000100000000000000000000010000000000000 + 36 0 12 0000000000001000000000000000000000001000000000000 + 37 0 11 0000000000010000000000000000000000000100000000000 + 38 0 10 0000000000100000000000000000000000000010000000000 + 39 0 9 0000000001000000000000000000000000000001000000000 + 40 0 8 0000000010000000000000000000000000000000100000000 + 41 0 7 0000000100000000000000000000000000000000010000000 + 42 0 6 0000001000000000000000000000000000000000001000000 + 43 0 5 0000010000000000000000000000000000000000000100000 + 44 0 4 0000100000000000000000000000000000000000000010000 + 45 0 3 0001000000000000000000000000000000000000000001000 + 46 0 2 0010000000000000000000000000000000000000000000100 + 47 0 1 0100000000000000000000000000000000000000000000010 + 48 1 0 1000000000000000000000000000000000000000000000001 diff --git a/regress/include/bitstring/good/64 b/regress/include/bitstring/good/64 index 7e9308eabc7..deb94b6c7da 100644 --- a/regress/include/bitstring/good/64 +++ b/regress/include/bitstring/good/64 @@ -557,3 +557,69 @@ first 1 bit should move left 1 position each line 61 0 61 0000000000000000000000000000000000000000000000000000000000000100 62 0 62 0000000000000000000000000000000000000000000000000000000000000010 63 0 63 0000000000000000000000000000000000000000000000000000000000000001 + +CHI square test + 0 1 0 1000000000000000000000000000000000000000000000000000000000000001 + 1 0 1 0100000000000000000000000000000000000000000000000000000000000010 + 2 0 2 0010000000000000000000000000000000000000000000000000000000000100 + 3 0 3 0001000000000000000000000000000000000000000000000000000000001000 + 4 0 4 0000100000000000000000000000000000000000000000000000000000010000 + 5 0 5 0000010000000000000000000000000000000000000000000000000000100000 + 6 0 6 0000001000000000000000000000000000000000000000000000000001000000 + 7 0 7 0000000100000000000000000000000000000000000000000000000010000000 + 8 0 8 0000000010000000000000000000000000000000000000000000000100000000 + 9 0 9 0000000001000000000000000000000000000000000000000000001000000000 + 10 0 10 0000000000100000000000000000000000000000000000000000010000000000 + 11 0 11 0000000000010000000000000000000000000000000000000000100000000000 + 12 0 12 0000000000001000000000000000000000000000000000000001000000000000 + 13 0 13 0000000000000100000000000000000000000000000000000010000000000000 + 14 0 14 0000000000000010000000000000000000000000000000000100000000000000 + 15 0 15 0000000000000001000000000000000000000000000000001000000000000000 + 16 0 16 0000000000000000100000000000000000000000000000010000000000000000 + 17 0 17 0000000000000000010000000000000000000000000000100000000000000000 + 18 0 18 0000000000000000001000000000000000000000000001000000000000000000 + 19 0 19 0000000000000000000100000000000000000000000010000000000000000000 + 20 0 20 0000000000000000000010000000000000000000000100000000000000000000 + 21 0 21 0000000000000000000001000000000000000000001000000000000000000000 + 22 0 22 0000000000000000000000100000000000000000010000000000000000000000 + 23 0 23 0000000000000000000000010000000000000000100000000000000000000000 + 24 0 24 0000000000000000000000001000000000000001000000000000000000000000 + 25 0 25 0000000000000000000000000100000000000010000000000000000000000000 + 26 0 26 0000000000000000000000000010000000000100000000000000000000000000 + 27 0 27 0000000000000000000000000001000000001000000000000000000000000000 + 28 0 28 0000000000000000000000000000100000010000000000000000000000000000 + 29 0 29 0000000000000000000000000000010000100000000000000000000000000000 + 30 0 30 0000000000000000000000000000001001000000000000000000000000000000 + 31 0 31 0000000000000000000000000000000110000000000000000000000000000000 + 32 0 31 0000000000000000000000000000000110000000000000000000000000000000 + 33 0 30 0000000000000000000000000000001001000000000000000000000000000000 + 34 0 29 0000000000000000000000000000010000100000000000000000000000000000 + 35 0 28 0000000000000000000000000000100000010000000000000000000000000000 + 36 0 27 0000000000000000000000000001000000001000000000000000000000000000 + 37 0 26 0000000000000000000000000010000000000100000000000000000000000000 + 38 0 25 0000000000000000000000000100000000000010000000000000000000000000 + 39 0 24 0000000000000000000000001000000000000001000000000000000000000000 + 40 0 23 0000000000000000000000010000000000000000100000000000000000000000 + 41 0 22 0000000000000000000000100000000000000000010000000000000000000000 + 42 0 21 0000000000000000000001000000000000000000001000000000000000000000 + 43 0 20 0000000000000000000010000000000000000000000100000000000000000000 + 44 0 19 0000000000000000000100000000000000000000000010000000000000000000 + 45 0 18 0000000000000000001000000000000000000000000001000000000000000000 + 46 0 17 0000000000000000010000000000000000000000000000100000000000000000 + 47 0 16 0000000000000000100000000000000000000000000000010000000000000000 + 48 0 15 0000000000000001000000000000000000000000000000001000000000000000 + 49 0 14 0000000000000010000000000000000000000000000000000100000000000000 + 50 0 13 0000000000000100000000000000000000000000000000000010000000000000 + 51 0 12 0000000000001000000000000000000000000000000000000001000000000000 + 52 0 11 0000000000010000000000000000000000000000000000000000100000000000 + 53 0 10 0000000000100000000000000000000000000000000000000000010000000000 + 54 0 9 0000000001000000000000000000000000000000000000000000001000000000 + 55 0 8 0000000010000000000000000000000000000000000000000000000100000000 + 56 0 7 0000000100000000000000000000000000000000000000000000000010000000 + 57 0 6 0000001000000000000000000000000000000000000000000000000001000000 + 58 0 5 0000010000000000000000000000000000000000000000000000000000100000 + 59 0 4 0000100000000000000000000000000000000000000000000000000000010000 + 60 0 3 0001000000000000000000000000000000000000000000000000000000001000 + 61 0 2 0010000000000000000000000000000000000000000000000000000000000100 + 62 0 1 0100000000000000000000000000000000000000000000000000000000000010 + 63 1 0 1000000000000000000000000000000000000000000000000000000000000001 diff --git a/regress/include/bitstring/good/67 b/regress/include/bitstring/good/67 index e5decc3b4bd..83cd3fdf0d2 100644 --- a/regress/include/bitstring/good/67 +++ b/regress/include/bitstring/good/67 @@ -581,3 +581,72 @@ first 1 bit should move left 1 position each line 64 0 64 0000000000000000000000000000000000000000000000000000000000000000100 65 0 65 0000000000000000000000000000000000000000000000000000000000000000010 66 0 66 0000000000000000000000000000000000000000000000000000000000000000001 + +CHI square test + 0 1 0 1000000000000000000000000000000000000000000000000000000000000000001 + 1 0 1 0100000000000000000000000000000000000000000000000000000000000000010 + 2 0 2 0010000000000000000000000000000000000000000000000000000000000000100 + 3 0 3 0001000000000000000000000000000000000000000000000000000000000001000 + 4 0 4 0000100000000000000000000000000000000000000000000000000000000010000 + 5 0 5 0000010000000000000000000000000000000000000000000000000000000100000 + 6 0 6 0000001000000000000000000000000000000000000000000000000000001000000 + 7 0 7 0000000100000000000000000000000000000000000000000000000000010000000 + 8 0 8 0000000010000000000000000000000000000000000000000000000000100000000 + 9 0 9 0000000001000000000000000000000000000000000000000000000001000000000 + 10 0 10 0000000000100000000000000000000000000000000000000000000010000000000 + 11 0 11 0000000000010000000000000000000000000000000000000000000100000000000 + 12 0 12 0000000000001000000000000000000000000000000000000000001000000000000 + 13 0 13 0000000000000100000000000000000000000000000000000000010000000000000 + 14 0 14 0000000000000010000000000000000000000000000000000000100000000000000 + 15 0 15 0000000000000001000000000000000000000000000000000001000000000000000 + 16 0 16 0000000000000000100000000000000000000000000000000010000000000000000 + 17 0 17 0000000000000000010000000000000000000000000000000100000000000000000 + 18 0 18 0000000000000000001000000000000000000000000000001000000000000000000 + 19 0 19 0000000000000000000100000000000000000000000000010000000000000000000 + 20 0 20 0000000000000000000010000000000000000000000000100000000000000000000 + 21 0 21 0000000000000000000001000000000000000000000001000000000000000000000 + 22 0 22 0000000000000000000000100000000000000000000010000000000000000000000 + 23 0 23 0000000000000000000000010000000000000000000100000000000000000000000 + 24 0 24 0000000000000000000000001000000000000000001000000000000000000000000 + 25 0 25 0000000000000000000000000100000000000000010000000000000000000000000 + 26 0 26 0000000000000000000000000010000000000000100000000000000000000000000 + 27 0 27 0000000000000000000000000001000000000001000000000000000000000000000 + 28 0 28 0000000000000000000000000000100000000010000000000000000000000000000 + 29 0 29 0000000000000000000000000000010000000100000000000000000000000000000 + 30 0 30 0000000000000000000000000000001000001000000000000000000000000000000 + 31 0 31 0000000000000000000000000000000100010000000000000000000000000000000 + 32 0 32 0000000000000000000000000000000010100000000000000000000000000000000 + 33 0 33 0000000000000000000000000000000001000000000000000000000000000000000 + 34 0 32 0000000000000000000000000000000010100000000000000000000000000000000 + 35 0 31 0000000000000000000000000000000100010000000000000000000000000000000 + 36 0 30 0000000000000000000000000000001000001000000000000000000000000000000 + 37 0 29 0000000000000000000000000000010000000100000000000000000000000000000 + 38 0 28 0000000000000000000000000000100000000010000000000000000000000000000 + 39 0 27 0000000000000000000000000001000000000001000000000000000000000000000 + 40 0 26 0000000000000000000000000010000000000000100000000000000000000000000 + 41 0 25 0000000000000000000000000100000000000000010000000000000000000000000 + 42 0 24 0000000000000000000000001000000000000000001000000000000000000000000 + 43 0 23 0000000000000000000000010000000000000000000100000000000000000000000 + 44 0 22 0000000000000000000000100000000000000000000010000000000000000000000 + 45 0 21 0000000000000000000001000000000000000000000001000000000000000000000 + 46 0 20 0000000000000000000010000000000000000000000000100000000000000000000 + 47 0 19 0000000000000000000100000000000000000000000000010000000000000000000 + 48 0 18 0000000000000000001000000000000000000000000000001000000000000000000 + 49 0 17 0000000000000000010000000000000000000000000000000100000000000000000 + 50 0 16 0000000000000000100000000000000000000000000000000010000000000000000 + 51 0 15 0000000000000001000000000000000000000000000000000001000000000000000 + 52 0 14 0000000000000010000000000000000000000000000000000000100000000000000 + 53 0 13 0000000000000100000000000000000000000000000000000000010000000000000 + 54 0 12 0000000000001000000000000000000000000000000000000000001000000000000 + 55 0 11 0000000000010000000000000000000000000000000000000000000100000000000 + 56 0 10 0000000000100000000000000000000000000000000000000000000010000000000 + 57 0 9 0000000001000000000000000000000000000000000000000000000001000000000 + 58 0 8 0000000010000000000000000000000000000000000000000000000000100000000 + 59 0 7 0000000100000000000000000000000000000000000000000000000000010000000 + 60 0 6 0000001000000000000000000000000000000000000000000000000000001000000 + 61 0 5 0000010000000000000000000000000000000000000000000000000000000100000 + 62 0 4 0000100000000000000000000000000000000000000000000000000000000010000 + 63 0 3 0001000000000000000000000000000000000000000000000000000000000001000 + 64 0 2 0010000000000000000000000000000000000000000000000000000000000000100 + 65 0 1 0100000000000000000000000000000000000000000000000000000000000000010 + 66 1 0 1000000000000000000000000000000000000000000000000000000000000000001 diff --git a/regress/include/bitstring/good/8 b/regress/include/bitstring/good/8 index aba64404b45..1def322532d 100644 --- a/regress/include/bitstring/good/8 +++ b/regress/include/bitstring/good/8 @@ -109,3 +109,13 @@ first 1 bit should move left 1 position each line 5 0 5 00000100 6 0 6 00000010 7 0 7 00000001 + +CHI square test + 0 1 0 10000001 + 1 0 1 01000010 + 2 0 2 00100100 + 3 0 3 00011000 + 4 0 3 00011000 + 5 0 2 00100100 + 6 0 1 01000010 + 7 1 0 10000001 -- 2.20.1