base64_unittest.cc 606 B

123456789101112131415161718192021222324252627
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "butil/base64.h"
  5. #include <gtest/gtest.h>
  6. namespace butil {
  7. TEST(Base64Test, Basic) {
  8. const std::string kText = "hello world";
  9. const std::string kBase64Text = "aGVsbG8gd29ybGQ=";
  10. std::string encoded;
  11. std::string decoded;
  12. bool ok;
  13. Base64Encode(kText, &encoded);
  14. EXPECT_EQ(kBase64Text, encoded);
  15. ok = Base64Decode(encoded, &decoded);
  16. EXPECT_TRUE(ok);
  17. EXPECT_EQ(kText, decoded);
  18. }
  19. } // namespace butil