blob: 9b23194ccf6587f20fafe549bfe97756a20dacaf [file] [log] [blame]
tfarina@chromium.org2c155672012-09-23 13:51:04 +09001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
hayato@chromium.org268ac3a2009-11-24 15:21:53 +09002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/base64.h"
tfarina@chromium.org2c155672012-09-23 13:51:04 +09006
hayato@chromium.org268ac3a2009-11-24 15:21:53 +09007#include "testing/gtest/include/gtest/gtest.h"
8
tfarina@chromium.org2c155672012-09-23 13:51:04 +09009namespace base {
hayato@chromium.org268ac3a2009-11-24 15:21:53 +090010
11TEST(Base64Test, Basic) {
12 const std::string kText = "hello world";
13 const std::string kBase64Text = "aGVsbG8gd29ybGQ=";
14
tfarina@chromium.org2c155672012-09-23 13:51:04 +090015 std::string encoded;
16 std::string decoded;
hayato@chromium.org268ac3a2009-11-24 15:21:53 +090017 bool ok;
18
vadimt@chromium.org528238b2013-12-11 10:48:50 +090019 Base64Encode(kText, &encoded);
hayato@chromium.org268ac3a2009-11-24 15:21:53 +090020 EXPECT_EQ(kBase64Text, encoded);
21
tfarina@chromium.org2c155672012-09-23 13:51:04 +090022 ok = Base64Decode(encoded, &decoded);
hayato@chromium.org268ac3a2009-11-24 15:21:53 +090023 EXPECT_TRUE(ok);
24 EXPECT_EQ(kText, decoded);
25}
tfarina@chromium.org2c155672012-09-23 13:51:04 +090026
27} // namespace base