llvm-project
57 строк · 1.7 Кб
1//===-- ChecksumTest.cpp --------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "gtest/gtest.h"10
11#include "lldb/Utility/Checksum.h"12
13using namespace lldb_private;14
15static llvm::MD5::MD5Result hash1 = {16{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}};17
18static llvm::MD5::MD5Result hash2 = {19{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}};20
21static llvm::MD5::MD5Result hash3 = {22{8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7}};23
24TEST(ChecksumTest, TestConstructor) {25Checksum checksum1;26EXPECT_FALSE(static_cast<bool>(checksum1));27EXPECT_EQ(checksum1, Checksum());28
29Checksum checksum2 = Checksum(hash1);30EXPECT_EQ(checksum2, Checksum(hash1));31
32Checksum checksum3(checksum2);33EXPECT_EQ(checksum3, Checksum(hash1));34}
35
36TEST(ChecksumTest, TestCopyConstructor) {37Checksum checksum1;38EXPECT_FALSE(static_cast<bool>(checksum1));39EXPECT_EQ(checksum1, Checksum());40
41Checksum checksum2 = checksum1;42EXPECT_EQ(checksum2, checksum1);43
44Checksum checksum3(checksum1);45EXPECT_EQ(checksum3, checksum1);46}
47
48TEST(ChecksumTest, TestMD5) {49Checksum checksum1(hash1);50EXPECT_TRUE(static_cast<bool>(checksum1));51
52// Make sure two checksums with the same underlying hashes are the same.53EXPECT_EQ(Checksum(hash1), Checksum(hash2));54
55// Make sure two checksums with different underlying hashes are different.56EXPECT_NE(Checksum(hash1), Checksum(hash3));57}
58