MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / TEST

Function TEST

source/test/encode_test.cpp:8–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6using namespace Star;
7
8TEST(EncodeTest, Base64) {
9 char const* data =
10 "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust "
11 "of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, "
12 "exceeds the short vehemence of any carnal pleasure.";
13 ByteArray testSource = ByteArray(data, strlen(data));
14 String testEncoded =
15 "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhl"
16 "ciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29u"
17 "dGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55"
18 "IGNhcm5hbCBwbGVhc3VyZS4=";
19
20 String encoded = base64Encode(testSource);
21 ByteArray decoded = base64Decode(encoded);
22
23 EXPECT_EQ(encoded, testEncoded);
24 EXPECT_EQ(decoded, testSource);
25}
26
27TEST(EncodeTest, SHA256) {
28 char const* data =

Callers

nothing calls this directly

Calls 5

ByteArrayClass · 0.85
base64EncodeFunction · 0.85
base64DecodeFunction · 0.85
hexDecodeFunction · 0.85
sha256Function · 0.85

Tested by

no test coverage detected