1 // Copyright 2017 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 ////////////////////////////////////////////////////////////////////////////////
16
17 #include "tink/subtle/common_enums.h"
18 #include "gtest/gtest.h"
19
20 namespace crypto {
21 namespace tink {
22 namespace subtle {
23 namespace {
24
25 class CommonEnumsTest : public ::testing::Test {};
26
TEST_F(CommonEnumsTest,testEllipticCurveTypeToString)27 TEST_F(CommonEnumsTest, testEllipticCurveTypeToString) {
28 EXPECT_EQ("NIST_P256", EnumToString(EllipticCurveType::NIST_P256));
29 EXPECT_EQ("NIST_P384", EnumToString(EllipticCurveType::NIST_P384));
30 EXPECT_EQ("NIST_P521", EnumToString(EllipticCurveType::NIST_P521));
31 EXPECT_EQ("UNKNOWN_CURVE", EnumToString(EllipticCurveType::UNKNOWN_CURVE));
32 EXPECT_EQ("UNKNOWN_CURVE: 42", EnumToString((EllipticCurveType)42));
33 }
34
TEST_F(CommonEnumsTest,testHashTypeToString)35 TEST_F(CommonEnumsTest, testHashTypeToString) {
36 EXPECT_EQ("SHA1", EnumToString(HashType::SHA1));
37 EXPECT_EQ("SHA224", EnumToString(HashType::SHA224));
38 EXPECT_EQ("SHA256", EnumToString(HashType::SHA256));
39 EXPECT_EQ("SHA384", EnumToString(HashType::SHA384));
40 EXPECT_EQ("SHA512", EnumToString(HashType::SHA512));
41 EXPECT_EQ("UNKNOWN_HASH", EnumToString(HashType::UNKNOWN_HASH));
42 EXPECT_EQ("UNKNOWN_HASH: 42", EnumToString((HashType)42));
43 }
44
TEST_F(CommonEnumsTest,testEcPointFormatToString)45 TEST_F(CommonEnumsTest, testEcPointFormatToString) {
46 EXPECT_EQ("UNCOMPRESSED", EnumToString(EcPointFormat::UNCOMPRESSED));
47 EXPECT_EQ("COMPRESSED", EnumToString(EcPointFormat::COMPRESSED));
48 EXPECT_EQ("DO_NOT_USE_CRUNCHY_UNCOMPRESSED",
49 EnumToString(EcPointFormat::DO_NOT_USE_CRUNCHY_UNCOMPRESSED));
50
51 EXPECT_EQ("UNKNOWN_FORMAT", EnumToString(EcPointFormat::UNKNOWN_FORMAT));
52 EXPECT_EQ("UNKNOWN_FORMAT: 42", EnumToString((EcPointFormat)42));
53 }
54
55 } // namespace
56 } // namespace subtle
57 } // namespace tink
58 } // namespace crypto
59