Base64Test.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2022-01-08
  6. * Changed: 2023-02-22
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include <ls-std/ls-std-encoding.hpp>
  11. using ls::std::encoding::Base64;
  12. using testing::Test;
  13. namespace
  14. {
  15. class Base64Test : public Test
  16. {
  17. protected:
  18. Base64Test() = default;
  19. ~Base64Test() override = default;
  20. void SetUp() override
  21. {}
  22. void TearDown() override
  23. {}
  24. };
  25. TEST_F(Base64Test, encode)
  26. {
  27. Base64 base64{};
  28. ASSERT_STREQ("YWJj", base64.encode("abc").c_str());
  29. ASSERT_STREQ("YWJjZGU=", base64.encode("abcde").c_str());
  30. ASSERT_STREQ("SGVsbG8gQysrIQ==", base64.encode("Hello C++!").c_str());
  31. ASSERT_STREQ("UG9seWZvbiB6d2l0c2NoZXJuZCBhw59lbiBNw6R4Y2hlbnMgVsO2Z2VsIFLDvGJlbiwgSm9naHVydCB1bmQgUXVhcms=", base64.encode("Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark").c_str());
  32. }
  33. TEST_F(Base64Test, decode)
  34. {
  35. Base64 base64{};
  36. ASSERT_STREQ("abc", base64.decode("YWJj").c_str());
  37. ASSERT_STREQ("abcde", base64.decode("YWJjZGU=").c_str());
  38. ASSERT_STREQ("Hello C++!", base64.decode("SGVsbG8gQysrIQ==").c_str());
  39. ASSERT_STREQ("Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark", base64.decode("UG9seWZvbiB6d2l0c2NoZXJuZCBhw59lbiBNw6R4Y2hlbnMgVsO2Z2VsIFLDvGJlbiwgSm9naHVydCB1bmQgUXVhcms=").c_str());
  40. }
  41. }