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

Side by Side Diff: remoting/jingle_glue/network_settings_unittest.cc

Issue 209323002: New policies: enable/disable relay; port range (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: policy_templates.json; addressed other CR comments. Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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 "remoting/jingle_glue/network_settings.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 namespace remoting {
9
10 TEST(ParsePortRange, Basic) {
11 int min_port, max_port;
12
13 // Valid range
14 EXPECT_TRUE(ParsePortRange("1-65535", &min_port, &max_port));
15 EXPECT_EQ(1, min_port);
16 EXPECT_EQ(65535, max_port);
17
18 EXPECT_TRUE(ParsePortRange(" 1 - 65535 ", &min_port, &max_port));
19 EXPECT_EQ(1, min_port);
20 EXPECT_EQ(65535, max_port);
21
22 EXPECT_TRUE(ParsePortRange("12400-12400", &min_port, &max_port));
23 EXPECT_EQ(12400, min_port);
24 EXPECT_EQ(12400, max_port);
25
26 // Invalid
27 EXPECT_FALSE(ParsePortRange("", &min_port, &max_port));
28 EXPECT_FALSE(ParsePortRange("-65535", &min_port, &max_port));
29 EXPECT_FALSE(ParsePortRange("1-", &min_port, &max_port));
30 EXPECT_FALSE(ParsePortRange("-", &min_port, &max_port));
31 EXPECT_FALSE(ParsePortRange("-1-65535", &min_port, &max_port));
32 EXPECT_FALSE(ParsePortRange("0-65535", &min_port, &max_port));
33 EXPECT_FALSE(ParsePortRange("1-65536", &min_port, &max_port));
34 EXPECT_FALSE(ParsePortRange("1-4294967295", &min_port, &max_port));
35 EXPECT_FALSE(ParsePortRange("10-1", &min_port, &max_port));
36 }
37
38 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698