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

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: 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("12400-12400", &min_port, &max_port));
297 EXPECT_EQ(12400, min_port);
298 EXPECT_EQ(12400, max_port);
299
300 // Invalid
301 EXPECT_FALSE(ParsePortRange("0-65535", &min_port, &max_port));
302 EXPECT_FALSE(ParsePortRange("1-65536", &min_port, &max_port));
303 EXPECT_FALSE(ParsePortRange("1-4294967295", &min_port, &max_port));
304 EXPECT_FALSE(ParsePortRange("10-1", &min_port, &max_port));
305 }
306
288 } // namespace remoting 307 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698