| Index: net/dns/mdns_query_unittest.cc
|
| diff --git a/net/dns/mdns_query_unittest.cc b/net/dns/mdns_query_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..56d75995edfa082dbc328e0771ec07901d7cf908
|
| --- /dev/null
|
| +++ b/net/dns/mdns_query_unittest.cc
|
| @@ -0,0 +1,42 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "net/dns/mdns_query.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace net {
|
| +
|
| +namespace {
|
| +
|
| +TEST(MDnsQueryTest, Constructor) {
|
| + // This includes \0 at the end.
|
| + const char qname_data[] = "\x03""www""\x07""example""\x03""com";
|
| + const uint8 query_data[] = {
|
| + // Header
|
| + 0x00, 0x00,
|
| + 0x00, 0x00, // Flags not set.
|
| + 0x00, 0x01, // Set QDCOUNT (question count) to 1, all the
|
| + // rest are 0 for a query.
|
| + 0x00, 0x00,
|
| + 0x00, 0x00,
|
| + 0x00, 0x00,
|
| +
|
| + // Question
|
| + 0x03, 'w', 'w', 'w', // QNAME: www.example.com in DNS format.
|
| + 0x07, 'e', 'x', 'a', 'm', 'p', 'l', 'e',
|
| + 0x03, 'c', 'o', 'm',
|
| + 0x00,
|
| +
|
| + 0x00, 0x01, // QTYPE: A query.
|
| + 0x00, 0x01, // QCLASS: IN class. Unicast bit not set.
|
| + };
|
| +
|
| + base::StringPiece qname(qname_data, sizeof(qname_data));
|
| + MDnsQuery q1(qname, dns_protocol::kTypeA);
|
| +
|
| + EXPECT_EQ(sizeof(query_data), q1.size());
|
| + EXPECT_EQ(0, memcmp(q1.io_buffer()->data(), query_data, sizeof(query_data)));
|
| +}
|
| +}
|
| +}
|
|
|