summaryrefslogtreecommitdiff
path: root/dbtests
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-01-21 15:50:49 -0500
committerAaron <aaron@10gen.com>2009-01-21 15:50:49 -0500
commit046e7f9acf00f96c77fc92dc37efc1a5fcd2652a (patch)
treec95ff3871272498f358060c4bfd8f243016a2c62 /dbtests
parent9a36738d0c62e7a6d5950d0495e30f8c41f23e96 (diff)
downloadmongo-046e7f9acf00f96c77fc92dc37efc1a5fcd2652a.tar.gz
Add HostByName test
Diffstat (limited to 'dbtests')
-rw-r--r--dbtests/dbtests.cpp1
-rw-r--r--dbtests/dbtests.h1
-rw-r--r--dbtests/socktests.cpp45
3 files changed, 47 insertions, 0 deletions
diff --git a/dbtests/dbtests.cpp b/dbtests/dbtests.cpp
index f72925e3a94..bba5fe8c9bb 100644
--- a/dbtests/dbtests.cpp
+++ b/dbtests/dbtests.cpp
@@ -90,6 +90,7 @@ int main( int argc, char** argv ) {
tests.add( pairingTests(), "pairing" );
tests.add( pdfileTests(), "pdfile" );
tests.add( queryTests(), "query" );
+ tests.add( sockTests(), "sock" );
return tests.run( argc, argv );
}
diff --git a/dbtests/dbtests.h b/dbtests/dbtests.h
index 8a55e23f91d..84a8c1df4c2 100644
--- a/dbtests/dbtests.h
+++ b/dbtests/dbtests.h
@@ -29,3 +29,4 @@ UnitTest::TestPtr namespaceTests();
UnitTest::TestPtr pairingTests();
UnitTest::TestPtr pdfileTests();
UnitTest::TestPtr queryTests();
+UnitTest::TestPtr sockTests();
diff --git a/dbtests/socktests.cpp b/dbtests/socktests.cpp
new file mode 100644
index 00000000000..7923f25e73c
--- /dev/null
+++ b/dbtests/socktests.cpp
@@ -0,0 +1,45 @@
+// socktests.cpp : sock.{h,cpp} unit tests.
+//
+
+/**
+ * Copyright (C) 2008 10gen Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "../util/sock.h"
+
+#include "dbtests.h"
+
+namespace SockTests {
+
+ class HostByName {
+ public:
+ void run() {
+ ASSERT_EQUALS( "127.0.0.1", hostbyname( "localhost" ) );
+ ASSERT_EQUALS( "127.0.0.1", hostbyname( "127.0.0.1" ) );
+ }
+ };
+
+ class All : public UnitTest::Suite {
+ public:
+ All() {
+ add< HostByName >();
+ }
+ };
+
+} // namespace SockTests
+
+UnitTest::TestPtr sockTests() {
+ return UnitTest::createSuite< SockTests::All >();
+} \ No newline at end of file