blob: 742c16af5209db4de5caa4773db54ab85e21a273 [file] [log] [blame]
Darin Petkov877642b2011-06-27 13:37:22 -07001// Copyright (c) 2011 The Chromium OS 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
5#include <gtest/gtest.h>
6
7#include "shill/crypto_rot47.h"
8
9using std::string;
10using testing::Test;
11
12namespace shill {
13
14namespace {
15const char kEmpty[] = "";
16const char kPlainText[] = "~{\"Hello world!\" OPQ ['1234']}";
17const char kCipherText[] = "OLQw6==@ H@C=5PQ ~!\" ,V`abcV.N";
18} // namespace {}
19
20class CryptoROT47Test : public Test {
21 protected:
22 CryptoROT47 crypto_;
23};
24
25TEST_F(CryptoROT47Test, GetID) {
26 EXPECT_EQ(CryptoROT47::kID, crypto_.GetID());
27}
28
29TEST_F(CryptoROT47Test, Encrypt) {
30 string text;
31 EXPECT_TRUE(crypto_.Encrypt(kPlainText, &text));
32 EXPECT_EQ(kCipherText, text);
33 EXPECT_TRUE(crypto_.Encrypt(kEmpty, &text));
34 EXPECT_EQ(kEmpty, text);
35}
36
37TEST_F(CryptoROT47Test, Decrypt) {
38 string text;
39 EXPECT_TRUE(crypto_.Decrypt(kCipherText, &text));
40 EXPECT_EQ(kPlainText, text);
41 EXPECT_TRUE(crypto_.Decrypt(kEmpty, &text));
42 EXPECT_EQ(kEmpty, text);
43}
44
45} // namespace shill