59 lines
1.8 KiB
C++
59 lines
1.8 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// Copyright 2020 Google LLC.
|
|
//
|
|
// This software is licensed under the terms defined in the Widevine Master
|
|
// License Agreement. For a copy of this agreement, please contact
|
|
// widevine-licensing@google.com.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "common/hash_algorithm_util.h"
|
|
|
|
#include "testing/gmock.h"
|
|
#include "testing/gunit.h"
|
|
#include "common/hash_algorithm.h"
|
|
|
|
namespace widevine {
|
|
|
|
TEST(HashAlgorithmTest, ProtoToEnumUnspecified) {
|
|
EXPECT_EQ(HashAlgorithm::kUnspecified,
|
|
HashAlgorithmProtoToEnum(HASH_ALGORITHM_UNSPECIFIED));
|
|
}
|
|
|
|
TEST(HashAlgorithmTest, ProtoToEnumSha1) {
|
|
EXPECT_EQ(HashAlgorithm::kSha1,
|
|
HashAlgorithmProtoToEnum(HASH_ALGORITHM_SHA_1));
|
|
}
|
|
|
|
TEST(HashAlgorithmTest, ProtoToEnumSha256) {
|
|
EXPECT_EQ(HashAlgorithm::kSha256,
|
|
HashAlgorithmProtoToEnum(HASH_ALGORITHM_SHA_256));
|
|
}
|
|
|
|
TEST(HashAlgorithmTest, ProtoToEnumUnsupported) {
|
|
EXPECT_EQ(HashAlgorithm::kUnspecified,
|
|
HashAlgorithmProtoToEnum(static_cast<HashAlgorithmProto>(1234)));
|
|
}
|
|
|
|
TEST(HashAlgorithmTest, EnumToProtoUnspecified) {
|
|
EXPECT_EQ(HASH_ALGORITHM_UNSPECIFIED,
|
|
HashAlgorithmEnumToProto(HashAlgorithm::kUnspecified));
|
|
}
|
|
|
|
TEST(HashAlgorithmTest, EnumToProtoSha1) {
|
|
EXPECT_EQ(HASH_ALGORITHM_SHA_1,
|
|
HashAlgorithmEnumToProto(HashAlgorithm::kSha1));
|
|
}
|
|
|
|
TEST(HashAlgorithmTest, EnumToProtoSha256) {
|
|
EXPECT_EQ(HASH_ALGORITHM_SHA_256,
|
|
HashAlgorithmEnumToProto(HashAlgorithm::kSha256));
|
|
}
|
|
|
|
TEST(HashAlgorithmTest, EnumToProtoUnexpected) {
|
|
int some_value = 1234;
|
|
EXPECT_EQ(HASH_ALGORITHM_UNSPECIFIED,
|
|
HashAlgorithmEnumToProto(static_cast<HashAlgorithm>(some_value)));
|
|
}
|
|
|
|
} // namespace widevine
|