OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 ASSERT_STREQ("D", fields.at(0).c_str()); | 291 ASSERT_STREQ("D", fields.at(0).c_str()); |
292 ASSERT_STREQ("\"A", fields.at(1).c_str()); | 292 ASSERT_STREQ("\"A", fields.at(1).c_str()); |
293 | 293 |
294 tokenize("D (A B) C (E F) G", ' ', '(', ')', &fields); | 294 tokenize("D (A B) C (E F) G", ' ', '(', ')', &fields); |
295 ASSERT_EQ(5ul, fields.size()); | 295 ASSERT_EQ(5ul, fields.size()); |
296 ASSERT_STREQ("D", fields.at(0).c_str()); | 296 ASSERT_STREQ("D", fields.at(0).c_str()); |
297 ASSERT_STREQ("A B", fields.at(1).c_str()); | 297 ASSERT_STREQ("A B", fields.at(1).c_str()); |
298 ASSERT_STREQ("E F", fields.at(3).c_str()); | 298 ASSERT_STREQ("E F", fields.at(3).c_str()); |
299 } | 299 } |
300 | 300 |
301 TEST(TokenizeTest, TokenizeWithEmptyTokens) { | |
302 std::vector<std::string> fields; | |
303 EXPECT_EQ(3ul, tokenize_with_empty_tokens("a.b.c", '.', &fields)); | |
304 EXPECT_EQ("a", fields[0]); | |
305 EXPECT_EQ("b", fields[1]); | |
306 EXPECT_EQ("c", fields[2]); | |
307 | |
308 EXPECT_EQ(3ul, tokenize_with_empty_tokens("..c", '.', &fields)); | |
tommi
2015/09/16 21:51:01
add a test case for source == ""?
Taylor Brandstetter
2015/09/24 00:25:05
Done.
| |
309 EXPECT_TRUE(fields[0].empty()); | |
310 EXPECT_TRUE(fields[1].empty()); | |
311 EXPECT_EQ("c", fields[2]); | |
312 } | |
313 | |
301 TEST(TokenizeFirstTest, NoLeadingSpaces) { | 314 TEST(TokenizeFirstTest, NoLeadingSpaces) { |
302 std::string token; | 315 std::string token; |
303 std::string rest; | 316 std::string rest; |
304 | 317 |
305 ASSERT_TRUE(tokenize_first("A &*${}", ' ', &token, &rest)); | 318 ASSERT_TRUE(tokenize_first("A &*${}", ' ', &token, &rest)); |
306 ASSERT_STREQ("A", token.c_str()); | 319 ASSERT_STREQ("A", token.c_str()); |
307 ASSERT_STREQ("&*${}", rest.c_str()); | 320 ASSERT_STREQ("&*${}", rest.c_str()); |
308 | 321 |
309 ASSERT_TRUE(tokenize_first("A B& *${}", ' ', &token, &rest)); | 322 ASSERT_TRUE(tokenize_first("A B& *${}", ' ', &token, &rest)); |
310 ASSERT_STREQ("A", token.c_str()); | 323 ASSERT_STREQ("A", token.c_str()); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 EXPECT_FALSE(FromString<bool>("false\nfalse")); | 434 EXPECT_FALSE(FromString<bool>("false\nfalse")); |
422 } | 435 } |
423 | 436 |
424 TEST(BoolTest, RoundTrip) { | 437 TEST(BoolTest, RoundTrip) { |
425 bool value; | 438 bool value; |
426 EXPECT_TRUE(FromString(ToString(true), &value)); | 439 EXPECT_TRUE(FromString(ToString(true), &value)); |
427 EXPECT_TRUE(value); | 440 EXPECT_TRUE(value); |
428 EXPECT_TRUE(FromString(ToString(false), &value)); | 441 EXPECT_TRUE(FromString(ToString(false), &value)); |
429 EXPECT_FALSE(value); | 442 EXPECT_FALSE(value); |
430 } | 443 } |
444 | |
431 } // namespace rtc | 445 } // namespace rtc |
OLD | NEW |