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

Side by Side Diff: remoting/base/util_unittest.cc

Issue 209323002: New policies: enable/disable relay; port range (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a few more tests. 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 6
7 #include "remoting/base/util.h" 7 #include "remoting/base/util.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" 9 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
10 10
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // Invalid first byte 278 // Invalid first byte
279 EXPECT_FALSE(StringIsUtf8("\xfe\x80\x80\x80\x80\x80\x80", 7)); 279 EXPECT_FALSE(StringIsUtf8("\xfe\x80\x80\x80\x80\x80\x80", 7));
280 EXPECT_FALSE(StringIsUtf8("\xff\x80\x80\x80\x80\x80\x80", 7)); 280 EXPECT_FALSE(StringIsUtf8("\xff\x80\x80\x80\x80\x80\x80", 7));
281 281
282 // Invalid continuation byte 282 // Invalid continuation byte
283 EXPECT_FALSE(StringIsUtf8("\xc0\x00", 2)); 283 EXPECT_FALSE(StringIsUtf8("\xc0\x00", 2));
284 EXPECT_FALSE(StringIsUtf8("\xc0\x40", 2)); 284 EXPECT_FALSE(StringIsUtf8("\xc0\x40", 2));
285 EXPECT_FALSE(StringIsUtf8("\xc0\xc0", 2)); 285 EXPECT_FALSE(StringIsUtf8("\xc0\xc0", 2));
286 } 286 }
287 287
288 TEST(ParsePortRange, Basic) {
289 int min_port, max_port;
290
291 // Valid range
292 EXPECT_TRUE(ParsePortRange("1-65535", &min_port, &max_port));
293 EXPECT_EQ(1, min_port);
294 EXPECT_EQ(65535, max_port);
295
296 EXPECT_TRUE(ParsePortRange(" 1 - 65535 ", &min_port, &max_port));
297 EXPECT_EQ(1, min_port);
298 EXPECT_EQ(65535, max_port);
299
300 EXPECT_TRUE(ParsePortRange("12400-12400", &min_port, &max_port));
301 EXPECT_EQ(12400, min_port);
302 EXPECT_EQ(12400, max_port);
303
304 // Invalid
305 EXPECT_FALSE(ParsePortRange("", &min_port, &max_port));
306 EXPECT_FALSE(ParsePortRange("-65535", &min_port, &max_port));
307 EXPECT_FALSE(ParsePortRange("1-", &min_port, &max_port));
308 EXPECT_FALSE(ParsePortRange("-", &min_port, &max_port));
309 EXPECT_FALSE(ParsePortRange("-1-65535", &min_port, &max_port));
310 EXPECT_FALSE(ParsePortRange("0-65535", &min_port, &max_port));
311 EXPECT_FALSE(ParsePortRange("1-65536", &min_port, &max_port));
312 EXPECT_FALSE(ParsePortRange("1-4294967295", &min_port, &max_port));
313 EXPECT_FALSE(ParsePortRange("10-1", &min_port, &max_port));
314 }
315
288 } // namespace remoting 316 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698