Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
test_base64.cpp File Reference
#include <boost/test/included/unit_test.hpp>
#include <fc/crypto/base64.hpp>
#include <fc/exception/exception.hpp>
Include dependency graph for test_base64.cpp:

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   base64
 

Functions

 BOOST_AUTO_TEST_CASE (base64enc)
 
 FC_LOG_AND_RETHROW ()
 
 BOOST_AUTO_TEST_CASE (base64urlenc)
 
 BOOST_AUTO_TEST_CASE (base64dec)
 
 BOOST_AUTO_TEST_CASE (base64urldec)
 
 BOOST_AUTO_TEST_CASE (base64dec_extraequals)
 
 BOOST_AUTO_TEST_CASE (base64dec_bad_stuff)
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   base64

Definition at line 1 of file test_base64.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/6]

BOOST_AUTO_TEST_CASE ( base64dec )

Definition at line 26 of file test_base64.cpp.

26 {
27 auto input = "YWJjMTIzJCYoKSc/tPUB+n5h"s;
28 auto expected_output = "abc123$&()'?\xb4\xf5\x01\xfa~a"s;
29
30 BOOST_CHECK_EQUAL(expected_output, base64_decode(input));
std::string base64_decode(const std::string &encoded_string)
Definition base64.cpp:152
FC_LOG_AND_RETHROW()
char * s
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/6]

BOOST_AUTO_TEST_CASE ( base64dec_bad_stuff )

Definition at line 47 of file test_base64.cpp.

47 {
48 auto input = "YWJjMTIzJCYoKSc/tPU$B+n5h="s;
49
50 BOOST_CHECK_EXCEPTION(base64_decode(input), fc::exception, [](const fc::exception& e) {
51 return e.to_detail_string().find("encountered non-base64 character") != std::string::npos;
52 });
Used to generate a useful error report when an exception is thrown.
Definition exception.hpp:58
std::string to_detail_string(log_level ll=log_level::all) const
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/6]

BOOST_AUTO_TEST_CASE ( base64dec_extraequals )

Definition at line 40 of file test_base64.cpp.

40 {
41 auto input = "YWJjMTIzJCYoKSc/tPUB+n5h========="s;
42 auto expected_output = "abc123$&()'?\xb4\xf5\x01\xfa~a"s;
43
44 BOOST_CHECK_EQUAL(expected_output, base64_decode(input));
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/6]

BOOST_AUTO_TEST_CASE ( base64enc )

Definition at line 12 of file test_base64.cpp.

12 {
13 auto input = "abc123$&()'?\xb4\xf5\x01\xfa~a"s;
14 auto expected_output = "YWJjMTIzJCYoKSc/tPUB+n5h"s;
15
16 BOOST_CHECK_EQUAL(expected_output, base64_encode(input));
std::string base64_encode(unsigned char const *bytes_to_encode, unsigned int in_len)
Definition base64.cpp:92
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/6]

BOOST_AUTO_TEST_CASE ( base64urldec )

Definition at line 33 of file test_base64.cpp.

33 {
34 auto input = "YWJjMTIzJCYoKSc_tPUB-n5h"s;
35 auto expected_output = "abc123$&()'?\xb4\xf5\x01\xfa~a"s;
36
37 BOOST_CHECK_EQUAL(expected_output, base64url_decode(input));
std::string base64url_decode(const std::string &encoded_string)
Definition base64.cpp:156
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/6]

BOOST_AUTO_TEST_CASE ( base64urlenc )

Definition at line 19 of file test_base64.cpp.

19 {
20 auto input = "abc123$&()'?\xb4\xf5\x01\xfa~a"s;
21 auto expected_output = "YWJjMTIzJCYoKSc_tPUB-n5h"s;
22
23 BOOST_CHECK_EQUAL(expected_output, base64url_encode(input));
std::string base64url_encode(unsigned char const *bytes_to_encode, unsigned int in_len)
Definition base64.cpp:101
Here is the call graph for this function:

◆ FC_LOG_AND_RETHROW()

FC_LOG_AND_RETHROW ( )