-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b28f36
commit 38b8cd2
Showing
8 changed files
with
171 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include "lib/globals.h" | ||
#include "lib/fluxmap.h" | ||
#include "lib/usb/applesauce.h" | ||
|
||
static void test_convert(const Bytes& asbytes, const Bytes& flbytes) | ||
{ | ||
Bytes astoflbytes = applesauceToFluxEngine(asbytes); | ||
Bytes fltoasbytes = fluxEngineToApplesauce(flbytes); | ||
|
||
if (astoflbytes != flbytes) | ||
{ | ||
std::cout << "Applesauce to FluxEngine conversion failed.\n"; | ||
std::cout << "Applesauce bytes:" << std::endl; | ||
hexdump(std::cout, asbytes); | ||
std::cout << std::endl << "Produced this:" << std::endl; | ||
hexdump(std::cout, astoflbytes); | ||
std::cout << std::endl << "Expected this:" << std::endl; | ||
hexdump(std::cout, flbytes); | ||
abort(); | ||
} | ||
|
||
if (fltoasbytes != asbytes) | ||
{ | ||
std::cout << "FluxEngine to Applesauce conversion failed.\n"; | ||
std::cout << "FluxEngine bytes:" << std::endl; | ||
hexdump(std::cout, flbytes); | ||
std::cout << std::endl << "Produced this:" << std::endl; | ||
hexdump(std::cout, fltoasbytes); | ||
std::cout << std::endl << "Expected this:" << std::endl; | ||
hexdump(std::cout, asbytes); | ||
abort(); | ||
} | ||
} | ||
|
||
static void test_conversions() | ||
{ | ||
/* Simple one-byte intervals. */ | ||
|
||
test_convert(Bytes{0x20, 0x20, 0x20, 0x20}, Bytes{0xb0, 0xb0, 0xb0, 0xb0}); | ||
|
||
/* Long, multibyte intervals. */ | ||
|
||
test_convert(Bytes{0xff, 0x1f, 0x20, 0xff, 0xff, 0x20}, | ||
Bytes{0x3f, | ||
0x3f, | ||
0x3f, | ||
0x3f, | ||
0x3f, | ||
0x3f, | ||
0xb3, | ||
0xb0, | ||
0x3f, | ||
0x3f, | ||
0x3f, | ||
0x3f, | ||
0x3f, | ||
0x3f, | ||
0x3f, | ||
0x3f, | ||
0x3f, | ||
0x3f, | ||
0x3f, | ||
0x3f, | ||
0xb9}); | ||
} | ||
|
||
int main(int argc, const char* argv[]) | ||
{ | ||
test_conversions(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
"agg", | ||
"amiga", | ||
"applesingle", | ||
"applesauce", | ||
"bitaccumulator", | ||
"bytes", | ||
"compression", | ||
|