#include #include "jwt-cpp/base.h" TEST(BaseTest, Base64Decode) { ASSERT_EQ("1", jwt::base::decode("MQ==")); ASSERT_EQ("12", jwt::base::decode("MTI=")); ASSERT_EQ("123", jwt::base::decode("MTIz")); ASSERT_EQ("1234", jwt::base::decode("MTIzNA==")); } TEST(BaseTest, Base64DecodeURL) { ASSERT_EQ("1", jwt::base::decode("MQ%3d%3d")); ASSERT_EQ("12", jwt::base::decode("MTI%3d")); ASSERT_EQ("123", jwt::base::decode("MTIz")); ASSERT_EQ("1234", jwt::base::decode("MTIzNA%3d%3d")); } TEST(BaseTest, Base64Encode) { ASSERT_EQ("MQ==", jwt::base::encode("1")); ASSERT_EQ("MTI=", jwt::base::encode("12")); ASSERT_EQ("MTIz", jwt::base::encode("123")); ASSERT_EQ("MTIzNA==", jwt::base::encode("1234")); } TEST(BaseTest, Base64EncodeURL) { ASSERT_EQ("MQ%3d%3d", jwt::base::encode("1")); ASSERT_EQ("MTI%3d", jwt::base::encode("12")); ASSERT_EQ("MTIz", jwt::base::encode("123")); ASSERT_EQ("MTIzNA%3d%3d", jwt::base::encode("1234")); } TEST(BaseTest, Base64Pad) { ASSERT_EQ("MQ==", jwt::base::pad("MQ")); ASSERT_EQ("MTI=", jwt::base::pad("MTI")); ASSERT_EQ("MTIz", jwt::base::pad("MTIz")); ASSERT_EQ("MTIzNA==", jwt::base::pad("MTIzNA")); } TEST(BaseTest, Base64PadURL) { ASSERT_EQ("MQ%3d%3d", jwt::base::pad("MQ")); ASSERT_EQ("MTI%3d", jwt::base::pad("MTI")); ASSERT_EQ("MTIz", jwt::base::pad("MTIz")); ASSERT_EQ("MTIzNA%3d%3d", jwt::base::pad("MTIzNA")); } TEST(BaseTest, Base64Trim) { ASSERT_EQ("MQ", jwt::base::trim("MQ==")); ASSERT_EQ("MTI", jwt::base::trim("MTI=")); ASSERT_EQ("MTIz", jwt::base::trim("MTIz")); ASSERT_EQ("MTIzNA", jwt::base::trim("MTIzNA==")); } TEST(BaseTest, Base64TrimURL) { ASSERT_EQ("MQ", jwt::base::trim("MQ%3d%3d")); ASSERT_EQ("MTI", jwt::base::trim("MTI%3d")); ASSERT_EQ("MTIz", jwt::base::trim("MTIz")); ASSERT_EQ("MTIzNA", jwt::base::trim("MTIzNA%3d%3d")); }