[llvm] [CGData] Outlined Hash Tree (PR #89792)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 10:17:49 PDT 2024


================
@@ -0,0 +1,82 @@
+//===- OutlinedHashTreeTest.cpp -------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/CodeGenData/OutlinedHashTree.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+
+TEST(OutlinedHashTreeTest, Empty) {
+  OutlinedHashTree HashTree;
+  ASSERT_TRUE(HashTree.empty());
+  // The header node is always present.
+  ASSERT_TRUE(HashTree.size() == 1);
+  ASSERT_TRUE(HashTree.depth() == 0);
----------------
ellishg wrote:

```suggestion
  EXPECT_TRUE(HashTree.empty());
  // The header node is always present.
  EXPECT_EQ(HashTree.size(), 1);
  EXPECT_EQ(HashTree.depth(), 0);
```

Using `EXPECT` means the test won't exit on the first failure. `ASSERT` is used when continuing is not useful, like if some value is null. And `EXPECT_EQ()` will show both values if they are not equal to help with debugging.

https://github.com/llvm/llvm-project/pull/89792


More information about the llvm-commits mailing list