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