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

Side by Side Diff: third_party/protobuf/src/google/protobuf/io/tokenizer_unittest.cc

Issue 1983203003: Update third_party/protobuf to protobuf-v3.0.0-beta-3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile error Created 4 years, 7 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
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 EXPECT_EQ(0xabcdef12u, ParseInteger("0xabcdef12")); 729 EXPECT_EQ(0xabcdef12u, ParseInteger("0xabcdef12"));
730 EXPECT_EQ(0xabcdef12u, ParseInteger("0xABCDEF12")); 730 EXPECT_EQ(0xabcdef12u, ParseInteger("0xABCDEF12"));
731 EXPECT_EQ(kuint64max, ParseInteger("0xFFFFFFFFFFFFFFFF")); 731 EXPECT_EQ(kuint64max, ParseInteger("0xFFFFFFFFFFFFFFFF"));
732 EXPECT_EQ(01234567, ParseInteger("01234567")); 732 EXPECT_EQ(01234567, ParseInteger("01234567"));
733 EXPECT_EQ(0X123, ParseInteger("0X123")); 733 EXPECT_EQ(0X123, ParseInteger("0X123"));
734 734
735 // Test invalid integers that may still be tokenized as integers. 735 // Test invalid integers that may still be tokenized as integers.
736 EXPECT_EQ(0, ParseInteger("0x")); 736 EXPECT_EQ(0, ParseInteger("0x"));
737 737
738 uint64 i; 738 uint64 i;
739 #ifdef PROTOBUF_HAS_DEATH_TEST // death tests do not work on Windows yet 739
740 // Test invalid integers that will never be tokenized as integers. 740 // Test invalid integers that will never be tokenized as integers.
741 EXPECT_DEBUG_DEATH(Tokenizer::ParseInteger("zxy", kuint64max, &i), 741 EXPECT_FALSE(Tokenizer::ParseInteger("zxy", kuint64max, &i));
742 "passed text that could not have been tokenized as an integer"); 742 EXPECT_FALSE(Tokenizer::ParseInteger("1.2", kuint64max, &i));
743 EXPECT_DEBUG_DEATH(Tokenizer::ParseInteger("1.2", kuint64max, &i), 743 EXPECT_FALSE(Tokenizer::ParseInteger("08", kuint64max, &i));
744 "passed text that could not have been tokenized as an integer"); 744 EXPECT_FALSE(Tokenizer::ParseInteger("0xg", kuint64max, &i));
745 EXPECT_DEBUG_DEATH(Tokenizer::ParseInteger("08", kuint64max, &i), 745 EXPECT_FALSE(Tokenizer::ParseInteger("-1", kuint64max, &i));
746 "passed text that could not have been tokenized as an integer");
747 EXPECT_DEBUG_DEATH(Tokenizer::ParseInteger("0xg", kuint64max, &i),
748 "passed text that could not have been tokenized as an integer");
749 EXPECT_DEBUG_DEATH(Tokenizer::ParseInteger("-1", kuint64max, &i),
750 "passed text that could not have been tokenized as an integer");
751 #endif // PROTOBUF_HAS_DEATH_TEST
752 746
753 // Test overflows. 747 // Test overflows.
754 EXPECT_TRUE (Tokenizer::ParseInteger("0", 0, &i)); 748 EXPECT_TRUE (Tokenizer::ParseInteger("0", 0, &i));
755 EXPECT_FALSE(Tokenizer::ParseInteger("1", 0, &i)); 749 EXPECT_FALSE(Tokenizer::ParseInteger("1", 0, &i));
756 EXPECT_TRUE (Tokenizer::ParseInteger("1", 1, &i)); 750 EXPECT_TRUE (Tokenizer::ParseInteger("1", 1, &i));
757 EXPECT_TRUE (Tokenizer::ParseInteger("12345", 12345, &i)); 751 EXPECT_TRUE (Tokenizer::ParseInteger("12345", 12345, &i));
758 EXPECT_FALSE(Tokenizer::ParseInteger("12346", 12345, &i)); 752 EXPECT_FALSE(Tokenizer::ParseInteger("12346", 12345, &i));
759 EXPECT_TRUE (Tokenizer::ParseInteger("0xFFFFFFFFFFFFFFFF" , kuint64max, &i)); 753 EXPECT_TRUE (Tokenizer::ParseInteger("0xFFFFFFFFFFFFFFFF" , kuint64max, &i));
760 EXPECT_FALSE(Tokenizer::ParseInteger("0x10000000000000000", kuint64max, &i)); 754 EXPECT_FALSE(Tokenizer::ParseInteger("0x10000000000000000", kuint64max, &i));
761 } 755 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 987
994 // Only "foo" should have been read. 988 // Only "foo" should have been read.
995 EXPECT_EQ(strlen("foo"), input.ByteCount()); 989 EXPECT_EQ(strlen("foo"), input.ByteCount());
996 } 990 }
997 991
998 992
999 } // namespace 993 } // namespace
1000 } // namespace io 994 } // namespace io
1001 } // namespace protobuf 995 } // namespace protobuf
1002 } // namespace google 996 } // namespace google
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698