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.
5 #include "remoting/protocol/network_settings.h"
7 #include "testing/gtest/include/gtest/gtest.h"
12 TEST(ParsePortRange
, Basic
) {
16 EXPECT_TRUE(NetworkSettings::ParsePortRange("1-65535", &min
, &max
));
18 EXPECT_EQ(65535u, max
);
20 EXPECT_TRUE(NetworkSettings::ParsePortRange(" 1 - 65535 ", &min
, &max
));
22 EXPECT_EQ(65535u, max
);
24 EXPECT_TRUE(NetworkSettings::ParsePortRange("12400-12400", &min
, &max
));
25 EXPECT_EQ(12400u, min
);
26 EXPECT_EQ(12400u, max
);
29 EXPECT_FALSE(NetworkSettings::ParsePortRange("", &min
, &max
));
30 EXPECT_FALSE(NetworkSettings::ParsePortRange("-65535", &min
, &max
));
31 EXPECT_FALSE(NetworkSettings::ParsePortRange("1-", &min
, &max
));
32 EXPECT_FALSE(NetworkSettings::ParsePortRange("-", &min
, &max
));
33 EXPECT_FALSE(NetworkSettings::ParsePortRange("-1-65535", &min
, &max
));
34 EXPECT_FALSE(NetworkSettings::ParsePortRange("1--65535", &min
, &max
));
35 EXPECT_FALSE(NetworkSettings::ParsePortRange("1-65535-", &min
, &max
));
36 EXPECT_FALSE(NetworkSettings::ParsePortRange("0-65535", &min
, &max
));
37 EXPECT_FALSE(NetworkSettings::ParsePortRange("1-65536", &min
, &max
));
38 EXPECT_FALSE(NetworkSettings::ParsePortRange("1-4294967295", &min
, &max
));
39 EXPECT_FALSE(NetworkSettings::ParsePortRange("10-1", &min
, &max
));
40 EXPECT_FALSE(NetworkSettings::ParsePortRange("1foo-2bar", &min
, &max
));
43 } // namespace protocol
44 } // namespace remoting