[MemProf] Templatize CallStackRadixTreeBuilder (NFC) (#117014)
[llvm-project.git] / lldb / unittests / Utility / ChecksumTest.cpp
bloba81aba2ee98ca18148ac07fc7eaf31ad9f92b934
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 //===----------------------------------------------------------------------===//
9 #include "gtest/gtest.h"
11 #include "lldb/Utility/Checksum.h"
13 using namespace lldb_private;
15 static llvm::MD5::MD5Result hash1 = {
16 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}};
18 static llvm::MD5::MD5Result hash2 = {
19 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}};
21 static llvm::MD5::MD5Result hash3 = {
22 {8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7}};
24 TEST(ChecksumTest, TestConstructor) {
25 Checksum checksum1;
26 EXPECT_FALSE(static_cast<bool>(checksum1));
27 EXPECT_EQ(checksum1, Checksum());
29 Checksum checksum2 = Checksum(hash1);
30 EXPECT_EQ(checksum2, Checksum(hash1));
32 Checksum checksum3(checksum2);
33 EXPECT_EQ(checksum3, Checksum(hash1));
36 TEST(ChecksumTest, TestCopyConstructor) {
37 Checksum checksum1;
38 EXPECT_FALSE(static_cast<bool>(checksum1));
39 EXPECT_EQ(checksum1, Checksum());
41 Checksum checksum2 = checksum1;
42 EXPECT_EQ(checksum2, checksum1);
44 Checksum checksum3(checksum1);
45 EXPECT_EQ(checksum3, checksum1);
48 TEST(ChecksumTest, TestMD5) {
49 Checksum checksum1(hash1);
50 EXPECT_TRUE(static_cast<bool>(checksum1));
52 // Make sure two checksums with the same underlying hashes are the same.
53 EXPECT_EQ(Checksum(hash1), Checksum(hash2));
55 // Make sure two checksums with different underlying hashes are different.
56 EXPECT_NE(Checksum(hash1), Checksum(hash3));