Allow Optionals to be compared to None
[oota-llvm.git] / unittests / ADT / OptionalTest.cpp
index 3ede81cfacca820358e2901256af7b8057e3a119..18b59e315818eaa84eb35464e702b131c9099c1d 100644 (file)
@@ -183,10 +183,10 @@ struct MultiArgConstructor {
   explicit MultiArgConstructor(int x, bool positive)
     : x(x), y(positive ? x : -x) {}
 
-  MultiArgConstructor(const MultiArgConstructor &) LLVM_DELETED_FUNCTION;
-  MultiArgConstructor(MultiArgConstructor &&) LLVM_DELETED_FUNCTION;
-  MultiArgConstructor &operator=(const MultiArgConstructor &) LLVM_DELETED_FUNCTION;
-  MultiArgConstructor &operator=(MultiArgConstructor &&) LLVM_DELETED_FUNCTION;
+  MultiArgConstructor(const MultiArgConstructor &) = delete;
+  MultiArgConstructor(MultiArgConstructor &&) = delete;
+  MultiArgConstructor &operator=(const MultiArgConstructor &) = delete;
+  MultiArgConstructor &operator=(MultiArgConstructor &&) = delete;
 
   static unsigned Destructions;
   ~MultiArgConstructor() {
@@ -340,13 +340,13 @@ struct Immovable {
   }
 private:
   // This should disable all move/copy operations.
-  Immovable(Immovable&& other) LLVM_DELETED_FUNCTION;
+  Immovable(Immovable&& other) = delete;
 };
 
 unsigned Immovable::Constructions = 0;
 unsigned Immovable::Destructions = 0;
 
-TEST_F(OptionalTest, MoveOnlyEmplace) {
+TEST_F(OptionalTest, ImmovableEmplace) {
   Optional<Immovable> A;
   Immovable::ResetCounts();
   A.emplace(4);
@@ -377,5 +377,18 @@ TEST_F(OptionalTest, MoveGetValueOr) {
 
 #endif // LLVM_HAS_RVALUE_REFERENCE_THIS
 
+TEST_F(OptionalTest, NoneComparison) {
+  Optional<int> o;
+  EXPECT_EQ(o, None);
+  EXPECT_EQ(None, o);
+  EXPECT_FALSE(o != None);
+  EXPECT_FALSE(None != o);
+  o = 3;
+  EXPECT_FALSE(o == None);
+  EXPECT_FALSE(None == o);
+  EXPECT_TRUE(o != None);
+  EXPECT_TRUE(None != o);
+}
+
 } // end anonymous namespace