mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2026-02-19 14:46:28 +00:00
If the input doesn't have the proper number of encoding characters (a multiple of 4), return an empty result. Co-Authored-By: Sean Curtis <sean.curtis@tri.global>
21 lines
705 B
C++
21 lines
705 B
C++
#include "gtest/gtest.h"
|
|
#include <yaml-cpp/binary.h>
|
|
|
|
TEST(BinaryTest, DecodingSimple) {
|
|
std::string input{90, 71, 86, 104, 90, 71, 74, 108, 90, 87, 89, 61};
|
|
const std::vector<unsigned char> &result = YAML::DecodeBase64(input);
|
|
EXPECT_EQ(std::string(result.begin(), result.end()), "deadbeef");
|
|
}
|
|
|
|
TEST(BinaryTest, DecodingNoCrashOnNegative) {
|
|
std::string input{-58, -1, -99, 109};
|
|
const std::vector<unsigned char> &result = YAML::DecodeBase64(input);
|
|
EXPECT_TRUE(result.empty());
|
|
}
|
|
|
|
TEST(BinaryTest, DecodingTooShort) {
|
|
std::string input{90, 71, 86, 104, 90, 71, 74, 108, 90, 87, 89};
|
|
const std::vector<unsigned char> &result = YAML::DecodeBase64(input);
|
|
EXPECT_TRUE(result.empty());
|
|
}
|