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

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

Issue 15733008: Multicast DNS implementation (initial) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mdns_implementation2
Patch Set: Renamed files from "listener" to "client" Created 7 years, 6 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 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/mdns_query.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace net {
9
10 namespace {
11
12 TEST(MDnsQueryTest, Constructor) {
13 // This includes \0 at the end.
14 const char qname_data[] = "\x03""www""\x07""example""\x03""com";
15 const uint8 query_data[] = {
16 // Header
17 0x00, 0x00,
18 0x00, 0x00, // Flags not set.
19 0x00, 0x01, // Set QDCOUNT (question count) to 1, all the
20 // rest are 0 for a query.
21 0x00, 0x00,
22 0x00, 0x00,
23 0x00, 0x00,
24
25 // Question
26 0x03, 'w', 'w', 'w', // QNAME: www.example.com in DNS format.
27 0x07, 'e', 'x', 'a', 'm', 'p', 'l', 'e',
28 0x03, 'c', 'o', 'm',
29 0x00,
30
31 0x00, 0x01, // QTYPE: A query.
32 0x00, 0x01, // QCLASS: IN class. Unicast bit not set.
33 };
34
35 base::StringPiece qname(qname_data, sizeof(qname_data));
36 MDnsQuery q1(qname, dns_protocol::kTypeA);
37
38 EXPECT_EQ(sizeof(query_data), q1.size());
39 EXPECT_EQ(0, memcmp(q1.io_buffer()->data(), query_data, sizeof(query_data)));
40 }
41 }
42 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698