foxglove_bridge_base
tests
base64_test.cpp
Go to the documentation of this file.
1
#include <gtest/gtest.h>
2
3
#include <
foxglove_bridge/base64.hpp
>
4
5
TEST
(
Base64Test
, EncodingTest) {
6
constexpr
char
arr[] = {
'A'
,
'B'
,
'C'
,
'D'
};
7
const
std::string_view sv(arr,
sizeof
(arr));
8
const
std::string b64encoded =
foxglove::base64Encode
(sv);
9
EXPECT_EQ(b64encoded,
"QUJDRA=="
);
10
}
11
12
TEST
(
Base64Test
, DecodeTest) {
13
const
std::vector<unsigned char> expectedVal = {0x00, 0xFF, 0x01, 0xFE};
14
EXPECT_EQ(
foxglove::base64Decode
(
"AP8B/g=="
), expectedVal);
15
}
16
17
TEST
(
Base64Test
, DecodeInvalidStringTest) {
18
// String length not multiple of 4
19
EXPECT_THROW(
foxglove::base64Decode
(
"faefa"
), std::runtime_error);
20
// Invalid characters
21
EXPECT_THROW(
foxglove::base64Decode
(
"fa^ef a"
), std::runtime_error);
22
}
23
24
int
main
(
int
argc,
char
** argv) {
25
testing::InitGoogleTest(&argc, argv);
26
return
RUN_ALL_TESTS();
27
}
main
int main(int argc, char **argv)
Definition:
base64_test.cpp:24
TEST
TEST(Base64Test, EncodingTest)
Definition:
base64_test.cpp:5
base64.hpp
foxglove::base64Encode
std::string base64Encode(const std::string_view &input)
Definition:
base64.cpp:10
foxglove::base64Decode
std::vector< unsigned char > base64Decode(const std::string &input)
Definition:
base64.cpp:47
Base64Test
foxglove_bridge
Author(s): Foxglove
autogenerated on Tue May 20 2025 02:34:26