|
|
|
@ -102,6 +102,7 @@ class ProtostreamObjectSourceTest |
|
|
|
|
mock_(), |
|
|
|
|
ow_(&mock_), |
|
|
|
|
use_lower_camel_for_enums_(false), |
|
|
|
|
use_ints_for_enums_(false), |
|
|
|
|
add_trailing_zeros_(false) { |
|
|
|
|
helper_.ResetTypeInfo(Book::descriptor(), Proto3Message::descriptor()); |
|
|
|
|
} |
|
|
|
@ -123,6 +124,7 @@ class ProtostreamObjectSourceTest |
|
|
|
|
google::protobuf::scoped_ptr<ProtoStreamObjectSource> os( |
|
|
|
|
helper_.NewProtoSource(&in_stream, GetTypeUrl(descriptor))); |
|
|
|
|
if (use_lower_camel_for_enums_) os->set_use_lower_camel_for_enums(true); |
|
|
|
|
if (use_ints_for_enums_) os->set_use_ints_for_enums(true); |
|
|
|
|
os->set_max_recursion_depth(64); |
|
|
|
|
return os->WriteTo(&mock_); |
|
|
|
|
} |
|
|
|
@ -270,6 +272,8 @@ class ProtostreamObjectSourceTest |
|
|
|
|
|
|
|
|
|
void UseLowerCamelForEnums() { use_lower_camel_for_enums_ = true; } |
|
|
|
|
|
|
|
|
|
void UseIntsForEnums() { use_ints_for_enums_ = true; } |
|
|
|
|
|
|
|
|
|
void AddTrailingZeros() { add_trailing_zeros_ = true; } |
|
|
|
|
|
|
|
|
|
testing::TypeInfoTestHelper helper_; |
|
|
|
@ -277,6 +281,7 @@ class ProtostreamObjectSourceTest |
|
|
|
|
::testing::NiceMock<MockObjectWriter> mock_; |
|
|
|
|
ExpectingObjectWriter ow_; |
|
|
|
|
bool use_lower_camel_for_enums_; |
|
|
|
|
bool use_ints_for_enums_; |
|
|
|
|
bool add_trailing_zeros_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -498,6 +503,18 @@ TEST_P(ProtostreamObjectSourceTest, EnumCaseIsUnchangedByDefault) { |
|
|
|
|
DoTest(book, Book::descriptor()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(ProtostreamObjectSourceTest, UseIntsForEnumsTest) { |
|
|
|
|
Book book; |
|
|
|
|
book.set_type(Book::ACTION_AND_ADVENTURE); |
|
|
|
|
|
|
|
|
|
UseIntsForEnums(); |
|
|
|
|
|
|
|
|
|
ow_.StartObject("") |
|
|
|
|
->RenderInt32("type", 3) |
|
|
|
|
->EndObject(); |
|
|
|
|
DoTest(book, Book::descriptor()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_P(ProtostreamObjectSourceTest, UnknownEnum) { |
|
|
|
|
Proto3Message message; |
|
|
|
|
message.set_enum_value(static_cast<Proto3Message::NestedEnum>(1234)); |
|
|
|
|