[llvm] r280033 - Rename unittests/ADT/ilistTestTemp.cpp => IListTest.cpp

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 29 17:18:43 PDT 2016


Author: dexonsmith
Date: Mon Aug 29 19:18:43 2016
New Revision: 280033

URL: http://llvm.org/viewvc/llvm-project?rev=280033&view=rev
Log:
Rename unittests/ADT/ilistTestTemp.cpp => IListTest.cpp

And rename the tests inside from ilistTest to IListTest.  This makes the
file sort properly in the CMakeLists.txt (previously, sorting would
throw it down to the end of the list) and is consistent with the tests
I've added more recently.

Why use IListNodeBaseTest.cpp (and a test name of IListNodeBaseTest)?
- ilist_node_base_test is the obvious thing, since this is testing
  ilist_node_base.  However, gtest disallows underscores in test names.
- ilist_node_baseTest fails for the same reason.
- ilistNodeBaseTest is weird, because it isn't in our usual
  TitleCaseTest form that we use for tests, and it also doesn't have the
  name of the tested class in it.
- IlistNodeBaseTest matches TitleCaseTest, but "Ilist" is hard to read,
  and really "ilist" is an abbreviation for "IntrusiveList" so the
  lowercase "list" is strange.
- That left IListNodeBaseTest.

Note: I made this move in two stages, with a temporary filename of
ilistTestTemp in between in r279524.  This was in the hopes of avoiding
problems on Git and SVN clients on case-insensitive filesystems,
particularly on buildbots with incremental checkouts.

Added:
    llvm/trunk/unittests/ADT/IListTest.cpp
      - copied, changed from r280032, llvm/trunk/unittests/ADT/ilistTestTemp.cpp
Removed:
    llvm/trunk/unittests/ADT/ilistTestTemp.cpp
Modified:
    llvm/trunk/unittests/ADT/CMakeLists.txt

