1 // socktests.cpp : sock.{h,cpp} unit tests. 2 // 3 4 5 /** 6 * Copyright (C) 2018-present MongoDB, Inc. 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the Server Side Public License, version 1, 10 * as published by MongoDB, Inc. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * Server Side Public License for more details. 16 * 17 * You should have received a copy of the Server Side Public License 18 * along with this program. If not, see 19 * <http://www.mongodb.com/licensing/server-side-public-license>. 20 * 21 * As a special exception, the copyright holders give permission to link the 22 * code of portions of this program with the OpenSSL library under certain 23 * conditions as described in each individual source file and distribute 24 * linked combinations including the program with the OpenSSL library. You 25 * must comply with the Server Side Public License in all respects for 26 * all of the code used other than as permitted herein. If you modify file(s) 27 * with this exception, you may extend this exception to your version of the 28 * file(s), but you are not obligated to do so. If you do not wish to do so, 29 * delete this exception statement from your version. If you delete this 30 * exception statement from all source files in the program, then also delete 31 * it in the license file. 32 */ 33 34 #include "mongo/platform/basic.h" 35 36 #include "mongo/db/repl/isself.h" 37 #include "mongo/dbtests/dbtests.h" 38 #include "mongo/util/net/hostandport.h" 39 #include "mongo/util/net/sock.h" 40 41 namespace SockTests { 42 43 class HostByName { 44 public: run()45 void run() { 46 ASSERT_EQUALS("127.0.0.1", hostbyname("localhost")); 47 ASSERT_EQUALS("127.0.0.1", hostbyname("127.0.0.1")); 48 // ASSERT_EQUALS( "::1", hostbyname( "::1" ) ); // IPv6 disabled at runtime by default. 49 50 HostAndPort h("asdfasdfasdf_no_such_host"); 51 ASSERT_EQUALS("", hostbyname("asdfasdfasdf_no_such_host")); 52 } 53 }; 54 55 class All : public Suite { 56 public: All()57 All() : Suite("sock") {} setupTests()58 void setupTests() { 59 add<HostByName>(); 60 } 61 }; 62 63 SuiteInstance<All> myall; 64 65 } // namespace SockTests 66