summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/net/render_dns_master_unittest.cc
blob: 0a4b6373cf392bdb06ed97c1a599d62dde00aca7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (c) 2006-2008 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.

// Single threaded tests of RenderDnsMaster functionality.

#include "chrome/renderer/net/render_dns_master.h"
#include "testing/gtest/include/gtest/gtest.h"

#include <algorithm>

namespace {

class RenderDnsMasterTest : public testing::Test {
};

TEST(RenderDnsMasterTest, NumericIpDiscardCheck) {
  // Regular names.
  const std::string A("a.com"), B("b.net"), C("www.other.uk");
  // Combination of digits plus dots.
  const std::string N1("1.3."), N2("5.5.7.12");

#define TESTNAME(string) RenderDnsMaster::is_numeric_ip((string.data()), \
                                                        (string).size())

  EXPECT_TRUE(TESTNAME(N1));
  EXPECT_TRUE(TESTNAME(N2));

  EXPECT_FALSE(TESTNAME(A));
  EXPECT_FALSE(TESTNAME(B));
  EXPECT_FALSE(TESTNAME(C));

#undef TESTNAME
}

}  // namespace anonymous