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

Unified Diff: third_party/protobuf/src/google/protobuf/proto_cast_test.cc

Issue 1291903002: Pull new version of protobuf sources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix attempts Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/src/google/protobuf/proto_cast_test.cc
diff --git a/third_party/protobuf/src/google/protobuf/generated_message_util.cc b/third_party/protobuf/src/google/protobuf/proto_cast_test.cc
similarity index 67%
copy from third_party/protobuf/src/google/protobuf/generated_message_util.cc
copy to third_party/protobuf/src/google/protobuf/proto_cast_test.cc
index 92882d79ce7ae63cbf1964fc20474a0db6115609..eb101eb633c22114b8a856f7928748cb90646a49 100644
--- a/third_party/protobuf/src/google/protobuf/generated_message_util.cc
+++ b/third_party/protobuf/src/google/protobuf/proto_cast_test.cc
@@ -1,6 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
-// http://code.google.com/p/protobuf/
+// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -28,37 +28,33 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Author: kenton@google.com (Kenton Varda)
-// Based on original Protocol Buffers design by
-// Sanjay Ghemawat, Jeff Dean, and others.
+#include <google/protobuf/util/proto_cast.h>
-#include <google/protobuf/generated_message_util.h>
-
-#include <limits>
+#include <google/protobuf/util/unknown_enum_test.pb.h>
+#include <gtest/gtest.h>
+#include <google/protobuf/testing/gmock.h>
namespace google {
-namespace protobuf {
-namespace internal {
+using google::protobuf::util::UpRevision;
+using google::protobuf::util::DownRevision;
-double Infinity() {
- return std::numeric_limits<double>::infinity();
-}
-double NaN() {
- return std::numeric_limits<double>::quiet_NaN();
-}
+namespace {
-const ::std::string* empty_string_;
-ProtobufOnceType empty_string_once_init_;
+TEST(ProtoCastTest, V2KnownValue) {
+ UpRevision sender;
+ sender.set_value(UpRevision::NONDEFAULT_VALUE);
-void InitEmptyString() {
- empty_string_ = new std::string();
+ DownRevision receiver = proto_cast<DownRevision>(sender);
+ ASSERT_EQ(DownRevision::NONDEFAULT_VALUE, receiver.value());
}
-const ::std::string& GetEmptyString() {
- GoogleOnceInit(&empty_string_once_init_, &InitEmptyString);
- return *empty_string_;
+TEST(ProtoCastTest, V2UnknownValue) {
+ UpRevision sender;
+ sender.set_value(UpRevision::NEW_VALUE);
+
+ DownRevision receiver = proto_cast<DownRevision>(sender);
+ ASSERT_EQ(DownRevision::DEFAULT_VALUE, receiver.value());
}
-} // namespace internal
-} // namespace protobuf
+} // namespace
} // namespace google
« no previous file with comments | « third_party/protobuf/src/google/protobuf/proto_cast.h ('k') | third_party/protobuf/src/google/protobuf/reflection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698