Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Side by Side Diff: net/dns/address_sorter_unittest.cc

Issue 10442098: [net/dns] Resolve AF_UNSPEC on dual-stacked systems. Sort addresses according to RFC3484. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle ifa_netmnask == NULL and other errors after getifaddrs. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/dns/address_sorter.h"
6
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "base/synchronization/waitable_event.h"
10 #include "net/base/address_list.h"
11 #include "net/base/net_util.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace net {
15 namespace {
16
17 IPEndPoint MakeEndPoint(const std::string& str) {
18 IPAddressNumber addr;
19 CHECK(ParseIPLiteralToNumber(str, &addr));
20 return IPEndPoint(addr, 0);
21 }
22
23 void OnSortComplete(AddressList* result_buf,
24 base::WaitableEvent* event,
25 bool success,
26 const AddressList& result) {
27 EXPECT_TRUE(success);
28 if (success)
29 *result_buf = result;
30 event->Signal();
31 }
32
33 TEST(AddressSorterTest, Sort) {
34 scoped_ptr<AddressSorter> sorter(AddressSorter::CreateAddressSorter());
35 AddressList list;
36 list.push_back(MakeEndPoint("10.0.0.1"));
37 list.push_back(MakeEndPoint("8.8.8.8"));
38 list.push_back(MakeEndPoint("::1"));
39 list.push_back(MakeEndPoint("2001:4860:4860::8888"));
40
41 base::WaitableEvent event(false, false);
42 AddressList result;
43 sorter->Sort(list, base::Bind(&OnSortComplete, &result, &event));
44 event.Wait();
45 }
46
47 } // namespace
48 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698