Consistency in namespace-closing comments
[folly.git] / folly / io / async / test / AsyncSocketTest.cpp
index e8f3cf120fcf84d8440fe4bdb37e7cc747e36eef..a9f7e46aa12eb450839b9f179bdbb38d2376f31e 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.
  */
 #include <iostream>
 
-#include <folly/io/async/AsyncSocket.h>
 #include <folly/io/async/AsyncServerSocket.h>
+#include <folly/io/async/AsyncSocket.h>
 #include <folly/io/async/EventBase.h>
-
-#include <gtest/gtest.h>
+#include <folly/portability/GTest.h>
 
 namespace folly {
 
@@ -76,4 +75,17 @@ TEST(AsyncSocketTest, v4v6samePort) {
   }
 }
 
+TEST(AsyncSocketTest, duplicateBind) {
+  EventBase base;
+  auto server1 = AsyncServerSocket::newSocket(&base);
+  server1->bind(0);
+  server1->listen(10);
+
+  SocketAddress address;
+  server1->getAddress(std::addressof(address));
+
+  auto server2 = AsyncServerSocket::newSocket(&base);
+  EXPECT_THROW(server2->bind(address.getPort()), std::exception);
+}
+
 } // namespace