add missing include to ThreadId.h
[folly.git] / folly / test / DiscriminatedPtrTest.cpp
index e282d9d38e72d5e5c6cf4717180495dd71fe5601..f4d4ca70957e8b8f4f444dc69e312621e5a0b0dc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-#include "folly/DiscriminatedPtr.h"
+#include <folly/DiscriminatedPtr.h>
 
-#include <gtest/gtest.h>
+#include <folly/portability/GTest.h>
 
 using namespace folly;
 
@@ -68,10 +68,10 @@ TEST(DiscriminatedPtr, Basic) {
 TEST(DiscriminatedPtr, Apply) {
   struct Foo { };
   struct Visitor {
-    std::string operator()(int* ptr) { return "int"; }
-    std::string operator()(const int* ptr) { return "const int"; }
-    std::string operator()(Foo* ptr) { return "Foo"; }
-    std::string operator()(const Foo* ptr) { return "const Foo"; }
+    std::string operator()(int* /* ptr */) { return "int"; }
+    std::string operator()(const int* /* ptr */) { return "const int"; }
+    std::string operator()(Foo* /* ptr */) { return "Foo"; }
+    std::string operator()(const Foo* /* ptr */) { return "const Foo"; }
   };
 
   typedef DiscriminatedPtr<int, Foo> Ptr;
@@ -86,6 +86,9 @@ TEST(DiscriminatedPtr, Apply) {
   p.set(&foo);
   EXPECT_EQ("Foo", p.apply(Visitor()));
   EXPECT_EQ("const Foo", static_cast<const Ptr&>(p).apply(Visitor()));
+  EXPECT_EQ("Foo", apply_visitor(Visitor(), p));
+  EXPECT_EQ("const Foo", apply_visitor(Visitor(), static_cast<const Ptr&>(p)));
+  EXPECT_EQ("Foo", apply_visitor(Visitor(), std::move(p)));
 
   p.clear();
   EXPECT_THROW({p.apply(Visitor());}, std::invalid_argument);
@@ -94,10 +97,10 @@ TEST(DiscriminatedPtr, Apply) {
 TEST(DiscriminatedPtr, ApplyVoid) {
   struct Foo { };
   struct Visitor {
-    void operator()(int* ptr) { result = "int"; }
-    void operator()(const int* ptr) { result = "const int"; }
-    void operator()(Foo* ptr) { result = "Foo"; }
-    void operator()(const Foo* ptr) { result = "const Foo"; }
+    void operator()(int* /* ptr */) { result = "int"; }
+    void operator()(const int* /* ptr */) { result = "const int"; }
+    void operator()(Foo* /* ptr */) { result = "Foo"; }
+    void operator()(const Foo* /* ptr */) { result = "const Foo"; }
 
     std::string result;
   };