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)); |
| 309 EXPECT_TRUE(fields[0].empty()); |
| 310 EXPECT_TRUE(fields[1].empty()); |
| 311 EXPECT_EQ("c", fields[2]); |
| 312 |
| 313 EXPECT_EQ(1ul, tokenize_with_empty_tokens("", '.', &fields)); |
| 314 EXPECT_TRUE(fields[0].empty()); |
| 315 } |
| 316 |
301 TEST(TokenizeFirstTest, NoLeadingSpaces) { | 317 TEST(TokenizeFirstTest, NoLeadingSpaces) { |
302 std::string token; | 318 std::string token; |
303 std::string rest; | 319 std::string rest; |
304 | 320 |
305 ASSERT_TRUE(tokenize_first("A &*${}", ' ', &token, &rest)); | 321 ASSERT_TRUE(tokenize_first("A &*${}", ' ', &token, &rest)); |
306 ASSERT_STREQ("A", token.c_str()); | 322 ASSERT_STREQ("A", token.c_str()); |
307 ASSERT_STREQ("&*${}", rest.c_str()); | 323 ASSERT_STREQ("&*${}", rest.c_str()); |
308 | 324 |
309 ASSERT_TRUE(tokenize_first("A B& *${}", ' ', &token, &rest)); | 325 ASSERT_TRUE(tokenize_first("A B& *${}", ' ', &token, &rest)); |
310 ASSERT_STREQ("A", token.c_str()); | 326 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")); | 437 EXPECT_FALSE(FromString<bool>("false\nfalse")); |
422 } | 438 } |
423 | 439 |
424 TEST(BoolTest, RoundTrip) { | 440 TEST(BoolTest, RoundTrip) { |
425 bool value; | 441 bool value; |
426 EXPECT_TRUE(FromString(ToString(true), &value)); | 442 EXPECT_TRUE(FromString(ToString(true), &value)); |
427 EXPECT_TRUE(value); | 443 EXPECT_TRUE(value); |
428 EXPECT_TRUE(FromString(ToString(false), &value)); | 444 EXPECT_TRUE(FromString(ToString(false), &value)); |
429 EXPECT_FALSE(value); | 445 EXPECT_FALSE(value); |
430 } | 446 } |
| 447 |
431 } // namespace rtc | 448 } // namespace rtc |
OLD | NEW |