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.
5 #include "net/base/port_util.h"
9 #include "testing/gtest/include/gtest/gtest.h"
13 TEST(NetUtilTest
, SetExplicitlyAllowedPortsTest
) {
14 std::string invalid
[] = {"1,2,a", "'1','2'", "1, 2, 3", "1 0,11,12"};
15 std::string valid
[] = {"", "1", "1,2", "1,2,3", "10,11,12,13"};
17 for (size_t i
= 0; i
< arraysize(invalid
); ++i
) {
18 SetExplicitlyAllowedPorts(invalid
[i
]);
19 EXPECT_EQ(0, static_cast<int>(GetCountOfExplicitlyAllowedPorts()));
22 for (size_t i
= 0; i
< arraysize(valid
); ++i
) {
23 SetExplicitlyAllowedPorts(valid
[i
]);
24 EXPECT_EQ(i
, GetCountOfExplicitlyAllowedPorts());