From 44ca9a392ac6238a8cf76bb6469252c121d64df0 Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Tue, 13 Nov 2018 11:16:40 +0100 Subject: [PATCH] Allow usage of stringstream under examples/. This CL addresses comment #56 on webrtc:8982 [1]. [1] - https://bugs.chromium.org/p/webrtc/issues/detail?id=8982#c56 Bug: webrtc:8982 Change-Id: Iaf56fbcdae4937db1ee6e550d2300d29b6975cfd No-Try: True Reviewed-on: https://webrtc-review.googlesource.com/c/110720 Commit-Queue: Mirko Bonadei Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#25619} --- PRESUBMIT.py | 3 ++- examples/stunprober/main.cc | 2 +- examples/turnserver/read_auth_file.cc | 3 +-- examples/turnserver/read_auth_file.h | 5 ++--- examples/turnserver/read_auth_file_unittest.cc | 9 ++++----- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 797fb2de4a..0bcf99777b 100755 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -481,7 +481,8 @@ def CheckNoStreamUsageIsAdded(input_api, output_api, file_filter = lambda x: (input_api.FilterSourceFile(x) and source_file_filter(x)) for f in input_api.AffectedSourceFiles(file_filter): - if f.LocalPath() == 'PRESUBMIT.py': + # Usage of stringstream is allowed under examples/. + if f.LocalPath() == 'PRESUBMIT.py' or f.LocalPath().startswith('examples'): continue for line_num, line in f.ChangedContents(): if ((include_re.search(line) or usage_re.search(line)) diff --git a/examples/stunprober/main.cc b/examples/stunprober/main.cc index f438fcf64d..6da96e4699 100644 --- a/examples/stunprober/main.cc +++ b/examples/stunprober/main.cc @@ -14,7 +14,7 @@ #include #include -#include // no-presubmit-check TODO(webrtc:8982) +#include #include "p2p/base/basicpacketsocketfactory.h" #include "p2p/stunprober/stunprober.h" diff --git a/examples/turnserver/read_auth_file.cc b/examples/turnserver/read_auth_file.cc index adb2fd894a..de5465e82f 100644 --- a/examples/turnserver/read_auth_file.cc +++ b/examples/turnserver/read_auth_file.cc @@ -13,8 +13,7 @@ namespace webrtc_examples { -std::map ReadAuthFile( - std::istream* s) { // no-presubmit-check TODO(webrtc:8982) +std::map ReadAuthFile(std::istream* s) { std::map name_to_key; for (std::string line; std::getline(*s, line);) { const size_t sep = line.find('='); diff --git a/examples/turnserver/read_auth_file.h b/examples/turnserver/read_auth_file.h index 4a8564e4b9..1c139c9924 100644 --- a/examples/turnserver/read_auth_file.h +++ b/examples/turnserver/read_auth_file.h @@ -11,14 +11,13 @@ #ifndef EXAMPLES_TURNSERVER_READ_AUTH_FILE_H_ #define EXAMPLES_TURNSERVER_READ_AUTH_FILE_H_ -#include // no-presubmit-check TODO(webrtc:8982) +#include #include #include namespace webrtc_examples { -std::map ReadAuthFile( - std::istream* s); // no-presubmit-check TODO(webrtc:8982) +std::map ReadAuthFile(std::istream* s); } // namespace webrtc_examples diff --git a/examples/turnserver/read_auth_file_unittest.cc b/examples/turnserver/read_auth_file_unittest.cc index de7d8ec839..4a6f332c27 100644 --- a/examples/turnserver/read_auth_file_unittest.cc +++ b/examples/turnserver/read_auth_file_unittest.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include // no-presubmit-check TODO(webrtc:8982) +#include #include "examples/turnserver/read_auth_file.h" #include "test/gtest.h" @@ -16,21 +16,20 @@ namespace webrtc_examples { TEST(ReadAuthFile, HandlesEmptyFile) { - std::istringstream empty; // no-presubmit-check TODO(webrtc:8982) + std::istringstream empty; auto map = ReadAuthFile(&empty); EXPECT_TRUE(map.empty()); } TEST(ReadAuthFile, RecognizesValidUser) { - std::istringstream // no-presubmit-check TODO(webrtc:8982) - file("foo=deadbeaf\n"); + std::istringstream file("foo=deadbeaf\n"); auto map = ReadAuthFile(&file); ASSERT_NE(map.find("foo"), map.end()); EXPECT_EQ(map["foo"], "\xde\xad\xbe\xaf"); } TEST(ReadAuthFile, EmptyValueForInvalidHex) { - std::istringstream file( // no-presubmit-check TODO(webrtc:8982) + std::istringstream file( "foo=deadbeaf\n" "bar=xxxxinvalidhex\n" "baz=cafe\n");