summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-04-21 21:14:13 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-04-21 21:14:13 (GMT)
commit181814572bf67d603d56a52a6fe3e12a2344c395 (patch)
tree45bedc7d343e18cb050dba074b59c1839eab5a63 /Swiften/QA
parentb462b193e32c38132b5f4ff9bc6f38ff3bd444bd (diff)
downloadswift-181814572bf67d603d56a52a6fe3e12a2344c395.zip
swift-181814572bf67d603d56a52a6fe3e12a2344c395.tar.bz2
Fix non-determinism of DomainNameResolverTest.
Diffstat (limited to 'Swiften/QA')
-rw-r--r--Swiften/QA/NetworkTest/DomainNameResolverTest.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp
index 7c99487..cd3c3e1 100644
--- a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp
+++ b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp
@@ -8,6 +8,8 @@
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <boost/bind.hpp>
+#include <algorithm>
+
#include "Swiften/Base/sleep.h"
#include "Swiften/Base/String.h"
#include "Swiften/Base/ByteArray.h"
@@ -18,6 +20,12 @@
using namespace Swift;
+struct CompareHostAddresses {
+ bool operator()(const HostAddress& h1, const HostAddress& h2) {
+ return h1.toString() < h2.toString();
+ }
+};
+
class DomainNameResolverTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(DomainNameResolverTest);
CPPUNIT_TEST(testResolveAddress);
@@ -82,8 +90,8 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(!addressQueryError);
CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(addressQueryResult.size()));
- CPPUNIT_ASSERT_EQUAL(std::string("1234:5678:9abc:def0:0fed:cba9:8765:4321"), addressQueryResult[0].toString());
- CPPUNIT_ASSERT_EQUAL(std::string("10.0.0.7"), addressQueryResult[1].toString());
+ CPPUNIT_ASSERT_EQUAL(std::string("10.0.0.7"), addressQueryResult[0].toString());
+ CPPUNIT_ASSERT_EQUAL(std::string("1234:5678:9abc:def0:0fed:cba9:8765:4321"), addressQueryResult[1].toString());
}
void testResolveAddress_International() {
@@ -104,8 +112,7 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
waitForResults();
CPPUNIT_ASSERT(!addressQueryError);
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(addressQueryResult.size()));
- CPPUNIT_ASSERT_EQUAL(std::string("127.0.0.1"), addressQueryResult[0].toString());
+ CPPUNIT_ASSERT(std::find(addressQueryResult.begin(), addressQueryResult.end(), HostAddress("127.0.0.1")) != addressQueryResult.end());
}
@@ -150,6 +157,7 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
void handleAddressQueryResult(const std::vector<HostAddress>& addresses, boost::optional<DomainNameResolveError> error) {
addressQueryResult = addresses;
+ std::sort(addressQueryResult.begin(), addressQueryResult.end(), CompareHostAddresses());
addressQueryError = error;
resultsAvailable = true;
}