forked from daminetreg/xxhr
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from nxxm/feature/fix-decoding-nullptr-ending-…
…buffer [base64] decoding input-buffers that have '\0'
- Loading branch information
Showing
3 changed files
with
50 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#define BOOST_TEST_MODULE base64 | ||
#include <boost/test/included/unit_test.hpp> | ||
#include "wasm_boost_test.hpp" | ||
|
||
#include <xxhr/util.hpp> | ||
|
||
std::map<std::string, std::string> test_data { | ||
{ "", "" }, | ||
{ "TQ==" , "M" }, | ||
{ "TWE=" , "Ma" }, | ||
{ "TWFu" , "Man" }, | ||
{ "cGxlYXN1cmUu" , "pleasure." }, | ||
{ "bGVhc3VyZS4=" , "leasure." }, | ||
{ "ZWFzdXJlLg==" , "easure." }, | ||
{ "YXN1cmUu" , "asure." }, | ||
{ "c3VyZS4=" , "sure." }, | ||
{ "c3VyZS4=" , "sure." }, | ||
{ "AQABAFEAAAD5AAAAAA==", { 0x01, 0x00, 0x01, 0x00, 0x51, 0x00, 0x00, 0x00, char(0xf9), 0x00, 0x00, 0x00, 0x00 } } | ||
}; | ||
|
||
|
||
BOOST_AUTO_TEST_CASE(decode) { | ||
BOOST_REQUIRE(test_data.size() > 0); | ||
for (const auto& data : test_data) { | ||
BOOST_TEST_MESSAGE( data.first << " check if equals " << data.second); | ||
BOOST_REQUIRE_EQUAL(xxhr::util::decode64(data.first), data.second); | ||
} | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(encode) { | ||
BOOST_REQUIRE(test_data.size() > 0); | ||
for (const auto& data : test_data) { | ||
BOOST_TEST_MESSAGE( data.first << " check if equals " << data.second); | ||
BOOST_REQUIRE_EQUAL(xxhr::util::encode64(data.second), data.first); | ||
} | ||
} |
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,9 @@ | ||
#pragma once | ||
|
||
|
||
#ifdef __EMSCRIPTEN__ | ||
#include <signal.h> | ||
extern "C" { | ||
int sigaltstack(const stack_t *__restrict, stack_t *__restrict) { return 0; } //XXX: Check in newer emcc version if we can remove this. | ||
} | ||
#endif |
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