Modified: llvm/trunk/unittests/ADT/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/CMakeLists.txt?rev=280033&r1=280032&r2=280033&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/CMakeLists.txt (original)
+++ llvm/trunk/unittests/ADT/CMakeLists.txt Mon Aug 29 19:18:43 2016
@@ -17,11 +17,11 @@ set(ADTSources
   FoldingSet.cpp
   FunctionRefTest.cpp
   HashingTest.cpp
-  ilistTestTemp.cpp
   IListBaseTest.cpp
   IListIteratorTest.cpp
   IListNodeBaseTest.cpp
   IListSentinelTest.cpp
+  IListTest.cpp
   ImmutableMapTest.cpp
   ImmutableSetTest.cpp
   IntEqClassesTest.cpp

Copied: llvm/trunk/unittests/ADT/IListTest.cpp (from r280032, llvm/trunk/unittests/ADT/ilistTestTemp.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/IListTest.cpp?p2=llvm/trunk/unittests/ADT/IListTest.cpp&p1=llvm/trunk/unittests/ADT/ilistTestTemp.cpp&r1=280032&r2=280033&rev=280033&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/ilistTestTemp.cpp (original)
+++ llvm/trunk/unittests/ADT/IListTest.cpp Mon Aug 29 19:18:43 2016
@@ -1,4 +1,4 @@
-//===- unittests/ADT/ilistTestTemp.cpp - ilist unit tests -----------------===//
+//===- unittests/ADT/IListTest.cpp - ilist unit tests ---------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,9 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// FIXME: Rename this file to IListTest.cpp once incremental checkouts on bots
-// have found this file.
-
 #include "llvm/ADT/ilist.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ilist_node.h"
@@ -29,7 +26,7 @@ struct Node : ilist_node<Node> {
   ~Node() { Value = -1; }
 };
 
-TEST(ilistTest, Basic) {
+TEST(IListTest, Basic) {
   ilist<Node> List;
   List.push_back(Node(1));
   EXPECT_EQ(1, List.back().Value);
@@ -47,7 +44,7 @@ TEST(ilistTest, Basic) {
   EXPECT_EQ(1, ConstList.getPrevNode(ConstList.back())->Value);
 }
 
-TEST(ilistTest, SpliceOne) {
+TEST(IListTest, SpliceOne) {
   ilist<Node> List;
   List.push_back(1);
 
@@ -67,7 +64,7 @@ TEST(ilistTest, SpliceOne) {
   EXPECT_EQ(3, List.back().Value);
 }
 
-TEST(ilistTest, SpliceSwap) {
+TEST(IListTest, SpliceSwap) {
   ilist<Node> L;
   Node N0(0);
   Node N1(1);
@@ -83,7 +80,7 @@ TEST(ilistTest, SpliceSwap) {
   L.clearAndLeakNodesUnsafely();
 }
 
-TEST(ilistTest, SpliceSwapOtherWay) {
+TEST(IListTest, SpliceSwapOtherWay) {
   ilist<Node> L;
   Node N0(0);
   Node N1(1);
@@ -99,7 +96,7 @@ TEST(ilistTest, SpliceSwapOtherWay) {
   L.clearAndLeakNodesUnsafely();
 }
 
-TEST(ilistTest, UnsafeClear) {
+TEST(IListTest, UnsafeClear) {
   ilist<Node> List;
 
   // Before even allocating a sentinel.
@@ -132,7 +129,7 @@ TEST(ilistTest, UnsafeClear) {
 }
 
 struct Empty {};
-TEST(ilistTest, HasObsoleteCustomizationTrait) {
+TEST(IListTest, HasObsoleteCustomizationTrait) {
   // Negative test for HasObsoleteCustomization.
   static_assert(!ilist_detail::HasObsoleteCustomization<Empty, Node>::value,
                 "Empty has no customizations");
@@ -141,7 +138,7 @@ TEST(ilistTest, HasObsoleteCustomization
 struct GetNext {
   Node *getNext(Node *);
 };
-TEST(ilistTest, HasGetNextTrait) {
+TEST(IListTest, HasGetNextTrait) {
   static_assert(ilist_detail::HasGetNext<GetNext, Node>::value,
                 "GetNext has a getNext(Node*)");
   static_assert(ilist_detail::HasObsoleteCustomization<GetNext, Node>::value,
@@ -155,7 +152,7 @@ TEST(ilistTest, HasGetNextTrait) {
 struct CreateSentinel {
   Node *createSentinel();
 };
-TEST(ilistTest, HasCreateSentinelTrait) {
+TEST(IListTest, HasCreateSentinelTrait) {
   static_assert(ilist_detail::HasCreateSentinel<CreateSentinel>::value,
                 "CreateSentinel has a getNext(Node*)");
   static_assert(
@@ -189,7 +186,7 @@ struct ilist_traits<NodeWithCallback>
 
 namespace {
 
-TEST(ilistTest, addNodeToList) {
+TEST(IListTest, addNodeToList) {
   ilist<NodeWithCallback> L;
   NodeWithCallback N(7);
   ASSERT_FALSE(N.IsInList);
@@ -214,7 +211,7 @@ struct PrivateNode : private ilist_node<
   PrivateNode(const PrivateNode &) = delete;
 };
 
-TEST(ilistTest, privateNode) {
+TEST(IListTest, privateNode) {
   // Instantiate various APIs to be sure they're callable when ilist_node is
   // inherited privately.
   ilist<NodeWithCallback> L;

Removed: llvm/trunk/unittests/ADT/ilistTestTemp.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/ilistTestTemp.cpp?rev=280032&view=auto
==============================================================================
--- llvm/trunk/unittests/ADT/ilistTestTemp.cpp (original)
+++ llvm/trunk/unittests/ADT/ilistTestTemp.cpp (removed)
@@ -1,232 +0,0 @@
-//===- unittests/ADT/ilistTestTemp.cpp - ilist unit tests -----------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// FIXME: Rename this file to IListTest.cpp once incremental checkouts on bots
-// have found this file.
-
-#include "llvm/ADT/ilist.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/ilist_node.h"
-#include "gtest/gtest.h"
-#include <ostream>
-
-using namespace llvm;
-
-namespace {
-
-struct Node : ilist_node<Node> {
-  int Value;
-
-  Node() {}
-  Node(int Value) : Value(Value) {}
-  Node(const Node&) = default;
-  ~Node() { Value = -1; }
-};
-
-TEST(ilistTest, Basic) {
-  ilist<Node> List;
-  List.push_back(Node(1));
-  EXPECT_EQ(1, List.back().Value);
-  EXPECT_EQ(nullptr, List.getPrevNode(List.back()));
-  EXPECT_EQ(nullptr, List.getNextNode(List.back()));
-
-  List.push_back(Node(2));
-  EXPECT_EQ(2, List.back().Value);
-  EXPECT_EQ(2, List.getNextNode(List.front())->Value);
-  EXPECT_EQ(1, List.getPrevNode(List.back())->Value);
-
-  const ilist<Node> &ConstList = List;
-  EXPECT_EQ(2, ConstList.back().Value);
-  EXPECT_EQ(2, ConstList.getNextNode(ConstList.front())->Value);
-  EXPECT_EQ(1, ConstList.getPrevNode(ConstList.back())->Value);
-}
-
-TEST(ilistTest, SpliceOne) {
-  ilist<Node> List;
-  List.push_back(1);
-
-  // The single-element splice operation supports noops.
-  List.splice(List.begin(), List, List.begin());
-  EXPECT_EQ(1u, List.size());
-  EXPECT_EQ(1, List.front().Value);
-  EXPECT_TRUE(std::next(List.begin()) == List.end());
-
-  // Altenative noop. Move the first element behind itself.
-  List.push_back(2);
-  List.push_back(3);
-  List.splice(std::next(List.begin()), List, List.begin());
-  EXPECT_EQ(3u, List.size());
-  EXPECT_EQ(1, List.front().Value);
-  EXPECT_EQ(2, std::next(List.begin())->Value);
-  EXPECT_EQ(3, List.back().Value);
-}
-
-TEST(ilistTest, SpliceSwap) {
-  ilist<Node> L;
-  Node N0(0);
-  Node N1(1);
-  L.insert(L.end(), &N0);
-  L.insert(L.end(), &N1);
-  EXPECT_EQ(0, L.front().Value);
-  EXPECT_EQ(1, L.back().Value);
-
-  L.splice(L.begin(), L, ++L.begin());
-  EXPECT_EQ(1, L.front().Value);
-  EXPECT_EQ(0, L.back().Value);
-
-  L.clearAndLeakNodesUnsafely();
-}
-
-TEST(ilistTest, SpliceSwapOtherWay) {
-  ilist<Node> L;
-  Node N0(0);
-  Node N1(1);
-  L.insert(L.end(), &N0);
-  L.insert(L.end(), &N1);
-  EXPECT_EQ(0, L.front().Value);
-  EXPECT_EQ(1, L.back().Value);
-
-  L.splice(L.end(), L, L.begin());
-  EXPECT_EQ(1, L.front().Value);
-  EXPECT_EQ(0, L.back().Value);
-
-  L.clearAndLeakNodesUnsafely();
-}
-
-TEST(ilistTest, UnsafeClear) {
-  ilist<Node> List;
-
-  // Before even allocating a sentinel.
-  List.clearAndLeakNodesUnsafely();
-  EXPECT_EQ(0u, List.size());
-
-  // Empty list with sentinel.
-  ilist<Node>::iterator E = List.end();
-  List.clearAndLeakNodesUnsafely();
-  EXPECT_EQ(0u, List.size());
-  // The sentinel shouldn't change.
-  EXPECT_TRUE(E == List.end());
-
-  // List with contents.
-  List.push_back(1);
-  ASSERT_EQ(1u, List.size());
-  Node *N = &*List.begin();
-  EXPECT_EQ(1, N->Value);
-  List.clearAndLeakNodesUnsafely();
-  EXPECT_EQ(0u, List.size());
-  ASSERT_EQ(1, N->Value);
-  delete N;
-
-  // List is still functional.
-  List.push_back(5);
-  List.push_back(6);
-  ASSERT_EQ(2u, List.size());
-  EXPECT_EQ(5, List.front().Value);
-  EXPECT_EQ(6, List.back().Value);
-}
-
-struct Empty {};
-TEST(ilistTest, HasObsoleteCustomizationTrait) {
-  // Negative test for HasObsoleteCustomization.
-  static_assert(!ilist_detail::HasObsoleteCustomization<Empty, Node>::value,
-                "Empty has no customizations");
-}
-
-struct GetNext {
-  Node *getNext(Node *);
-};
-TEST(ilistTest, HasGetNextTrait) {
-  static_assert(ilist_detail::HasGetNext<GetNext, Node>::value,
-                "GetNext has a getNext(Node*)");
-  static_assert(ilist_detail::HasObsoleteCustomization<GetNext, Node>::value,
-                "Empty should be obsolete because of getNext()");
-
-  // Negative test for HasGetNext.
-  static_assert(!ilist_detail::HasGetNext<Empty, Node>::value,
-                "Empty does not have a getNext(Node*)");
-}
-
-struct CreateSentinel {
-  Node *createSentinel();
-};
-TEST(ilistTest, HasCreateSentinelTrait) {
-  static_assert(ilist_detail::HasCreateSentinel<CreateSentinel>::value,
-                "CreateSentinel has a getNext(Node*)");
-  static_assert(
-      ilist_detail::HasObsoleteCustomization<CreateSentinel, Node>::value,
-      "Empty should be obsolete because of createSentinel()");
-
-  // Negative test for HasCreateSentinel.
-  static_assert(!ilist_detail::HasCreateSentinel<Empty>::value,
-                "Empty does not have a createSentinel()");
-}
-
-struct NodeWithCallback : ilist_node<NodeWithCallback> {
-  int Value = 0;
-  bool IsInList = false;
-
-  NodeWithCallback() = default;
-  NodeWithCallback(int Value) : Value(Value) {}
-  NodeWithCallback(const NodeWithCallback &) = delete;
-};
-
-} // end namespace
-
-namespace llvm {
-template <>
-struct ilist_traits<NodeWithCallback>
-    : public ilist_node_traits<NodeWithCallback> {
-  void addNodeToList(NodeWithCallback *N) { N->IsInList = true; }
-  void removeNodeFromList(NodeWithCallback *N) { N->IsInList = false; }
-};
-} // end namespace llvm
-
-namespace {
-
-TEST(ilistTest, addNodeToList) {
-  ilist<NodeWithCallback> L;
-  NodeWithCallback N(7);
-  ASSERT_FALSE(N.IsInList);
-
-  L.insert(L.begin(), &N);
-  ASSERT_EQ(1u, L.size());
-  ASSERT_EQ(&N, &*L.begin());
-  ASSERT_TRUE(N.IsInList);
-
-  L.remove(&N);
-  ASSERT_EQ(0u, L.size());
-  ASSERT_FALSE(N.IsInList);
-}
-
-struct PrivateNode : private ilist_node<PrivateNode> {
-  friend struct llvm::ilist_node_access;
-
-  int Value = 0;
-
-  PrivateNode() = default;
-  PrivateNode(int Value) : Value(Value) {}
-  PrivateNode(const PrivateNode &) = delete;
-};
-
-TEST(ilistTest, privateNode) {
-  // Instantiate various APIs to be sure they're callable when ilist_node is
-  // inherited privately.
-  ilist<NodeWithCallback> L;
-  NodeWithCallback N(7);
-  L.insert(L.begin(), &N);
-  ++L.begin();
-  (void)*L.begin();
-  (void)(L.begin() == L.end());
-
-  ilist<NodeWithCallback> L2;
-  L2.splice(L2.end(), L);
-  L2.remove(&N);
-}
-
-} // end namespace




More information about the llvm-commits mailing list