2 * Copyright 2016 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #include <gtest/gtest.h>
17 #include <folly/io/async/AsyncSocketException.h>
19 using namespace testing;
23 TEST(AsyncSocketException, SimpleTest) {
24 AsyncSocketException ex1(
25 AsyncSocketException::AsyncSocketExceptionType::NOT_OPEN,
28 EXPECT_EQ(AsyncSocketException::AsyncSocketExceptionType::NOT_OPEN,
30 EXPECT_EQ(0, ex1.getErrno());
31 EXPECT_EQ("AsyncSocketException: test exception 1, type = Socket not open",
32 std::string(ex1.what()));
34 AsyncSocketException ex2(
35 AsyncSocketException::AsyncSocketExceptionType::BAD_ARGS,
37 111 /*ECONNREFUSED*/);
39 EXPECT_EQ(AsyncSocketException::AsyncSocketExceptionType::BAD_ARGS,
41 EXPECT_EQ(111, ex2.getErrno());
43 "AsyncSocketException: test exception 2, type = Invalid arguments, "
44 "errno = 111 (Connection refused)",
45 std::string(ex2.what()));