aboutsummaryrefslogtreecommitdiffstats
path: root/c_test
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2023-02-25 21:01:03 +0000
committerGravatar Peter McGoron 2023-02-25 21:01:03 +0000
commit09d636c02cdbb13d10f1435d918cc36116715fc4 (patch)
treec7099a6c49ffa4521e144c5ed5a19186d08ec1ec /c_test
parentget rid of unused lablen (diff)
export creole_decode; add db test
Diffstat (limited to '')
-rw-r--r--c_test/encode_decode.c179
1 files changed, 4 insertions, 175 deletions
diff --git a/c_test/encode_decode.c b/c_test/encode_decode.c
index 835305c..2366049 100644
--- a/c_test/encode_decode.c
+++ b/c_test/encode_decode.c
@@ -11,188 +11,17 @@ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
+
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
-#include "../creole.c"
-
-#if 0
-struct seq {
- creole_word max;
- unsigned encode_to;
- unsigned high_bits;
-
- unsigned char minbuf[7];
- unsigned char maxbuf[7];
-};
-
-void bprint(unsigned char c) {
- int i;
-
- for (i = 0; i < 8; i++) {
- printf("%u", (c >> (7 - i)) & 1);
- }
-}
-
-void bprintb(unsigned char *b, int len) {
- while (len-- > 0) {
- bprint(*b++);
- printf(" ");
- }
-}
-
-static void encode_byte_seq(struct seq *s) {
- creole_word i = 0;
- int j;
- unsigned char buf[7];
-
- for (;;) {
-
- assert(creole_encode(i, s->encode_to, s->high_bits,
- buf) == 1);
- if (memcmp(s->minbuf, buf, s->encode_to) != 0) {
- printf("0x%X ", i);
- bprintb(s->minbuf, s->encode_to);
- printf("|");
- bprintb(buf, s->encode_to);
- printf("\n");
- abort();
- }
-
- if (i == s->max)
- break;
- i++;
-
- for (j = s->encode_to - 1; j > 0; j--) {
- if (s->minbuf[j] == 0xBF) {
- s->minbuf[j] = 0x80;
- } else {
- s->minbuf[j]++;
- break;
- }
- }
-
- if (j == 0)
- s->minbuf[0]++;
- }
- assert(memcmp(s->maxbuf, s->minbuf, s->encode_to) == 0);
-}
-
-static void encode_1(void) {
- struct seq s;
-
- s.max = 0x7F;
- s.encode_to = 1;
- s.high_bits = 0;
- s.minbuf[0] = 0x00;
- s.maxbuf[0] = 0x7F;
-
- encode_byte_seq(&s);
-}
-
-static void encode_2(unsigned high_bits) {
- struct seq s;
- s.high_bits = high_bits;
-
- memset(s.maxbuf, 0xBF, sizeof(s.maxbuf));
- memset(s.minbuf, 0x80, sizeof(s.minbuf));
- s.max = 0x7F;
- s.encode_to = 2;
- s.maxbuf[0] = s.minbuf[0] = 0xC0 | (high_bits << 1);
- s.maxbuf[0] = 0xC1 | (high_bits << 1);
- s.minbuf[1] = 0x80;
- encode_byte_seq(&s);
-}
-
-static void encode_3(unsigned high_bits) {
- struct seq s;
- s.high_bits = high_bits;
-
- memset(s.maxbuf, 0xBF, sizeof(s.maxbuf));
- memset(s.minbuf, 0x80, sizeof(s.minbuf));
- s.max = 0xFFF;
- s.encode_to = 3;
- s.minbuf[0] = 0xE0 | high_bits;
- s.maxbuf[0] = 0xE0 | high_bits;
- s.minbuf[1] = 0x80;
- encode_byte_seq(&s);
-}
-
-static void encode_4(unsigned high_bits) {
- struct seq s;
- s.high_bits = high_bits;
-
- memset(s.maxbuf, 0xBF, sizeof(s.maxbuf));
- memset(s.minbuf, 0x80, sizeof(s.minbuf));
- s.max = 0x1FFFF;
- s.encode_to = 4;
- s.maxbuf[0] = s.minbuf[0] = 0xF0 | (high_bits >> 1);
- s.minbuf[1] = 0x80 | ((high_bits & 0x1) << 5);
- s.maxbuf[1] = 0x9F | ((high_bits & 0x1) << 5);
- encode_byte_seq(&s);
-}
-
-static void encode_5(unsigned high_bits) {
- struct seq s;
- s.high_bits = high_bits;
-
- memset(s.maxbuf, 0xBF, sizeof(s.maxbuf));
- memset(s.minbuf, 0x80, sizeof(s.minbuf));
- s.max = 0x3FFFFF;
- s.encode_to = 5;
- s.maxbuf[0] = s.minbuf[0] = 0xF8 | (high_bits >> 2);
- s.minbuf[1] = 0x80 | ((high_bits & 0x3) << 4);
- s.maxbuf[1] = 0x8F | ((high_bits & 0x3) << 4);
- encode_byte_seq(&s);
-}
-
-static void encode_6(unsigned high_bits) {
- struct seq s;
- s.high_bits = high_bits;
-
- memset(s.maxbuf, 0xBF, sizeof(s.maxbuf));
- memset(s.minbuf, 0x80, sizeof(s.minbuf));
- s.max = 0x7FFFFFF;
- s.encode_to = 6;
- s.maxbuf[0] = s.minbuf[0] = 0xFC | (high_bits >> 3);
- s.minbuf[1] = 0x80 | ((high_bits & 0x7) << 3);
- s.maxbuf[1] = 0x87 | ((high_bits & 0x7) << 3);
- encode_byte_seq(&s);
-}
-
-static void encode_7(unsigned high_bits) {
- struct seq s;
- s.high_bits = high_bits;
-
- memset(s.maxbuf, 0xBF, sizeof(s.maxbuf));
- memset(s.minbuf, 0x80, sizeof(s.minbuf));
- s.max = 0xFFFFFFFF;
- s.encode_to = 7;
- s.maxbuf[0] = s.minbuf[0] = 0xFE;
- s.minbuf[1] = 0x80 | (high_bits << 2);
- s.maxbuf[1] = 0x83 | (high_bits << 2);
- encode_byte_seq(&s);
-}
-
-static void test_encode(void) {
- void (*tests[6])(unsigned) = {encode_2, encode_3, encode_4, encode_5, encode_6, encode_7};
- unsigned high_bits;
- unsigned test;
- encode_1();
-
-# pragma omp parallel for collapse(2) num_threads(8)
- for (high_bits = 0; high_bits < 16; high_bits++) {
- for (test = 0; test < 6; test++)
- tests[test](high_bits);
- }
-}
-#endif
+#include "../creole.h"
void encode_decode_byte_seq(creole_word max, unsigned encode_to, unsigned high_bits) {
unsigned char buf[7];
struct creole_reader r = {0};
- struct word w;
+ struct creole_word w;
creole_word i = 0;
for (;;) {
@@ -201,7 +30,7 @@ void encode_decode_byte_seq(creole_word max, unsigned encode_to, unsigned high_b
assert(creole_encode(i, encode_to, high_bits,
buf) == 1);
- assert(decode_seq(&r, &w) == 1);
+ assert(creole_decode(&r, &w) == 1);
assert(w.len == encode_to);
if (w.high_bits != high_bits) {
printf("high bits %u != %u\n", w.high_bits, high_bits);
ian scripts use makedev (>=2.3.1-49) in postinst by default now.Gravatar aeb 7-30/+104 Postinst script using mknod added as alternative. Revision bumped up to 0.8.1. git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@47 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-11-25Fix postinst ldconfig.Gravatar aeb 2-11/+11 Fix device file creation. Install NEWS and README as documentation in the dev package. git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@46 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-11-25Add some information about return values.Gravatar aeb 1-3/+29 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@45 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-11-24Bump up version numbers for release.Gravatar aeb 2-3/+11 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@44 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-11-24Added libraw1394.postinst.in to list of distributed files.Gravatar aeb 3-3/+35 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@43 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-11-23Add ldconfig in deb postinst for Debian policy conformance.Gravatar aeb 2-2/+17 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@42 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-11-23Removed acconfig.h, which wasn't needed for some time.Gravatar aeb 1-13/+0 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@41 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-11-22Added ieee1394.h header.Gravatar aeb 3-1/+38 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@40 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-09-13Fix raw1394_start_iso_write() which uses wrong variable.Gravatar aeb 1-1/+1 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@39 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-09-10Work around compiler warnings for int/ptr casts.Gravatar aeb 6-10/+20 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@38 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-09-10Added control files for Debian packages.Gravatar aeb 6-8/+106 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@37 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-09-01Added missing prototypes for iso send functions.Gravatar aeb 1-0/+7 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@36 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-08-08Added raw1394_get_irm_id().Gravatar aeb 7-7/+39 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@35 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-08-06Added support for isochronous sending.Gravatar aeb 3-0/+35 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@34 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-07-05Added raw1394_reset_bus() call.Gravatar aeb 4-0/+23 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@33 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-22- Set library version info in configure.in, use in src/Makefile.am.Gravatar aeb 4-2/+16 - Enable compiler warnings. git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@32 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-15Update libtool version number.Gravatar aeb 2-2/+2 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@31 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-14Added copyright headers.Gravatar aeb 6-0/+54 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@30 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-11Added explicit AC_PROG_INSTALL call.Gravatar aeb 1-0/+1 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@29 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-09Fix size of error field.Gravatar aeb 1-2/+2 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@28 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-06-02Modified support for 32/64 bit environments, control struct fields have ↵Gravatar aeb 7-43/+28 fixed size now. git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@27 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-05-28Added support for environments with 64 bit kernel and 32 bit userland.Gravatar aeb 8-7/+45 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@26 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-04-27Fixed missing setting of ext code in raw1394_start_lock()Gravatar aeb 1-0/+1 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@25 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-04-15Fixed lock transaction to actually return response value.Gravatar aeb 3-5/+11 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@24 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-04-12Add userdata functions as news.Gravatar aeb 1-0/+4 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@23 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-04-05Add userdata functions.Gravatar aeb 3-0/+18 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@22 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-03-18Bump version number to 0.6.Gravatar aeb 3-5/+6 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@21 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-03-18Mention byte order change.Gravatar aeb 1-0/+2 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@20 53a565d1-3bb7-0310-b661-cf11e63c67ab 2000-03-18Mention SourceForge home.Gravatar aeb 1-1/+5 git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@19 53a565d1-3bb7-0310-b661-cf11e63c67ab