mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
device; writes haven't been converted yet. Reduces the bandiwidth from about 800kB/s to about 500kB/s, which is about what I thought.
44 lines
1.0 KiB
C++
44 lines
1.0 KiB
C++
#include "globals.h"
|
|
#include "bytes.h"
|
|
#include "crunch.h"
|
|
|
|
static uint8_t outputbuffer[64];
|
|
|
|
static void test_crunch()
|
|
{
|
|
crunch_state_t cs = {};
|
|
Bytes inputdata = { 0x01, 0x7f, 0x80, 0x81, 0x01 };
|
|
cs.inputptr = inputdata.begin();
|
|
cs.inputlen = inputdata.size();
|
|
cs.outputptr = outputbuffer;
|
|
cs.outputlen = 64;
|
|
crunch(&cs);
|
|
donecrunch(&cs);
|
|
Bytes outputdata(outputbuffer, cs.outputptr - outputbuffer);
|
|
|
|
assert((outputdata == Bytes{ 0x01, 0x7f, 0xb0, 0x10 }));
|
|
}
|
|
|
|
static void test_uncrunch()
|
|
{
|
|
crunch_state_t cs = {};
|
|
Bytes inputdata = { 0x01, 0x7f, 0xb0, 0x10 };
|
|
cs.inputptr = inputdata.begin();
|
|
cs.inputlen = inputdata.size();
|
|
cs.outputptr = outputbuffer;
|
|
cs.outputlen = 64;
|
|
uncrunch(&cs);
|
|
doneuncrunch(&cs);
|
|
Bytes outputdata(outputbuffer, cs.outputptr - outputbuffer);
|
|
|
|
assert((outputdata == Bytes { 0x01, 0x7f, 0x80, 0x81, 0x01 }));
|
|
}
|
|
|
|
int main(int argc, const char* argv[])
|
|
{
|
|
test_crunch();
|
|
test_uncrunch();
|
|
return 0;
|
|
}
|
|
|