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 <mbonadei@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25619}
This commit is contained in:
Mirko Bonadei
2018-11-13 11:16:40 +01:00
committed by Commit Bot
parent 105edcaeaf
commit 44ca9a392a
5 changed files with 10 additions and 12 deletions

View File

@ -481,7 +481,8 @@ def CheckNoStreamUsageIsAdded(input_api, output_api,
file_filter = lambda x: (input_api.FilterSourceFile(x) file_filter = lambda x: (input_api.FilterSourceFile(x)
and source_file_filter(x)) and source_file_filter(x))
for f in input_api.AffectedSourceFiles(file_filter): 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 continue
for line_num, line in f.ChangedContents(): for line_num, line in f.ChangedContents():
if ((include_re.search(line) or usage_re.search(line)) if ((include_re.search(line) or usage_re.search(line))

View File

@ -14,7 +14,7 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <sstream> // no-presubmit-check TODO(webrtc:8982) #include <sstream>
#include "p2p/base/basicpacketsocketfactory.h" #include "p2p/base/basicpacketsocketfactory.h"
#include "p2p/stunprober/stunprober.h" #include "p2p/stunprober/stunprober.h"

View File

@ -13,8 +13,7 @@
namespace webrtc_examples { namespace webrtc_examples {
std::map<std::string, std::string> ReadAuthFile( std::map<std::string, std::string> ReadAuthFile(std::istream* s) {
std::istream* s) { // no-presubmit-check TODO(webrtc:8982)
std::map<std::string, std::string> name_to_key; std::map<std::string, std::string> name_to_key;
for (std::string line; std::getline(*s, line);) { for (std::string line; std::getline(*s, line);) {
const size_t sep = line.find('='); const size_t sep = line.find('=');

View File

@ -11,14 +11,13 @@
#ifndef EXAMPLES_TURNSERVER_READ_AUTH_FILE_H_ #ifndef EXAMPLES_TURNSERVER_READ_AUTH_FILE_H_
#define EXAMPLES_TURNSERVER_READ_AUTH_FILE_H_ #define EXAMPLES_TURNSERVER_READ_AUTH_FILE_H_
#include <istream> // no-presubmit-check TODO(webrtc:8982) #include <istream>
#include <map> #include <map>
#include <string> #include <string>
namespace webrtc_examples { namespace webrtc_examples {
std::map<std::string, std::string> ReadAuthFile( std::map<std::string, std::string> ReadAuthFile(std::istream* s);
std::istream* s); // no-presubmit-check TODO(webrtc:8982)
} // namespace webrtc_examples } // namespace webrtc_examples

View File

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include <sstream> // no-presubmit-check TODO(webrtc:8982) #include <sstream>
#include "examples/turnserver/read_auth_file.h" #include "examples/turnserver/read_auth_file.h"
#include "test/gtest.h" #include "test/gtest.h"
@ -16,21 +16,20 @@
namespace webrtc_examples { namespace webrtc_examples {
TEST(ReadAuthFile, HandlesEmptyFile) { TEST(ReadAuthFile, HandlesEmptyFile) {
std::istringstream empty; // no-presubmit-check TODO(webrtc:8982) std::istringstream empty;
auto map = ReadAuthFile(&empty); auto map = ReadAuthFile(&empty);
EXPECT_TRUE(map.empty()); EXPECT_TRUE(map.empty());
} }
TEST(ReadAuthFile, RecognizesValidUser) { TEST(ReadAuthFile, RecognizesValidUser) {
std::istringstream // no-presubmit-check TODO(webrtc:8982) std::istringstream file("foo=deadbeaf\n");
file("foo=deadbeaf\n");
auto map = ReadAuthFile(&file); auto map = ReadAuthFile(&file);
ASSERT_NE(map.find("foo"), map.end()); ASSERT_NE(map.find("foo"), map.end());
EXPECT_EQ(map["foo"], "\xde\xad\xbe\xaf"); EXPECT_EQ(map["foo"], "\xde\xad\xbe\xaf");
} }
TEST(ReadAuthFile, EmptyValueForInvalidHex) { TEST(ReadAuthFile, EmptyValueForInvalidHex) {
std::istringstream file( // no-presubmit-check TODO(webrtc:8982) std::istringstream file(
"foo=deadbeaf\n" "foo=deadbeaf\n"
"bar=xxxxinvalidhex\n" "bar=xxxxinvalidhex\n"
"baz=cafe\n"); "baz=cafe\n");