2 #include <winpr/print.h>
6 static const BYTE TEST_BELLS_DATA[] =
"for.whom.the.bell.tolls,.the.bell.tolls.for.thee!";
8 static const BYTE TEST_BELLS_NCRUSH[] =
9 "\xfb\x1d\x7e\xe4\xda\xc7\x1d\x70\xf8\xa1\x6b\x1f\x7d\xc0\xbe\x6b"
10 "\xef\xb5\xef\x21\x87\xd0\xc5\xe1\x85\x71\xd4\x10\x16\xe7\xda\xfb"
11 "\x1d\x7e\xe4\xda\x47\x1f\xb0\xef\xbe\xbd\xff\x2f";
13 static BOOL test_NCrushCompressBells(
void)
18 const BYTE* pDstData = NULL;
19 BYTE OutputBuffer[65536] = { 0 };
20 const UINT32 SrcSize =
sizeof(TEST_BELLS_DATA) - 1;
21 const BYTE* pSrcData = TEST_BELLS_DATA;
22 const UINT32 expectedSize =
sizeof(TEST_BELLS_NCRUSH) - 1;
23 UINT32 DstSize =
sizeof(OutputBuffer);
24 NCRUSH_CONTEXT* ncrush = ncrush_context_new(TRUE);
29 status = ncrush_compress(ncrush, pSrcData, SrcSize, OutputBuffer, &pDstData, &DstSize, &Flags);
34 printf(
"status: %d Flags: 0x%08" PRIX32
" DstSize: %" PRIu32
"\n", status, Flags, DstSize);
36 if (DstSize != expectedSize)
38 printf(
"NCrushCompressBells: output size mismatch: Actual: %" PRIu32
", Expected: %" PRIu32
40 DstSize, expectedSize);
42 BitDump(__func__, WLOG_INFO, pDstData, DstSize * 8, 0);
44 BitDump(__func__, WLOG_INFO, TEST_BELLS_NCRUSH, expectedSize * 8, 0);
48 if (memcmp(pDstData, TEST_BELLS_NCRUSH, DstSize) != 0)
50 printf(
"NCrushCompressBells: output mismatch\n");
52 BitDump(__func__, WLOG_INFO, pDstData, DstSize * 8, 0);
54 BitDump(__func__, WLOG_INFO, TEST_BELLS_NCRUSH, expectedSize * 8, 0);
60 ncrush_context_free(ncrush);
64 static BOOL test_NCrushDecompressBells(
void)
69 const BYTE* pSrcData = NULL;
72 UINT32 expectedSize = 0;
73 const BYTE* pDstData = NULL;
74 NCRUSH_CONTEXT* ncrush = ncrush_context_new(FALSE);
79 SrcSize =
sizeof(TEST_BELLS_NCRUSH) - 1;
80 pSrcData = (
const BYTE*)TEST_BELLS_NCRUSH;
81 Flags = PACKET_COMPRESSED | 2;
82 expectedSize =
sizeof(TEST_BELLS_DATA) - 1;
83 status = ncrush_decompress(ncrush, pSrcData, SrcSize, &pDstData, &DstSize, Flags);
88 printf(
"Flags: 0x%08" PRIX32
" DstSize: %" PRIu32
"\n", Flags, DstSize);
90 if (DstSize != expectedSize)
92 printf(
"NCrushDecompressBells: output size mismatch: Actual: %" PRIu32
93 ", Expected: %" PRIu32
"\n",
94 DstSize, expectedSize);
98 if (memcmp(pDstData, TEST_BELLS_DATA, DstSize) != 0)
100 printf(
"NCrushDecompressBells: output mismatch\n");
106 ncrush_context_free(ncrush);
110 int TestFreeRDPCodecNCrush(
int argc,
char* argv[])
115 if (!test_NCrushCompressBells())
118 if (!test_NCrushDecompressBells())