OLD | NEW |
(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 } |
OLD | NEW |