Squashed 'libs/protobuf/' content from commit fcd3b9a85
git-subtree-dir: libs/protobuf git-subtree-split: fcd3b9a85ef36e46643dc30176cea1a7ad62e02b
This commit is contained in:
49
objectivec/Tests/GPBARCUnittestProtos.m
Normal file
49
objectivec/Tests/GPBARCUnittestProtos.m
Normal file
@@ -0,0 +1,49 @@
|
||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||
#error "This file requires ARC support."
|
||||
#endif
|
||||
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Makes sure all the generated headers compile with ARC on.
|
||||
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestCycle.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestDeprecated.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestDeprecatedFile.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestImport.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestImportPublic.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestMset.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjc.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjcOptions.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjcStartup.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestPreserveUnknownEnum.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto3.pbobjc.h"
|
||||
3678
objectivec/Tests/GPBArrayTests.m
Normal file
3678
objectivec/Tests/GPBArrayTests.m
Normal file
File diff suppressed because it is too large
Load Diff
442
objectivec/Tests/GPBCodedInputStreamTests.m
Normal file
442
objectivec/Tests/GPBCodedInputStreamTests.m
Normal file
@@ -0,0 +1,442 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import "GPBCodedInputStream.h"
|
||||
#import "GPBCodedOutputStream.h"
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
#import "GPBUtilities_PackagePrivate.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
|
||||
@interface CodedInputStreamTests : GPBTestCase
|
||||
@end
|
||||
|
||||
@implementation CodedInputStreamTests
|
||||
|
||||
- (NSData*)bytes_with_sentinel:(int32_t)unused, ... {
|
||||
va_list list;
|
||||
va_start(list, unused);
|
||||
|
||||
NSMutableData* values = [NSMutableData dataWithCapacity:0];
|
||||
int32_t i;
|
||||
|
||||
while ((i = va_arg(list, int32_t)) != 256) {
|
||||
NSAssert(i >= 0 && i < 256, @"");
|
||||
uint8_t u = (uint8_t)i;
|
||||
[values appendBytes:&u length:1];
|
||||
}
|
||||
|
||||
va_end(list);
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
#define bytes(...) [self bytes_with_sentinel:0, __VA_ARGS__, 256]
|
||||
|
||||
- (void)testDecodeZigZag {
|
||||
[self assertReadZigZag32:bytes(0x0) value:0];
|
||||
[self assertReadZigZag32:bytes(0x1) value:-1];
|
||||
[self assertReadZigZag32:bytes(0x2) value:1];
|
||||
[self assertReadZigZag32:bytes(0x3) value:-2];
|
||||
|
||||
[self assertReadZigZag32:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0x07) value:(int32_t)0x3FFFFFFF];
|
||||
[self assertReadZigZag32:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x07) value:(int32_t)0xC0000000];
|
||||
[self assertReadZigZag32:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0x0F) value:(int32_t)0x7FFFFFFF];
|
||||
[self assertReadZigZag32:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x0F) value:(int32_t)0x80000000];
|
||||
|
||||
[self assertReadZigZag64:bytes(0x0) value:0];
|
||||
[self assertReadZigZag64:bytes(0x1) value:-1];
|
||||
[self assertReadZigZag64:bytes(0x2) value:1];
|
||||
[self assertReadZigZag64:bytes(0x3) value:-2];
|
||||
|
||||
[self assertReadZigZag64:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0x07) value:(int32_t)0x3FFFFFFF];
|
||||
[self assertReadZigZag64:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x07) value:(int32_t)0xC0000000];
|
||||
[self assertReadZigZag64:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0x0F) value:(int32_t)0x7FFFFFFF];
|
||||
[self assertReadZigZag64:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x0F) value:(int32_t)0x80000000];
|
||||
|
||||
[self assertReadZigZag64:bytes(0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01)
|
||||
value:0x7FFFFFFFFFFFFFFFL];
|
||||
[self assertReadZigZag64:bytes(0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01)
|
||||
value:0x8000000000000000L];
|
||||
}
|
||||
|
||||
- (void)assertReadVarint:(NSData*)data value:(int64_t)value {
|
||||
if (value <= INT32_MAX && value >= INT32_MIN) {
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual((int32_t)value, [input readInt32]);
|
||||
}
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual((int32_t)value, [input readEnum]);
|
||||
}
|
||||
}
|
||||
if (value <= UINT32_MAX && value >= 0) {
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual((uint32_t)value, [input readUInt32]);
|
||||
}
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual(value, [input readInt64]);
|
||||
}
|
||||
if (value >= 0) {
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual((uint64_t)value, [input readUInt64]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)assertReadLittleEndian32:(NSData*)data value:(int32_t)value {
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual(value, [input readSFixed32]);
|
||||
}
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual(GPBConvertInt32ToFloat(value), [input readFloat]);
|
||||
}
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual((uint32_t)value, [input readFixed32]);
|
||||
}
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual(value, [input readSFixed32]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)assertReadLittleEndian64:(NSData*)data value:(int64_t)value {
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual(value, [input readSFixed64]);
|
||||
}
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual(GPBConvertInt64ToDouble(value), [input readDouble]);
|
||||
}
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual((uint64_t)value, [input readFixed64]);
|
||||
}
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual(value, [input readSFixed64]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)assertReadZigZag32:(NSData*)data value:(int64_t)value {
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual((int32_t)value, [input readSInt32]);
|
||||
}
|
||||
|
||||
- (void)assertReadZigZag64:(NSData*)data value:(int64_t)value {
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual(value, [input readSInt64]);
|
||||
}
|
||||
|
||||
- (void)assertReadVarintFailure:(NSData*)data {
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertThrows([input readInt32]);
|
||||
}
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertThrows([input readInt64]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testBytes {
|
||||
NSData* data = bytes(0xa2, 0x74);
|
||||
XCTAssertEqual(data.length, (NSUInteger)2);
|
||||
XCTAssertEqual(((uint8_t*)data.bytes)[0], (uint8_t)0xa2);
|
||||
XCTAssertEqual(((uint8_t*)data.bytes)[1], (uint8_t)0x74);
|
||||
}
|
||||
|
||||
- (void)testReadBool {
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:bytes(0x00)];
|
||||
XCTAssertEqual(NO, [input readBool]);
|
||||
}
|
||||
{
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:bytes(0x01)];
|
||||
XCTAssertEqual(YES, [input readBool]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testReadVarint {
|
||||
[self assertReadVarint:bytes(0x00) value:0];
|
||||
[self assertReadVarint:bytes(0x01) value:1];
|
||||
[self assertReadVarint:bytes(0x7f) value:127];
|
||||
// 14882
|
||||
[self assertReadVarint:bytes(0xa2, 0x74) value:(0x22 << 0) | (0x74 << 7)];
|
||||
// 1904930
|
||||
[self assertReadVarint:bytes(0xa2, 0xa2, 0x74) value:(0x22 << 0) | (0x22 << 7) | (0x74 << 14)];
|
||||
// 243831074
|
||||
[self assertReadVarint:bytes(0xa2, 0xa2, 0xa2, 0x74)
|
||||
value:(0x22 << 0) | (0x22 << 7) | (0x22 << 14) | (0x74 << 21)];
|
||||
// 2961488830
|
||||
[self assertReadVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x0b)
|
||||
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x0bLL << 28)];
|
||||
|
||||
// 64-bit
|
||||
// 7256456126
|
||||
[self assertReadVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x1b)
|
||||
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x1bLL << 28)];
|
||||
// 41256202580718336
|
||||
[self assertReadVarint:bytes(0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49)
|
||||
value:(0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | (0x43LL << 28) |
|
||||
(0x49LL << 35) | (0x24LL << 42) | (0x49LL << 49)];
|
||||
// 11964378330978735131
|
||||
[self assertReadVarint:bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01)
|
||||
value:(0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | (0x3bLL << 28) |
|
||||
(0x56LL << 35) | (0x00LL << 42) | (0x05LL << 49) | (0x26LL << 56) |
|
||||
(0x01ULL << 63)];
|
||||
|
||||
// Failures
|
||||
[self assertReadVarintFailure:bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x00)];
|
||||
[self assertReadVarintFailure:bytes(0x80)];
|
||||
}
|
||||
|
||||
- (void)testReadVarint32FromVarint64 {
|
||||
{
|
||||
// Turn on lower 31 bits of the upper half on a 64 bit varint.
|
||||
NSData* data = bytes(0x80, 0x80, 0x80, 0x80, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E);
|
||||
|
||||
int32_t value32 = 0x0;
|
||||
GPBCodedInputStream* input32 = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual(value32, [input32 readInt32]);
|
||||
|
||||
int64_t value64 = INT64_MAX & 0xFFFFFFFF00000000;
|
||||
GPBCodedInputStream* input64 = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual(value64, [input64 readInt64]);
|
||||
}
|
||||
{
|
||||
// Turn on lower 31 bits and lower 31 bits on upper half on a 64 bit varint.
|
||||
NSData* data = bytes(0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E);
|
||||
|
||||
int32_t value32 = INT32_MAX;
|
||||
GPBCodedInputStream* input32 = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual(value32, [input32 readInt32]);
|
||||
|
||||
int64_t value64 = INT64_MAX & 0xFFFFFFFF7FFFFFFF;
|
||||
GPBCodedInputStream* input64 = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual(value64, [input64 readInt64]);
|
||||
}
|
||||
{
|
||||
// Turn on bits 32 and 64 bit on a 64 bit varint.
|
||||
NSData* data = bytes(0x80, 0x80, 0x80, 0x80, 0x88, 0x80, 0x80, 0x80, 0x80, 0x01);
|
||||
|
||||
int32_t value32 = INT32_MIN;
|
||||
GPBCodedInputStream* input32 = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual(value32, [input32 readInt32]);
|
||||
|
||||
int64_t value64 = INT64_MIN | (0x01LL << 31);
|
||||
GPBCodedInputStream* input64 = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqual(value64, [input64 readInt64]);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testReadLittleEndian {
|
||||
[self assertReadLittleEndian32:bytes(0x78, 0x56, 0x34, 0x12) value:0x12345678];
|
||||
[self assertReadLittleEndian32:bytes(0xf0, 0xde, 0xbc, 0x9a) value:0x9abcdef0];
|
||||
|
||||
[self assertReadLittleEndian64:bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12)
|
||||
value:0x123456789abcdef0LL];
|
||||
[self assertReadLittleEndian64:bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a)
|
||||
value:0x9abcdef012345678LL];
|
||||
}
|
||||
|
||||
- (void)testReadWholeMessage {
|
||||
TestAllTypes* message = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
|
||||
NSData* rawBytes = message.data;
|
||||
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
|
||||
|
||||
TestAllTypes* message2 = [TestAllTypes parseFromData:rawBytes extensionRegistry:nil error:NULL];
|
||||
[self assertAllFieldsSet:message2 repeatedCount:kGPBDefaultRepeatCount];
|
||||
}
|
||||
|
||||
- (void)testSkipWholeMessage {
|
||||
TestAllTypes* message = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
NSData* rawBytes = message.data;
|
||||
|
||||
// Create two parallel inputs. Parse one as unknown fields while using
|
||||
// skipField() to skip each field on the other. Expect the same tags.
|
||||
GPBCodedInputStream* input1 = [GPBCodedInputStream streamWithData:rawBytes];
|
||||
GPBCodedInputStream* input2 = [GPBCodedInputStream streamWithData:rawBytes];
|
||||
GPBUnknownFieldSet* unknownFields = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
|
||||
while (YES) {
|
||||
int32_t tag = [input1 readTag];
|
||||
XCTAssertEqual(tag, [input2 readTag]);
|
||||
if (tag == 0) {
|
||||
break;
|
||||
}
|
||||
[unknownFields mergeFieldFrom:tag input:input1];
|
||||
[input2 skipField:tag];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testReadHugeBlob {
|
||||
// Allocate and initialize a 1MB blob.
|
||||
NSMutableData* blob = [NSMutableData dataWithLength:1 << 20];
|
||||
for (NSUInteger i = 0; i < blob.length; i++) {
|
||||
((uint8_t*)blob.mutableBytes)[i] = (uint8_t)i;
|
||||
}
|
||||
|
||||
// Make a message containing it.
|
||||
TestAllTypes* message = [TestAllTypes message];
|
||||
[self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
|
||||
[message setOptionalBytes:blob];
|
||||
|
||||
// Serialize and parse it. Make sure to parse from an InputStream, not
|
||||
// directly from a ByteString, so that CodedInputStream uses buffered
|
||||
// reading.
|
||||
NSData* messageData = message.data;
|
||||
XCTAssertNotNil(messageData);
|
||||
GPBCodedInputStream* stream = [GPBCodedInputStream streamWithData:messageData];
|
||||
TestAllTypes* message2 = [TestAllTypes parseFromCodedInputStream:stream
|
||||
extensionRegistry:nil
|
||||
error:NULL];
|
||||
|
||||
XCTAssertEqualObjects(message.optionalBytes, message2.optionalBytes);
|
||||
|
||||
// Make sure all the other fields were parsed correctly.
|
||||
TestAllTypes* message3 = [[message2 copy] autorelease];
|
||||
TestAllTypes* types = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
NSData* data = [types optionalBytes];
|
||||
[message3 setOptionalBytes:data];
|
||||
|
||||
[self assertAllFieldsSet:message3 repeatedCount:kGPBDefaultRepeatCount];
|
||||
}
|
||||
|
||||
- (void)testReadMaliciouslyLargeBlob {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
|
||||
int32_t tag = GPBWireFormatMakeTag(1, GPBWireFormatLengthDelimited);
|
||||
[output writeRawVarint32:tag];
|
||||
[output writeRawVarint32:0x7FFFFFFF];
|
||||
uint8_t bytes[32] = {0};
|
||||
[output writeRawData:[NSData dataWithBytes:bytes length:32]];
|
||||
[output flush];
|
||||
|
||||
NSData* data = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
GPBCodedInputStream* input =
|
||||
[GPBCodedInputStream streamWithData:[NSMutableData dataWithData:data]];
|
||||
XCTAssertEqual(tag, [input readTag]);
|
||||
|
||||
XCTAssertThrows([input readBytes]);
|
||||
}
|
||||
|
||||
- (void)testReadEmptyString {
|
||||
NSData* data = bytes(0x00);
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqualObjects(@"", [input readString]);
|
||||
}
|
||||
|
||||
- (void)testInvalidGroupEndTagThrows {
|
||||
NSData* data = bytes(0x0B, 0x1A, 0x02, 0x4B, 0x50, 0x14);
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertThrowsSpecificNamed([input skipMessage], NSException, GPBCodedInputStreamException,
|
||||
@"should throw a GPBCodedInputStreamException exception ");
|
||||
}
|
||||
|
||||
- (void)testBytesWithNegativeSize {
|
||||
NSData* data = bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x0F);
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertNil([input readBytes]);
|
||||
}
|
||||
|
||||
// Verifies fix for b/10315336.
|
||||
// Note: Now that there isn't a custom string class under the hood, this test
|
||||
// isn't as critical, but it does cover bad input and if a custom class is added
|
||||
// again, it will help validate that class' handing of bad utf8.
|
||||
- (void)testReadMalformedString {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
|
||||
int32_t tag =
|
||||
GPBWireFormatMakeTag(TestAllTypes_FieldNumber_DefaultString, GPBWireFormatLengthDelimited);
|
||||
[output writeRawVarint32:tag];
|
||||
[output writeRawVarint32:5];
|
||||
// Create an invalid utf-8 byte array.
|
||||
uint8_t bytes[] = {0xc2, 0xf2, 0x0, 0x0, 0x0};
|
||||
[output writeRawData:[NSData dataWithBytes:bytes length:sizeof(bytes)]];
|
||||
[output flush];
|
||||
|
||||
NSData* data = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
NSError* error = nil;
|
||||
TestAllTypes* message = [TestAllTypes parseFromCodedInputStream:input
|
||||
extensionRegistry:nil
|
||||
error:&error];
|
||||
XCTAssertNotNil(error);
|
||||
XCTAssertNil(message);
|
||||
}
|
||||
|
||||
- (void)testBOMWithinStrings {
|
||||
// We've seen servers that end up with BOMs within strings (not always at the
|
||||
// start, and sometimes in multiple places), make sure they always parse
|
||||
// correctly. (Again, this is inpart in case a custom string class is ever
|
||||
// used again.)
|
||||
const char* strs[] = {
|
||||
"\xEF\xBB\xBF String with BOM",
|
||||
"String with \xEF\xBB\xBF in middle",
|
||||
"String with end bom \xEF\xBB\xBF",
|
||||
"\xEF\xBB\xBF\xe2\x99\xa1", // BOM White Heart
|
||||
"\xEF\xBB\xBF\xEF\xBB\xBF String with Two BOM",
|
||||
};
|
||||
for (size_t i = 0; i < GPBARRAYSIZE(strs); ++i) {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
|
||||
int32_t tag =
|
||||
GPBWireFormatMakeTag(TestAllTypes_FieldNumber_DefaultString, GPBWireFormatLengthDelimited);
|
||||
[output writeRawVarint32:tag];
|
||||
size_t length = strlen(strs[i]);
|
||||
[output writeRawVarint32:(int32_t)length];
|
||||
[output writeRawData:[NSData dataWithBytes:strs[i] length:length]];
|
||||
[output flush];
|
||||
|
||||
NSData* data = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
TestAllTypes* message = [TestAllTypes parseFromCodedInputStream:input
|
||||
extensionRegistry:nil
|
||||
error:NULL];
|
||||
XCTAssertNotNil(message, @"Loop %zd", i);
|
||||
// Ensure the string is there. NSString can consume the BOM in some
|
||||
// cases, so don't actually check the string for exact equality.
|
||||
XCTAssertTrue(message.defaultString.length > 0, @"Loop %zd", i);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
399
objectivec/Tests/GPBCodedOutputStreamTests.m
Normal file
399
objectivec/Tests/GPBCodedOutputStreamTests.m
Normal file
@@ -0,0 +1,399 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import "GPBCodedInputStream.h"
|
||||
#import "GPBCodedOutputStream_PackagePrivate.h"
|
||||
#import "GPBUtilities_PackagePrivate.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
|
||||
@interface GPBCodedOutputStream (InternalMethods)
|
||||
// Declared in the .m file, expose for testing.
|
||||
- (instancetype)initWithOutputStream:(NSOutputStream*)output data:(NSMutableData*)data;
|
||||
@end
|
||||
|
||||
@interface GPBCodedOutputStream (Helper)
|
||||
+ (instancetype)streamWithOutputStream:(NSOutputStream*)output bufferSize:(size_t)bufferSize;
|
||||
@end
|
||||
|
||||
@implementation GPBCodedOutputStream (Helper)
|
||||
+ (instancetype)streamWithOutputStream:(NSOutputStream*)output bufferSize:(size_t)bufferSize {
|
||||
NSMutableData* data = [NSMutableData dataWithLength:bufferSize];
|
||||
return [[[self alloc] initWithOutputStream:output data:data] autorelease];
|
||||
}
|
||||
@end
|
||||
|
||||
@interface CodedOutputStreamTests : GPBTestCase
|
||||
@end
|
||||
|
||||
@implementation CodedOutputStreamTests
|
||||
|
||||
- (NSData*)bytes_with_sentinel:(int32_t)unused, ... {
|
||||
va_list list;
|
||||
va_start(list, unused);
|
||||
|
||||
NSMutableData* values = [NSMutableData dataWithCapacity:0];
|
||||
int32_t i;
|
||||
|
||||
while ((i = va_arg(list, int32_t)) != 256) {
|
||||
NSAssert(i >= 0 && i < 256, @"");
|
||||
uint8_t u = (uint8_t)i;
|
||||
[values appendBytes:&u length:1];
|
||||
}
|
||||
|
||||
va_end(list);
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
#define bytes(...) [self bytes_with_sentinel:0, __VA_ARGS__, 256]
|
||||
|
||||
- (void)assertWriteLittleEndian32:(NSData*)data value:(int32_t)value {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
[output writeRawLittleEndian32:(int32_t)value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
|
||||
// Try different block sizes.
|
||||
for (int blockSize = 1; blockSize <= 16; blockSize *= 2) {
|
||||
rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
output = [GPBCodedOutputStream streamWithOutputStream:rawOutput bufferSize:blockSize];
|
||||
[output writeRawLittleEndian32:(int32_t)value];
|
||||
[output flush];
|
||||
|
||||
actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)assertWriteLittleEndian64:(NSData*)data value:(int64_t)value {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
[output writeRawLittleEndian64:value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
|
||||
// Try different block sizes.
|
||||
for (int blockSize = 1; blockSize <= 16; blockSize *= 2) {
|
||||
rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
output = [GPBCodedOutputStream streamWithOutputStream:rawOutput bufferSize:blockSize];
|
||||
[output writeRawLittleEndian64:value];
|
||||
[output flush];
|
||||
|
||||
actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)assertWriteVarint:(NSData*)data value:(int64_t)value {
|
||||
// Only do 32-bit write if the value fits in 32 bits.
|
||||
if (GPBLogicalRightShift64(value, 32) == 0) {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
[output writeRawVarint32:(int32_t)value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
|
||||
// Also try computing size.
|
||||
XCTAssertEqual(GPBComputeRawVarint32Size((int32_t)value), (size_t)data.length);
|
||||
}
|
||||
|
||||
{
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
[output writeRawVarint64:value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
|
||||
// Also try computing size.
|
||||
XCTAssertEqual(GPBComputeRawVarint64Size(value), (size_t)data.length);
|
||||
}
|
||||
|
||||
// Try different block sizes.
|
||||
for (int blockSize = 1; blockSize <= 16; blockSize *= 2) {
|
||||
// Only do 32-bit write if the value fits in 32 bits.
|
||||
if (GPBLogicalRightShift64(value, 32) == 0) {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput
|
||||
bufferSize:blockSize];
|
||||
|
||||
[output writeRawVarint32:(int32_t)value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
}
|
||||
|
||||
{
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput
|
||||
bufferSize:blockSize];
|
||||
|
||||
[output writeRawVarint64:value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)assertWriteStringNoTag:(NSData*)data
|
||||
value:(NSString*)value
|
||||
context:(NSString*)contextMessage {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
[output writeStringNoTag:value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual, @"%@", contextMessage);
|
||||
|
||||
// Try different block sizes.
|
||||
for (int blockSize = 1; blockSize <= 16; blockSize *= 2) {
|
||||
rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
output = [GPBCodedOutputStream streamWithOutputStream:rawOutput bufferSize:blockSize];
|
||||
[output writeStringNoTag:value];
|
||||
[output flush];
|
||||
|
||||
actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual, @"%@", contextMessage);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testWriteVarint1 {
|
||||
[self assertWriteVarint:bytes(0x00) value:0];
|
||||
}
|
||||
|
||||
- (void)testWriteVarint2 {
|
||||
[self assertWriteVarint:bytes(0x01) value:1];
|
||||
}
|
||||
|
||||
- (void)testWriteVarint3 {
|
||||
[self assertWriteVarint:bytes(0x7f) value:127];
|
||||
}
|
||||
|
||||
- (void)testWriteVarint4 {
|
||||
// 14882
|
||||
[self assertWriteVarint:bytes(0xa2, 0x74) value:(0x22 << 0) | (0x74 << 7)];
|
||||
}
|
||||
|
||||
- (void)testWriteVarint5 {
|
||||
// The sign/nosign distinction is done here because normally varints are
|
||||
// around 64bit values, but for some cases a 32bit value is forced with
|
||||
// with the sign bit (tags, uint32, etc.)
|
||||
|
||||
// 1887747006 (no sign bit)
|
||||
[self assertWriteVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x07)
|
||||
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x07LL << 28)];
|
||||
// 2961488830 (sign bit)
|
||||
[self assertWriteVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x0b)
|
||||
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x0bLL << 28)];
|
||||
}
|
||||
|
||||
- (void)testWriteVarint6 {
|
||||
// 64-bit
|
||||
// 7256456126
|
||||
[self assertWriteVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x1b)
|
||||
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x1bLL << 28)];
|
||||
}
|
||||
|
||||
- (void)testWriteVarint7 {
|
||||
// 41256202580718336
|
||||
[self assertWriteVarint:bytes(0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49)
|
||||
value:(0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) | (0x43LL << 28) |
|
||||
(0x49LL << 35) | (0x24LL << 42) | (0x49LL << 49)];
|
||||
}
|
||||
|
||||
- (void)testWriteVarint8 {
|
||||
// 11964378330978735131
|
||||
[self assertWriteVarint:bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01)
|
||||
value:(0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) | (0x3bLL << 28) |
|
||||
(0x56LL << 35) | (0x00LL << 42) | (0x05LL << 49) | (0x26LL << 56) |
|
||||
(0x01ULL << 63)];
|
||||
}
|
||||
|
||||
- (void)testWriteLittleEndian {
|
||||
[self assertWriteLittleEndian32:bytes(0x78, 0x56, 0x34, 0x12) value:0x12345678];
|
||||
[self assertWriteLittleEndian32:bytes(0xf0, 0xde, 0xbc, 0x9a) value:0x9abcdef0];
|
||||
|
||||
[self assertWriteLittleEndian64:bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12)
|
||||
value:0x123456789abcdef0LL];
|
||||
[self assertWriteLittleEndian64:bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a)
|
||||
value:0x9abcdef012345678LL];
|
||||
}
|
||||
|
||||
- (void)testEncodeZigZag {
|
||||
XCTAssertEqual(0U, GPBEncodeZigZag32(0));
|
||||
XCTAssertEqual(1U, GPBEncodeZigZag32(-1));
|
||||
XCTAssertEqual(2U, GPBEncodeZigZag32(1));
|
||||
XCTAssertEqual(3U, GPBEncodeZigZag32(-2));
|
||||
XCTAssertEqual(0x7FFFFFFEU, GPBEncodeZigZag32(0x3FFFFFFF));
|
||||
XCTAssertEqual(0x7FFFFFFFU, GPBEncodeZigZag32(0xC0000000));
|
||||
XCTAssertEqual(0xFFFFFFFEU, GPBEncodeZigZag32(0x7FFFFFFF));
|
||||
XCTAssertEqual(0xFFFFFFFFU, GPBEncodeZigZag32(0x80000000));
|
||||
|
||||
XCTAssertEqual(0ULL, GPBEncodeZigZag64(0));
|
||||
XCTAssertEqual(1ULL, GPBEncodeZigZag64(-1));
|
||||
XCTAssertEqual(2ULL, GPBEncodeZigZag64(1));
|
||||
XCTAssertEqual(3ULL, GPBEncodeZigZag64(-2));
|
||||
XCTAssertEqual(0x000000007FFFFFFEULL, GPBEncodeZigZag64(0x000000003FFFFFFFLL));
|
||||
XCTAssertEqual(0x000000007FFFFFFFULL, GPBEncodeZigZag64(0xFFFFFFFFC0000000LL));
|
||||
XCTAssertEqual(0x00000000FFFFFFFEULL, GPBEncodeZigZag64(0x000000007FFFFFFFLL));
|
||||
XCTAssertEqual(0x00000000FFFFFFFFULL, GPBEncodeZigZag64(0xFFFFFFFF80000000LL));
|
||||
XCTAssertEqual(0xFFFFFFFFFFFFFFFEULL, GPBEncodeZigZag64(0x7FFFFFFFFFFFFFFFLL));
|
||||
XCTAssertEqual(0xFFFFFFFFFFFFFFFFULL, GPBEncodeZigZag64(0x8000000000000000LL));
|
||||
|
||||
// Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1)
|
||||
// were chosen semi-randomly via keyboard bashing.
|
||||
XCTAssertEqual(0U, GPBEncodeZigZag32(GPBDecodeZigZag32(0)));
|
||||
XCTAssertEqual(1U, GPBEncodeZigZag32(GPBDecodeZigZag32(1)));
|
||||
XCTAssertEqual(-1U, GPBEncodeZigZag32(GPBDecodeZigZag32(-1)));
|
||||
XCTAssertEqual(14927U, GPBEncodeZigZag32(GPBDecodeZigZag32(14927)));
|
||||
XCTAssertEqual(-3612U, GPBEncodeZigZag32(GPBDecodeZigZag32(-3612)));
|
||||
|
||||
XCTAssertEqual(0ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(0)));
|
||||
XCTAssertEqual(1ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(1)));
|
||||
XCTAssertEqual(-1ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(-1)));
|
||||
XCTAssertEqual(14927ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(14927)));
|
||||
XCTAssertEqual(-3612ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(-3612)));
|
||||
|
||||
XCTAssertEqual(856912304801416ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(856912304801416LL)));
|
||||
XCTAssertEqual(-75123905439571256ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(-75123905439571256LL)));
|
||||
}
|
||||
|
||||
- (void)testWriteWholeMessage {
|
||||
// Not kGPBDefaultRepeatCount because we are comparing to a golden master file
|
||||
// that was generated with 2.
|
||||
TestAllTypes* message = [self allSetRepeatedCount:2];
|
||||
|
||||
NSData* rawBytes = message.data;
|
||||
NSData* goldenData = [self getDataFileNamed:@"golden_message" dataToWrite:rawBytes];
|
||||
XCTAssertEqualObjects(rawBytes, goldenData);
|
||||
|
||||
// Try different block sizes.
|
||||
for (int blockSize = 1; blockSize < 256; blockSize *= 2) {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput
|
||||
bufferSize:blockSize];
|
||||
[message writeToCodedOutputStream:output];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(rawBytes, actual);
|
||||
}
|
||||
|
||||
// Not kGPBDefaultRepeatCount because we are comparing to a golden master file
|
||||
// that was generated with 2.
|
||||
TestAllExtensions* extensions = [self allExtensionsSetRepeatedCount:2];
|
||||
rawBytes = extensions.data;
|
||||
goldenData = [self getDataFileNamed:@"golden_packed_fields_message" dataToWrite:rawBytes];
|
||||
XCTAssertEqualObjects(rawBytes, goldenData);
|
||||
}
|
||||
|
||||
- (void)testCFStringGetCStringPtrAndStringsWithNullChars {
|
||||
// This test exists to verify that CFStrings with embedded NULLs still expose
|
||||
// their raw buffer if they are backed by UTF8 storage. If this fails, the
|
||||
// quick/direct access paths in GPBCodedOutputStream that depend on
|
||||
// CFStringGetCStringPtr need to be re-evalutated (maybe just removed).
|
||||
// And yes, we do get NULLs in strings from some servers.
|
||||
|
||||
char zeroTest[] = "\0Test\0String";
|
||||
// Note: there is a \0 at the end of this since it is a c-string.
|
||||
NSString* asNSString = [[NSString alloc] initWithBytes:zeroTest
|
||||
length:sizeof(zeroTest)
|
||||
encoding:NSUTF8StringEncoding];
|
||||
const char* cString = CFStringGetCStringPtr((CFStringRef)asNSString, kCFStringEncodingUTF8);
|
||||
XCTAssertTrue(cString != NULL);
|
||||
// Again, if the above assert fails, then it means NSString no longer exposes
|
||||
// the raw utf8 storage of a string created from utf8 input, so the code using
|
||||
// CFStringGetCStringPtr in GPBCodedOutputStream will still work (it will take
|
||||
// a different code path); but the optimizations for when
|
||||
// CFStringGetCStringPtr does work could possibly go away.
|
||||
|
||||
XCTAssertEqual(sizeof(zeroTest), [asNSString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertTrue(0 == memcmp(cString, zeroTest, sizeof(zeroTest)));
|
||||
[asNSString release];
|
||||
}
|
||||
|
||||
- (void)testWriteStringsWithZeroChar {
|
||||
// Unicode allows `\0` as a character, and NSString is a class cluster, so
|
||||
// there are a few different classes that could end up behind a given string.
|
||||
// Historically, we've seen differences based on constant strings in code and
|
||||
// strings built via the NSString apis. So this round trips them to ensure
|
||||
// they are acting as expected.
|
||||
|
||||
NSArray<NSString*>* strs = @[
|
||||
@"\0at start",
|
||||
@"in\0middle",
|
||||
@"at end\0",
|
||||
];
|
||||
int i = 0;
|
||||
for (NSString* str in strs) {
|
||||
NSData* asUTF8 = [str dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSMutableData* expected = [NSMutableData data];
|
||||
uint8_t lengthByte = (uint8_t)asUTF8.length;
|
||||
[expected appendBytes:&lengthByte length:1];
|
||||
[expected appendData:asUTF8];
|
||||
|
||||
NSString* context = [NSString stringWithFormat:@"Loop %d - Literal", i];
|
||||
[self assertWriteStringNoTag:expected value:str context:context];
|
||||
|
||||
// Force a new string to be built which gets a different class from the
|
||||
// NSString class cluster than the literal did.
|
||||
NSString* str2 = [NSString stringWithFormat:@"%@", str];
|
||||
context = [NSString stringWithFormat:@"Loop %d - Built", i];
|
||||
[self assertWriteStringNoTag:expected value:str2 context:context];
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testThatItThrowsWhenWriteRawPtrFails {
|
||||
NSOutputStream* output = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* codedOutput =
|
||||
[GPBCodedOutputStream streamWithOutputStream:output bufferSize:0]; // Skip buffering.
|
||||
[output close]; // Close the output stream to force failure on write.
|
||||
const char* cString = "raw";
|
||||
XCTAssertThrowsSpecificNamed([codedOutput writeRawPtr:cString offset:0 length:strlen(cString)],
|
||||
NSException, GPBCodedOutputStreamException_WriteFailed);
|
||||
}
|
||||
|
||||
@end
|
||||
38
objectivec/Tests/GPBCompileTest01.m
Normal file
38
objectivec/Tests/GPBCompileTest01.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBArray.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_1 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest02.m
Normal file
38
objectivec/Tests/GPBCompileTest02.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBCodedInputStream.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_2 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest03.m
Normal file
38
objectivec/Tests/GPBCompileTest03.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBCodedOutputStream.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_3 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest04.m
Normal file
38
objectivec/Tests/GPBCompileTest04.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_4 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest05.m
Normal file
38
objectivec/Tests/GPBCompileTest05.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBDictionary.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_5 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest06.m
Normal file
38
objectivec/Tests/GPBCompileTest06.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBExtensionRegistry.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_6 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest07.m
Normal file
38
objectivec/Tests/GPBCompileTest07.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBMessage.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_7 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest08.m
Normal file
38
objectivec/Tests/GPBCompileTest08.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBRootObject.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_8 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest09.m
Normal file
38
objectivec/Tests/GPBCompileTest09.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBUnknownField.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_9 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest10.m
Normal file
38
objectivec/Tests/GPBCompileTest10.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBUnknownFieldSet.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_10 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest11.m
Normal file
38
objectivec/Tests/GPBCompileTest11.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBUtilities.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_11 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest12.m
Normal file
38
objectivec/Tests/GPBCompileTest12.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBWellKnownTypes.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_12 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest13.m
Normal file
38
objectivec/Tests/GPBCompileTest13.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBWireFormat.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_13 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest14.m
Normal file
38
objectivec/Tests/GPBCompileTest14.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBAny.pbobjc.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_14 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest15.m
Normal file
38
objectivec/Tests/GPBCompileTest15.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBApi.pbobjc.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_15 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest16.m
Normal file
38
objectivec/Tests/GPBCompileTest16.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBDuration.pbobjc.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_16 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest17.m
Normal file
38
objectivec/Tests/GPBCompileTest17.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBEmpty.pbobjc.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_17 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest18.m
Normal file
38
objectivec/Tests/GPBCompileTest18.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBFieldMask.pbobjc.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_18 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest19.m
Normal file
38
objectivec/Tests/GPBCompileTest19.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBSourceContext.pbobjc.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_19 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest20.m
Normal file
38
objectivec/Tests/GPBCompileTest20.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBStruct.pbobjc.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_20 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest21.m
Normal file
38
objectivec/Tests/GPBCompileTest21.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBTimestamp.pbobjc.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_21 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest22.m
Normal file
38
objectivec/Tests/GPBCompileTest22.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBType.pbobjc.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_22 = 0;
|
||||
38
objectivec/Tests/GPBCompileTest23.m
Normal file
38
objectivec/Tests/GPBCompileTest23.m
Normal file
@@ -0,0 +1,38 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This is a test including a single public header to ensure things build.
|
||||
// It helps test that imports are complete/ordered correctly.
|
||||
|
||||
#import "GPBWrappers.pbobjc.h"
|
||||
|
||||
// Something in the body of this file so the compiler/linker won't complain
|
||||
// about an empty .o file.
|
||||
__attribute__((visibility("default"))) char dummy_symbol_23 = 0;
|
||||
195
objectivec/Tests/GPBConcurrencyTests.m
Normal file
195
objectivec/Tests/GPBConcurrencyTests.m
Normal file
@@ -0,0 +1,195 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2014 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjc.pbobjc.h"
|
||||
|
||||
static const int kNumThreads = 100;
|
||||
static const int kNumMessages = 100;
|
||||
|
||||
// NOTE: Most of these tests don't "fail" in the sense that the XCTAsserts
|
||||
// trip. Rather, the asserts simply exercise the apis, and if there is
|
||||
// a concurancy issue, the NSAsserts in the runtime code fire and/or the
|
||||
// code just crashes outright.
|
||||
|
||||
@interface ConcurrencyTests : GPBTestCase
|
||||
@end
|
||||
|
||||
@implementation ConcurrencyTests
|
||||
|
||||
- (NSArray *)createThreadsWithSelector:(SEL)selector object:(id)object {
|
||||
NSMutableArray *array = [NSMutableArray array];
|
||||
for (NSUInteger i = 0; i < kNumThreads; i++) {
|
||||
NSThread *thread = [[NSThread alloc] initWithTarget:self selector:selector object:object];
|
||||
[array addObject:thread];
|
||||
[thread release];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
- (NSArray *)createMessagesWithType:(Class)msgType {
|
||||
NSMutableArray *array = [NSMutableArray array];
|
||||
for (NSUInteger i = 0; i < kNumMessages; i++) {
|
||||
[array addObject:[msgType message]];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
- (void)startThreads:(NSArray *)threads {
|
||||
for (NSThread *thread in threads) {
|
||||
[thread start];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)joinThreads:(NSArray *)threads {
|
||||
for (NSThread *thread in threads) {
|
||||
while (![thread isFinished])
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)readForeignMessage:(NSArray *)messages {
|
||||
for (NSUInteger i = 0; i < 10; i++) {
|
||||
for (TestAllTypes *message in messages) {
|
||||
XCTAssertEqual(message.optionalForeignMessage.c, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testConcurrentReadOfUnsetMessageField {
|
||||
NSArray *messages = [self createMessagesWithType:[TestAllTypes class]];
|
||||
NSArray *threads = [self createThreadsWithSelector:@selector(readForeignMessage:)
|
||||
object:messages];
|
||||
[self startThreads:threads];
|
||||
[self joinThreads:threads];
|
||||
for (TestAllTypes *message in messages) {
|
||||
XCTAssertFalse(message.hasOptionalForeignMessage);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)readRepeatedInt32:(NSArray *)messages {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (TestAllTypes *message in messages) {
|
||||
XCTAssertEqual([message.repeatedInt32Array count], (NSUInteger)0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testConcurrentReadOfUnsetRepeatedIntField {
|
||||
NSArray *messages = [self createMessagesWithType:[TestAllTypes class]];
|
||||
NSArray *threads = [self createThreadsWithSelector:@selector(readRepeatedInt32:) object:messages];
|
||||
[self startThreads:threads];
|
||||
[self joinThreads:threads];
|
||||
for (TestAllTypes *message in messages) {
|
||||
XCTAssertEqual([message.repeatedInt32Array count], (NSUInteger)0);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)readRepeatedString:(NSArray *)messages {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (TestAllTypes *message in messages) {
|
||||
XCTAssertEqual([message.repeatedStringArray count], (NSUInteger)0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testConcurrentReadOfUnsetRepeatedStringField {
|
||||
NSArray *messages = [self createMessagesWithType:[TestAllTypes class]];
|
||||
NSArray *threads = [self createThreadsWithSelector:@selector(readRepeatedString:)
|
||||
object:messages];
|
||||
[self startThreads:threads];
|
||||
[self joinThreads:threads];
|
||||
for (TestAllTypes *message in messages) {
|
||||
XCTAssertEqual([message.repeatedStringArray count], (NSUInteger)0);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)readInt32Int32Map:(NSArray *)messages {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (TestRecursiveMessageWithRepeatedField *message in messages) {
|
||||
XCTAssertEqual([message.iToI count], (NSUInteger)0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testConcurrentReadOfUnsetInt32Int32MapField {
|
||||
NSArray *messages = [self createMessagesWithType:[TestRecursiveMessageWithRepeatedField class]];
|
||||
NSArray *threads = [self createThreadsWithSelector:@selector(readInt32Int32Map:) object:messages];
|
||||
[self startThreads:threads];
|
||||
[self joinThreads:threads];
|
||||
for (TestRecursiveMessageWithRepeatedField *message in messages) {
|
||||
XCTAssertEqual([message.iToI count], (NSUInteger)0);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)readStringStringMap:(NSArray *)messages {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (TestRecursiveMessageWithRepeatedField *message in messages) {
|
||||
XCTAssertEqual([message.strToStr count], (NSUInteger)0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testConcurrentReadOfUnsetStringStringMapField {
|
||||
NSArray *messages = [self createMessagesWithType:[TestRecursiveMessageWithRepeatedField class]];
|
||||
NSArray *threads = [self createThreadsWithSelector:@selector(readStringStringMap:)
|
||||
object:messages];
|
||||
[self startThreads:threads];
|
||||
[self joinThreads:threads];
|
||||
for (TestRecursiveMessageWithRepeatedField *message in messages) {
|
||||
XCTAssertEqual([message.strToStr count], (NSUInteger)0);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)readOptionalForeignMessageExtension:(NSArray *)messages {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (TestAllExtensions *message in messages) {
|
||||
ForeignMessage *foreign =
|
||||
[message getExtension:[UnittestRoot optionalForeignMessageExtension]];
|
||||
XCTAssertEqual(foreign.c, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testConcurrentReadOfUnsetExtensionField {
|
||||
NSArray *messages = [self createMessagesWithType:[TestAllExtensions class]];
|
||||
SEL sel = @selector(readOptionalForeignMessageExtension:);
|
||||
NSArray *threads = [self createThreadsWithSelector:sel object:messages];
|
||||
[self startThreads:threads];
|
||||
[self joinThreads:threads];
|
||||
GPBExtensionDescriptor *extension = [UnittestRoot optionalForeignMessageExtension];
|
||||
for (TestAllExtensions *message in messages) {
|
||||
XCTAssertFalse([message hasExtension:extension]);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
443
objectivec/Tests/GPBDescriptorTests.m
Normal file
443
objectivec/Tests/GPBDescriptorTests.m
Normal file
@@ -0,0 +1,443 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#import "GPBDescriptor_PackagePrivate.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjc.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjcOptions.pbobjc.h"
|
||||
|
||||
@interface DescriptorTests : GPBTestCase
|
||||
@end
|
||||
|
||||
@implementation DescriptorTests
|
||||
|
||||
- (void)testDescriptor_containingType {
|
||||
GPBDescriptor *testAllTypesDesc = [TestAllTypes descriptor];
|
||||
GPBDescriptor *nestedMessageDesc = [TestAllTypes_NestedMessage descriptor];
|
||||
XCTAssertNil(testAllTypesDesc.containingType);
|
||||
XCTAssertNotNil(nestedMessageDesc.containingType);
|
||||
XCTAssertEqual(nestedMessageDesc.containingType, testAllTypesDesc); // Ptr comparison
|
||||
}
|
||||
|
||||
- (void)testDescriptor_fullName {
|
||||
GPBDescriptor *testAllTypesDesc = [TestAllTypes descriptor];
|
||||
XCTAssertEqualObjects(testAllTypesDesc.fullName, @"objc.protobuf.tests.TestAllTypes");
|
||||
GPBDescriptor *nestedMessageDesc = [TestAllTypes_NestedMessage descriptor];
|
||||
XCTAssertEqualObjects(nestedMessageDesc.fullName,
|
||||
@"objc.protobuf.tests.TestAllTypes.NestedMessage");
|
||||
|
||||
// Prefixes removed.
|
||||
GPBDescriptor *descDesc = [GPBTESTPrefixedParentMessage descriptor];
|
||||
XCTAssertEqualObjects(descDesc.fullName, @"objc.protobuf.tests.options.PrefixedParentMessage");
|
||||
GPBDescriptor *descExtRngDesc = [GPBTESTPrefixedParentMessage_Child descriptor];
|
||||
XCTAssertEqualObjects(descExtRngDesc.fullName,
|
||||
@"objc.protobuf.tests.options.PrefixedParentMessage.Child");
|
||||
|
||||
// Things that get "_Class" added.
|
||||
GPBDescriptor *pointDesc = [Point_Class descriptor];
|
||||
XCTAssertEqualObjects(pointDesc.fullName, @"objc.protobuf.tests.Point");
|
||||
GPBDescriptor *pointRectDesc = [Point_Rect descriptor];
|
||||
XCTAssertEqualObjects(pointRectDesc.fullName, @"objc.protobuf.tests.Point.Rect");
|
||||
}
|
||||
|
||||
- (void)testFieldDescriptor {
|
||||
GPBDescriptor *descriptor = [TestAllTypes descriptor];
|
||||
|
||||
// Nested Enum
|
||||
GPBFieldDescriptor *fieldDescriptorWithName = [descriptor fieldWithName:@"optionalNestedEnum"];
|
||||
XCTAssertNotNil(fieldDescriptorWithName);
|
||||
GPBFieldDescriptor *fieldDescriptorWithNumber = [descriptor fieldWithNumber:21];
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber);
|
||||
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
|
||||
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name, @"TestAllTypes_NestedEnum");
|
||||
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
|
||||
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
|
||||
|
||||
// Foreign Enum
|
||||
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalForeignEnum"];
|
||||
XCTAssertNotNil(fieldDescriptorWithName);
|
||||
fieldDescriptorWithNumber = [descriptor fieldWithNumber:22];
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber);
|
||||
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
|
||||
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name, @"ForeignEnum");
|
||||
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
|
||||
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
|
||||
|
||||
// Import Enum
|
||||
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalImportEnum"];
|
||||
XCTAssertNotNil(fieldDescriptorWithName);
|
||||
fieldDescriptorWithNumber = [descriptor fieldWithNumber:23];
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber);
|
||||
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
|
||||
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name, @"ImportEnum");
|
||||
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
|
||||
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
|
||||
|
||||
// Nested Message
|
||||
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalNestedMessage"];
|
||||
XCTAssertNotNil(fieldDescriptorWithName);
|
||||
fieldDescriptorWithNumber = [descriptor fieldWithNumber:18];
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber);
|
||||
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
|
||||
XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor);
|
||||
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
|
||||
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeMessage);
|
||||
|
||||
// Foreign Message
|
||||
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalForeignMessage"];
|
||||
XCTAssertNotNil(fieldDescriptorWithName);
|
||||
fieldDescriptorWithNumber = [descriptor fieldWithNumber:19];
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber);
|
||||
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
|
||||
XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor);
|
||||
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
|
||||
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeMessage);
|
||||
|
||||
// Import Message
|
||||
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalImportMessage"];
|
||||
XCTAssertNotNil(fieldDescriptorWithName);
|
||||
fieldDescriptorWithNumber = [descriptor fieldWithNumber:20];
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber);
|
||||
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
|
||||
XCTAssertNil(fieldDescriptorWithNumber.enumDescriptor);
|
||||
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
|
||||
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeMessage);
|
||||
|
||||
// Some failed lookups.
|
||||
XCTAssertNil([descriptor fieldWithName:@"NOT THERE"]);
|
||||
XCTAssertNil([descriptor fieldWithNumber:9876543]);
|
||||
}
|
||||
|
||||
- (void)testEnumDescriptor {
|
||||
GPBEnumDescriptor *descriptor = TestAllTypes_NestedEnum_EnumDescriptor();
|
||||
|
||||
NSString *enumName = [descriptor enumNameForValue:1];
|
||||
XCTAssertNotNil(enumName);
|
||||
int32_t value;
|
||||
XCTAssertTrue([descriptor getValue:&value forEnumName:@"TestAllTypes_NestedEnum_Foo"]);
|
||||
XCTAssertTrue([descriptor getValue:NULL forEnumName:@"TestAllTypes_NestedEnum_Foo"]);
|
||||
XCTAssertEqual(value, TestAllTypes_NestedEnum_Foo);
|
||||
|
||||
enumName = [descriptor enumNameForValue:2];
|
||||
XCTAssertNotNil(enumName);
|
||||
XCTAssertTrue([descriptor getValue:&value forEnumName:@"TestAllTypes_NestedEnum_Bar"]);
|
||||
XCTAssertEqual(value, TestAllTypes_NestedEnum_Bar);
|
||||
|
||||
enumName = [descriptor enumNameForValue:3];
|
||||
XCTAssertNotNil(enumName);
|
||||
XCTAssertTrue([descriptor getValue:&value forEnumName:@"TestAllTypes_NestedEnum_Baz"]);
|
||||
XCTAssertEqual(value, TestAllTypes_NestedEnum_Baz);
|
||||
|
||||
// TextFormat
|
||||
enumName = [descriptor textFormatNameForValue:1];
|
||||
XCTAssertNotNil(enumName);
|
||||
XCTAssertTrue([descriptor getValue:&value forEnumTextFormatName:@"FOO"]);
|
||||
XCTAssertEqual(value, TestAllTypes_NestedEnum_Foo);
|
||||
XCTAssertNil([descriptor textFormatNameForValue:99999]);
|
||||
|
||||
// Bad values
|
||||
enumName = [descriptor enumNameForValue:0];
|
||||
XCTAssertNil(enumName);
|
||||
XCTAssertFalse([descriptor getValue:&value forEnumName:@"Unknown"]);
|
||||
XCTAssertFalse([descriptor getValue:NULL forEnumName:@"Unknown"]);
|
||||
XCTAssertFalse([descriptor getValue:&value forEnumName:@"TestAllTypes_NestedEnum_Unknown"]);
|
||||
XCTAssertFalse([descriptor getValue:NULL forEnumName:@"TestAllTypes_NestedEnum_Unknown"]);
|
||||
XCTAssertFalse([descriptor getValue:NULL forEnumTextFormatName:@"Unknown"]);
|
||||
XCTAssertFalse([descriptor getValue:&value forEnumTextFormatName:@"Unknown"]);
|
||||
}
|
||||
|
||||
- (void)testEnumDescriptorIntrospection {
|
||||
GPBEnumDescriptor *descriptor = TestAllTypes_NestedEnum_EnumDescriptor();
|
||||
|
||||
XCTAssertEqual(descriptor.enumNameCount, 4U);
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:0], @"TestAllTypes_NestedEnum_Foo");
|
||||
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:0], @"FOO");
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:1], @"TestAllTypes_NestedEnum_Bar");
|
||||
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:1], @"BAR");
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:2], @"TestAllTypes_NestedEnum_Baz");
|
||||
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:2], @"BAZ");
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:3], @"TestAllTypes_NestedEnum_Neg");
|
||||
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:3], @"NEG");
|
||||
}
|
||||
|
||||
- (void)testEnumDescriptorIntrospectionWithAlias {
|
||||
GPBEnumDescriptor *descriptor = TestEnumWithDupValue_EnumDescriptor();
|
||||
NSString *enumName;
|
||||
int32_t value;
|
||||
|
||||
XCTAssertEqual(descriptor.enumNameCount, 5U);
|
||||
|
||||
enumName = [descriptor getEnumNameForIndex:0];
|
||||
XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Foo1");
|
||||
XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
|
||||
XCTAssertEqual(value, 1);
|
||||
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:0], @"FOO1");
|
||||
|
||||
enumName = [descriptor getEnumNameForIndex:1];
|
||||
XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Bar1");
|
||||
XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
|
||||
XCTAssertEqual(value, 2);
|
||||
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:1], @"BAR1");
|
||||
|
||||
enumName = [descriptor getEnumNameForIndex:2];
|
||||
XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Baz");
|
||||
XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
|
||||
XCTAssertEqual(value, 3);
|
||||
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:2], @"BAZ");
|
||||
|
||||
enumName = [descriptor getEnumNameForIndex:3];
|
||||
XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Foo2");
|
||||
XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
|
||||
XCTAssertEqual(value, 1);
|
||||
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:3], @"FOO2");
|
||||
|
||||
enumName = [descriptor getEnumNameForIndex:4];
|
||||
XCTAssertEqualObjects(enumName, @"TestEnumWithDupValue_Bar2");
|
||||
XCTAssertTrue([descriptor getValue:&value forEnumName:enumName]);
|
||||
XCTAssertEqual(value, 2);
|
||||
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:4], @"BAR2");
|
||||
}
|
||||
|
||||
- (void)testEnumAliasNameCollisions {
|
||||
GPBEnumDescriptor *descriptor = TestEnumObjCNameCollision_EnumDescriptor();
|
||||
NSString *textFormatName;
|
||||
int32_t value;
|
||||
|
||||
XCTAssertEqual(descriptor.enumNameCount, 5U);
|
||||
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:0], @"TestEnumObjCNameCollision_Foo");
|
||||
textFormatName = [descriptor getEnumTextFormatNameForIndex:0];
|
||||
XCTAssertEqualObjects(textFormatName, @"FOO");
|
||||
XCTAssertTrue([descriptor getValue:&value forEnumTextFormatName:textFormatName]);
|
||||
XCTAssertEqual(value, 1);
|
||||
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:1], @"TestEnumObjCNameCollision_Foo");
|
||||
textFormatName = [descriptor getEnumTextFormatNameForIndex:1];
|
||||
XCTAssertEqualObjects(textFormatName, @"foo");
|
||||
XCTAssertTrue([descriptor getValue:&value forEnumTextFormatName:textFormatName]);
|
||||
XCTAssertEqual(value, 1);
|
||||
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:2], @"TestEnumObjCNameCollision_Bar");
|
||||
textFormatName = [descriptor getEnumTextFormatNameForIndex:2];
|
||||
XCTAssertEqualObjects(textFormatName, @"BAR");
|
||||
XCTAssertTrue([descriptor getValue:&value forEnumTextFormatName:textFormatName]);
|
||||
XCTAssertEqual(value, 2);
|
||||
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:3], @"TestEnumObjCNameCollision_Mumble");
|
||||
textFormatName = [descriptor getEnumTextFormatNameForIndex:3];
|
||||
XCTAssertEqualObjects(textFormatName, @"mumble");
|
||||
XCTAssertTrue([descriptor getValue:&value forEnumTextFormatName:textFormatName]);
|
||||
XCTAssertEqual(value, 2);
|
||||
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:4], @"TestEnumObjCNameCollision_Mumble");
|
||||
textFormatName = [descriptor getEnumTextFormatNameForIndex:4];
|
||||
XCTAssertEqualObjects(textFormatName, @"MUMBLE");
|
||||
XCTAssertTrue([descriptor getValue:&value forEnumTextFormatName:textFormatName]);
|
||||
XCTAssertEqual(value, 2);
|
||||
}
|
||||
|
||||
- (void)testEnumValueValidator {
|
||||
GPBDescriptor *descriptor = [TestAllTypes descriptor];
|
||||
GPBFieldDescriptor *fieldDescriptor = [descriptor fieldWithName:@"optionalNestedEnum"];
|
||||
|
||||
// Valid values
|
||||
XCTAssertTrue([fieldDescriptor isValidEnumValue:1]);
|
||||
XCTAssertTrue([fieldDescriptor isValidEnumValue:2]);
|
||||
XCTAssertTrue([fieldDescriptor isValidEnumValue:3]);
|
||||
XCTAssertTrue([fieldDescriptor isValidEnumValue:-1]);
|
||||
|
||||
// Invalid values
|
||||
XCTAssertFalse([fieldDescriptor isValidEnumValue:4]);
|
||||
XCTAssertFalse([fieldDescriptor isValidEnumValue:0]);
|
||||
XCTAssertFalse([fieldDescriptor isValidEnumValue:-2]);
|
||||
}
|
||||
|
||||
- (void)testOneofDescriptor {
|
||||
GPBDescriptor *descriptor = [TestOneof2 descriptor];
|
||||
|
||||
GPBFieldDescriptor *fooStringField =
|
||||
[descriptor fieldWithNumber:TestOneof2_FieldNumber_FooString];
|
||||
XCTAssertNotNil(fooStringField);
|
||||
GPBFieldDescriptor *barStringField =
|
||||
[descriptor fieldWithNumber:TestOneof2_FieldNumber_BarString];
|
||||
XCTAssertNotNil(barStringField);
|
||||
|
||||
// Check the oneofs to have what is expected but not other onesofs
|
||||
|
||||
GPBOneofDescriptor *oneofFoo = [descriptor oneofWithName:@"foo"];
|
||||
XCTAssertNotNil(oneofFoo);
|
||||
XCTAssertNotNil([oneofFoo fieldWithName:@"fooString"]);
|
||||
XCTAssertNil([oneofFoo fieldWithName:@"barString"]);
|
||||
|
||||
GPBOneofDescriptor *oneofBar = [descriptor oneofWithName:@"bar"];
|
||||
XCTAssertNotNil(oneofBar);
|
||||
XCTAssertNil([oneofBar fieldWithName:@"fooString"]);
|
||||
XCTAssertNotNil([oneofBar fieldWithName:@"barString"]);
|
||||
|
||||
// Pointer comparisons against lookups from message.
|
||||
|
||||
XCTAssertEqual([oneofFoo fieldWithNumber:TestOneof2_FieldNumber_FooString], fooStringField);
|
||||
XCTAssertEqual([oneofFoo fieldWithName:@"fooString"], fooStringField);
|
||||
|
||||
XCTAssertEqual([oneofBar fieldWithNumber:TestOneof2_FieldNumber_BarString], barStringField);
|
||||
XCTAssertEqual([oneofBar fieldWithName:@"barString"], barStringField);
|
||||
|
||||
// Unknown oneof not found.
|
||||
|
||||
XCTAssertNil([descriptor oneofWithName:@"mumble"]);
|
||||
XCTAssertNil([descriptor oneofWithName:@"Foo"]);
|
||||
|
||||
// Unknown oneof item.
|
||||
|
||||
XCTAssertNil([oneofFoo fieldWithName:@"mumble"]);
|
||||
XCTAssertNil([oneofFoo fieldWithNumber:666]);
|
||||
|
||||
// Field exists, but not in this oneof.
|
||||
|
||||
XCTAssertNil([oneofFoo fieldWithName:@"barString"]);
|
||||
XCTAssertNil([oneofFoo fieldWithNumber:TestOneof2_FieldNumber_BarString]);
|
||||
XCTAssertNil([oneofBar fieldWithName:@"fooString"]);
|
||||
XCTAssertNil([oneofBar fieldWithNumber:TestOneof2_FieldNumber_FooString]);
|
||||
|
||||
// Check pointers back to the enclosing oneofs.
|
||||
// (pointer comparisons)
|
||||
XCTAssertEqual(fooStringField.containingOneof, oneofFoo);
|
||||
XCTAssertEqual(barStringField.containingOneof, oneofBar);
|
||||
GPBFieldDescriptor *bazString = [descriptor fieldWithNumber:TestOneof2_FieldNumber_BazString];
|
||||
XCTAssertNotNil(bazString);
|
||||
XCTAssertNil(bazString.containingOneof);
|
||||
}
|
||||
|
||||
- (void)testExtensiondDescriptor {
|
||||
Class msgClass = [TestAllExtensions class];
|
||||
Class packedMsgClass = [TestPackedExtensions class];
|
||||
|
||||
// Int
|
||||
|
||||
GPBExtensionDescriptor *descriptor = [UnittestRoot optionalInt32Extension];
|
||||
XCTAssertNotNil(descriptor);
|
||||
XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
|
||||
XCTAssertFalse(descriptor.isPackable);
|
||||
XCTAssertEqualObjects(descriptor.defaultValue, @0);
|
||||
XCTAssertNil(descriptor.enumDescriptor);
|
||||
|
||||
descriptor = [UnittestRoot defaultInt32Extension];
|
||||
XCTAssertNotNil(descriptor);
|
||||
XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
|
||||
XCTAssertFalse(descriptor.isPackable);
|
||||
XCTAssertEqualObjects(descriptor.defaultValue, @41);
|
||||
XCTAssertNil(descriptor.enumDescriptor);
|
||||
|
||||
// Enum
|
||||
|
||||
descriptor = [UnittestRoot optionalNestedEnumExtension];
|
||||
XCTAssertNotNil(descriptor);
|
||||
XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
|
||||
XCTAssertFalse(descriptor.isPackable);
|
||||
XCTAssertEqual(descriptor.defaultValue, @1);
|
||||
XCTAssertEqualObjects(descriptor.enumDescriptor.name, @"TestAllTypes_NestedEnum");
|
||||
|
||||
descriptor = [UnittestRoot defaultNestedEnumExtension];
|
||||
XCTAssertNotNil(descriptor);
|
||||
XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
|
||||
XCTAssertFalse(descriptor.isPackable);
|
||||
XCTAssertEqual(descriptor.defaultValue, @2);
|
||||
XCTAssertEqualObjects(descriptor.enumDescriptor.name, @"TestAllTypes_NestedEnum");
|
||||
|
||||
// Message
|
||||
|
||||
descriptor = [UnittestRoot optionalNestedMessageExtension];
|
||||
XCTAssertNotNil(descriptor);
|
||||
XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
|
||||
XCTAssertFalse(descriptor.isPackable);
|
||||
XCTAssertNil(descriptor.defaultValue);
|
||||
XCTAssertNil(descriptor.enumDescriptor);
|
||||
|
||||
// Repeated Int
|
||||
|
||||
descriptor = [UnittestRoot repeatedInt32Extension];
|
||||
XCTAssertNotNil(descriptor);
|
||||
XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
|
||||
XCTAssertFalse(descriptor.isPackable);
|
||||
XCTAssertNil(descriptor.defaultValue);
|
||||
XCTAssertNil(descriptor.enumDescriptor);
|
||||
|
||||
descriptor = [UnittestRoot packedInt32Extension];
|
||||
XCTAssertNotNil(descriptor);
|
||||
XCTAssertEqual(descriptor.containingMessageClass, packedMsgClass); // ptr equality
|
||||
XCTAssertTrue(descriptor.isPackable);
|
||||
XCTAssertNil(descriptor.defaultValue);
|
||||
XCTAssertNil(descriptor.enumDescriptor);
|
||||
|
||||
// Repeated Enum
|
||||
|
||||
descriptor = [UnittestRoot repeatedNestedEnumExtension];
|
||||
XCTAssertNotNil(descriptor);
|
||||
XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
|
||||
XCTAssertFalse(descriptor.isPackable);
|
||||
XCTAssertNil(descriptor.defaultValue);
|
||||
XCTAssertEqualObjects(descriptor.enumDescriptor.name, @"TestAllTypes_NestedEnum");
|
||||
|
||||
descriptor = [UnittestRoot packedEnumExtension];
|
||||
XCTAssertNotNil(descriptor);
|
||||
XCTAssertEqual(descriptor.containingMessageClass, packedMsgClass); // ptr equality
|
||||
XCTAssertTrue(descriptor.isPackable);
|
||||
XCTAssertNil(descriptor.defaultValue);
|
||||
XCTAssertEqualObjects(descriptor.enumDescriptor.name, @"ForeignEnum");
|
||||
|
||||
// Repeated Message
|
||||
|
||||
descriptor = [UnittestRoot repeatedNestedMessageExtension];
|
||||
XCTAssertNotNil(descriptor);
|
||||
XCTAssertEqual(descriptor.containingMessageClass, msgClass); // ptr equality
|
||||
XCTAssertFalse(descriptor.isPackable);
|
||||
XCTAssertNil(descriptor.defaultValue);
|
||||
XCTAssertNil(descriptor.enumDescriptor);
|
||||
|
||||
// Compare (used internally for serialization).
|
||||
|
||||
GPBExtensionDescriptor *ext1 = [UnittestRoot optionalInt32Extension];
|
||||
XCTAssertEqual(ext1.fieldNumber, 1u);
|
||||
GPBExtensionDescriptor *ext2 = [UnittestRoot optionalInt64Extension];
|
||||
XCTAssertEqual(ext2.fieldNumber, 2u);
|
||||
|
||||
XCTAssertEqual([ext1 compareByFieldNumber:ext2], NSOrderedAscending);
|
||||
XCTAssertEqual([ext2 compareByFieldNumber:ext1], NSOrderedDescending);
|
||||
XCTAssertEqual([ext1 compareByFieldNumber:ext1], NSOrderedSame);
|
||||
}
|
||||
|
||||
@end
|
||||
2437
objectivec/Tests/GPBDictionaryTests+Bool.m
Normal file
2437
objectivec/Tests/GPBDictionaryTests+Bool.m
Normal file
File diff suppressed because it is too large
Load Diff
3660
objectivec/Tests/GPBDictionaryTests+Int32.m
Normal file
3660
objectivec/Tests/GPBDictionaryTests+Int32.m
Normal file
File diff suppressed because it is too large
Load Diff
3660
objectivec/Tests/GPBDictionaryTests+Int64.m
Normal file
3660
objectivec/Tests/GPBDictionaryTests+Int64.m
Normal file
File diff suppressed because it is too large
Load Diff
3369
objectivec/Tests/GPBDictionaryTests+String.m
Normal file
3369
objectivec/Tests/GPBDictionaryTests+String.m
Normal file
File diff suppressed because it is too large
Load Diff
3660
objectivec/Tests/GPBDictionaryTests+UInt32.m
Normal file
3660
objectivec/Tests/GPBDictionaryTests+UInt32.m
Normal file
File diff suppressed because it is too large
Load Diff
3659
objectivec/Tests/GPBDictionaryTests+UInt64.m
Normal file
3659
objectivec/Tests/GPBDictionaryTests+UInt64.m
Normal file
File diff suppressed because it is too large
Load Diff
186
objectivec/Tests/GPBDictionaryTests.m
Normal file
186
objectivec/Tests/GPBDictionaryTests.m
Normal file
@@ -0,0 +1,186 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2017 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "GPBDictionary.h"
|
||||
#import "GPBDictionary_PackagePrivate.h"
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#pragma mark - GPBAutocreatedDictionary Tests
|
||||
|
||||
// These are hand written tests to double check some behaviors of the
|
||||
// GPBAutocreatedDictionary. The GPBDictionary+[type]Tests files are generate
|
||||
// tests.
|
||||
|
||||
// NOTE: GPBAutocreatedDictionary is private to the library, users of the
|
||||
// library should never have to directly deal with this class.
|
||||
|
||||
@interface GPBAutocreatedDictionaryTests : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation GPBAutocreatedDictionaryTests
|
||||
|
||||
- (void)testEquality {
|
||||
GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
|
||||
|
||||
XCTAssertTrue([dict isEqual:@{}]);
|
||||
XCTAssertTrue([dict isEqualToDictionary:@{}]);
|
||||
|
||||
XCTAssertFalse([dict isEqual:@{@"foo" : @"bar"}]);
|
||||
XCTAssertFalse([dict isEqualToDictionary:@{@"foo" : @"bar"}]);
|
||||
|
||||
[dict setObject:@"bar" forKey:@"foo"];
|
||||
|
||||
XCTAssertFalse([dict isEqual:@{}]);
|
||||
XCTAssertFalse([dict isEqualToDictionary:@{}]);
|
||||
XCTAssertTrue([dict isEqual:@{@"foo" : @"bar"}]);
|
||||
XCTAssertTrue([dict isEqualToDictionary:@{@"foo" : @"bar"}]);
|
||||
XCTAssertFalse([dict isEqual:@{@"bar" : @"baz"}]);
|
||||
XCTAssertFalse([dict isEqualToDictionary:@{@"bar" : @"baz"}]);
|
||||
|
||||
GPBAutocreatedDictionary *dict2 = [[GPBAutocreatedDictionary alloc] init];
|
||||
|
||||
XCTAssertFalse([dict isEqual:dict2]);
|
||||
XCTAssertFalse([dict isEqualToDictionary:dict2]);
|
||||
|
||||
[dict2 setObject:@"mumble" forKey:@"foo"];
|
||||
XCTAssertFalse([dict isEqual:dict2]);
|
||||
XCTAssertFalse([dict isEqualToDictionary:dict2]);
|
||||
|
||||
[dict2 setObject:@"bar" forKey:@"foo"];
|
||||
XCTAssertTrue([dict isEqual:dict2]);
|
||||
XCTAssertTrue([dict isEqualToDictionary:dict2]);
|
||||
|
||||
[dict2 release];
|
||||
[dict release];
|
||||
}
|
||||
|
||||
- (void)testCopy {
|
||||
{
|
||||
GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
|
||||
|
||||
NSDictionary *cpy = [dict copy];
|
||||
XCTAssertTrue(cpy != dict); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSDictionary class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)0);
|
||||
|
||||
NSDictionary *cpy2 = [dict copy];
|
||||
XCTAssertTrue(cpy2 != dict); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSDictionary class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)0);
|
||||
|
||||
[cpy2 release];
|
||||
[cpy release];
|
||||
[dict release];
|
||||
}
|
||||
|
||||
{
|
||||
GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
|
||||
|
||||
NSMutableDictionary *cpy = [dict mutableCopy];
|
||||
XCTAssertTrue(cpy != dict); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSMutableDictionary class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)0);
|
||||
|
||||
NSMutableDictionary *cpy2 = [dict mutableCopy];
|
||||
XCTAssertTrue(cpy2 != dict); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSMutableDictionary class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)0);
|
||||
|
||||
[cpy2 release];
|
||||
[cpy release];
|
||||
[dict release];
|
||||
}
|
||||
|
||||
{
|
||||
GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
|
||||
dict[@"foo"] = @"bar";
|
||||
dict[@"baz"] = @"mumble";
|
||||
|
||||
NSDictionary *cpy = [dict copy];
|
||||
XCTAssertTrue(cpy != dict); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSDictionary class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)2);
|
||||
XCTAssertEqualObjects(cpy[@"foo"], @"bar");
|
||||
XCTAssertEqualObjects(cpy[@"baz"], @"mumble");
|
||||
|
||||
NSDictionary *cpy2 = [dict copy];
|
||||
XCTAssertTrue(cpy2 != dict); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSDictionary class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)2);
|
||||
XCTAssertEqualObjects(cpy2[@"foo"], @"bar");
|
||||
XCTAssertEqualObjects(cpy2[@"baz"], @"mumble");
|
||||
|
||||
[cpy2 release];
|
||||
[cpy release];
|
||||
[dict release];
|
||||
}
|
||||
|
||||
{
|
||||
GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
|
||||
dict[@"foo"] = @"bar";
|
||||
dict[@"baz"] = @"mumble";
|
||||
|
||||
NSMutableDictionary *cpy = [dict mutableCopy];
|
||||
XCTAssertTrue(cpy != dict); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSMutableDictionary class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)2);
|
||||
XCTAssertEqualObjects(cpy[@"foo"], @"bar");
|
||||
XCTAssertEqualObjects(cpy[@"baz"], @"mumble");
|
||||
|
||||
NSMutableDictionary *cpy2 = [dict mutableCopy];
|
||||
XCTAssertTrue(cpy2 != dict); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSMutableDictionary class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)2);
|
||||
XCTAssertEqualObjects(cpy2[@"foo"], @"bar");
|
||||
XCTAssertEqualObjects(cpy2[@"baz"], @"mumble");
|
||||
|
||||
[cpy2 release];
|
||||
[cpy release];
|
||||
[dict release];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
1043
objectivec/Tests/GPBDictionaryTests.pddm
Normal file
1043
objectivec/Tests/GPBDictionaryTests.pddm
Normal file
File diff suppressed because it is too large
Load Diff
133
objectivec/Tests/GPBExtensionRegistryTest.m
Normal file
133
objectivec/Tests/GPBExtensionRegistryTest.m
Normal file
@@ -0,0 +1,133 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2017 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import "GPBExtensionRegistry.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
|
||||
@interface GPBExtensionRegistryTest : GPBTestCase
|
||||
@end
|
||||
|
||||
@implementation GPBExtensionRegistryTest
|
||||
|
||||
- (void)testBasics {
|
||||
GPBExtensionRegistry *reg = [[[GPBExtensionRegistry alloc] init] autorelease];
|
||||
XCTAssertNotNil(reg);
|
||||
|
||||
XCTAssertNil([reg extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1]);
|
||||
XCTAssertNil([reg extensionForDescriptor:[TestAllTypes descriptor] fieldNumber:1]);
|
||||
|
||||
[reg addExtension:[UnittestRoot optionalInt32Extension]];
|
||||
[reg addExtension:[UnittestRoot packedInt64Extension]];
|
||||
|
||||
XCTAssertTrue([reg extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
|
||||
[UnittestRoot optionalInt32Extension]); // ptr equality
|
||||
XCTAssertNil([reg extensionForDescriptor:[TestAllTypes descriptor] fieldNumber:1]);
|
||||
XCTAssertTrue([reg extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] ==
|
||||
[UnittestRoot packedInt64Extension]); // ptr equality
|
||||
}
|
||||
|
||||
- (void)testCopy {
|
||||
GPBExtensionRegistry *reg1 = [[[GPBExtensionRegistry alloc] init] autorelease];
|
||||
[reg1 addExtension:[UnittestRoot optionalInt32Extension]];
|
||||
|
||||
GPBExtensionRegistry *reg2 = [[reg1 copy] autorelease];
|
||||
XCTAssertNotNil(reg2);
|
||||
|
||||
XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
|
||||
[UnittestRoot optionalInt32Extension]); // ptr equality
|
||||
XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
|
||||
[UnittestRoot optionalInt32Extension]); // ptr equality
|
||||
|
||||
// Message class that had registered extension(s) at the -copy time.
|
||||
|
||||
[reg1 addExtension:[UnittestRoot optionalBoolExtension]];
|
||||
[reg2 addExtension:[UnittestRoot optionalStringExtension]];
|
||||
|
||||
XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13] ==
|
||||
[UnittestRoot optionalBoolExtension]); // ptr equality
|
||||
XCTAssertNil([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14]);
|
||||
XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13]);
|
||||
XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14] ==
|
||||
[UnittestRoot optionalStringExtension]); // ptr equality
|
||||
|
||||
// Message class that did not have any registered extensions at the -copy time.
|
||||
|
||||
[reg1 addExtension:[UnittestRoot packedInt64Extension]];
|
||||
[reg2 addExtension:[UnittestRoot packedSint32Extension]];
|
||||
|
||||
XCTAssertTrue([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] ==
|
||||
[UnittestRoot packedInt64Extension]); // ptr equality
|
||||
XCTAssertNil([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94]);
|
||||
XCTAssertNil([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91]);
|
||||
XCTAssertTrue([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94] ==
|
||||
[UnittestRoot packedSint32Extension]); // ptr equality
|
||||
}
|
||||
|
||||
- (void)testAddExtensions {
|
||||
GPBExtensionRegistry *reg1 = [[[GPBExtensionRegistry alloc] init] autorelease];
|
||||
[reg1 addExtension:[UnittestRoot optionalInt32Extension]];
|
||||
|
||||
GPBExtensionRegistry *reg2 = [[[GPBExtensionRegistry alloc] init] autorelease];
|
||||
|
||||
XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1]);
|
||||
|
||||
[reg2 addExtensions:reg1];
|
||||
|
||||
XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
|
||||
[UnittestRoot optionalInt32Extension]); // ptr equality
|
||||
|
||||
// Confirm adding to the first doesn't add to the second.
|
||||
|
||||
[reg1 addExtension:[UnittestRoot optionalBoolExtension]];
|
||||
[reg1 addExtension:[UnittestRoot packedInt64Extension]];
|
||||
|
||||
XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13] ==
|
||||
[UnittestRoot optionalBoolExtension]); // ptr equality
|
||||
XCTAssertTrue([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] ==
|
||||
[UnittestRoot packedInt64Extension]); // ptr equality
|
||||
XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13]);
|
||||
XCTAssertNil([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91]);
|
||||
|
||||
// Confirm adding to the second doesn't add to the first.
|
||||
|
||||
[reg2 addExtension:[UnittestRoot optionalStringExtension]];
|
||||
[reg2 addExtension:[UnittestRoot packedSint32Extension]];
|
||||
|
||||
XCTAssertNil([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14]);
|
||||
XCTAssertNil([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94]);
|
||||
XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:14] ==
|
||||
[UnittestRoot optionalStringExtension]); // ptr equality
|
||||
XCTAssertTrue([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94] ==
|
||||
[UnittestRoot packedSint32Extension]); // ptr equality
|
||||
}
|
||||
|
||||
@end
|
||||
164
objectivec/Tests/GPBMessageTests+ClassNames.m
Normal file
164
objectivec/Tests/GPBMessageTests+ClassNames.m
Normal file
@@ -0,0 +1,164 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#import "GPBDescriptor_PackagePrivate.h"
|
||||
#import "GPBExtensionRegistry.h"
|
||||
#import "GPBMessage.h"
|
||||
#import "GPBRootObject_PackagePrivate.h"
|
||||
|
||||
// Support classes for tests using old class name (vs classrefs) interfaces.
|
||||
GPB_FINAL @interface MessageLackingClazzRoot : GPBRootObject
|
||||
@end
|
||||
|
||||
@interface MessageLackingClazzRoot (DynamicMethods)
|
||||
+ (GPBExtensionDescriptor *)ext1;
|
||||
@end
|
||||
|
||||
GPB_FINAL @interface MessageLackingClazz : GPBMessage
|
||||
@property(copy, nonatomic) NSString *foo;
|
||||
@end
|
||||
|
||||
@implementation MessageLackingClazz
|
||||
|
||||
@dynamic foo;
|
||||
|
||||
typedef struct MessageLackingClazz_storage_ {
|
||||
uint32_t _has_storage_[1];
|
||||
NSString *foo;
|
||||
} MessageLackingClazz_storage_;
|
||||
|
||||
+ (GPBDescriptor *)descriptor {
|
||||
static GPBDescriptor *descriptor = nil;
|
||||
if (!descriptor) {
|
||||
static GPBMessageFieldDescription fields[] = {
|
||||
{
|
||||
.name = "foo",
|
||||
.dataTypeSpecific.className = "NSString",
|
||||
.number = 1,
|
||||
.hasIndex = 0,
|
||||
.offset = (uint32_t)offsetof(MessageLackingClazz_storage_, foo),
|
||||
.flags = (GPBFieldFlags)(GPBFieldOptional),
|
||||
.dataType = GPBDataTypeMessage,
|
||||
},
|
||||
};
|
||||
GPBFileDescriptor *desc =
|
||||
[[[GPBFileDescriptor alloc] initWithPackage:@"test"
|
||||
objcPrefix:@"TEST"
|
||||
syntax:GPBFileSyntaxProto3] autorelease];
|
||||
|
||||
// GPBDescriptorInitializationFlag_UsesClassRefs intentionally not set here
|
||||
descriptor = [GPBDescriptor
|
||||
allocDescriptorForClass:[MessageLackingClazz class]
|
||||
rootClass:[MessageLackingClazzRoot class]
|
||||
file:desc
|
||||
fields:fields
|
||||
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
|
||||
storageSize:sizeof(MessageLackingClazz_storage_)
|
||||
flags:GPBDescriptorInitializationFlag_None];
|
||||
[descriptor setupContainingMessageClassName:"MessageLackingClazz"];
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation MessageLackingClazzRoot
|
||||
|
||||
+ (GPBExtensionRegistry *)extensionRegistry {
|
||||
// This is called by +initialize so there is no need to worry
|
||||
// about thread safety and initialization of registry.
|
||||
static GPBExtensionRegistry *registry = nil;
|
||||
if (!registry) {
|
||||
registry = [[GPBExtensionRegistry alloc] init];
|
||||
static GPBExtensionDescription descriptions[] = {
|
||||
{
|
||||
.defaultValue.valueMessage = NULL,
|
||||
.singletonName = "MessageLackingClazzRoot_ext1",
|
||||
.extendedClass.name = "MessageLackingClazz",
|
||||
.messageOrGroupClass.name = "MessageLackingClazz",
|
||||
.enumDescriptorFunc = NULL,
|
||||
.fieldNumber = 1,
|
||||
.dataType = GPBDataTypeMessage,
|
||||
// GPBExtensionUsesClazz Intentionally not set
|
||||
.options = 0,
|
||||
},
|
||||
};
|
||||
for (size_t i = 0; i < sizeof(descriptions) / sizeof(descriptions[0]); ++i) {
|
||||
// Intentionall using `-initWithExtensionDescription:` and not `
|
||||
// -initWithExtensionDescription:usesClassRefs:` to test backwards
|
||||
// compatibility
|
||||
GPBExtensionDescriptor *extension =
|
||||
[[GPBExtensionDescriptor alloc] initWithExtensionDescription:&descriptions[i]];
|
||||
[registry addExtension:extension];
|
||||
[self globallyRegisterExtension:extension];
|
||||
[extension release];
|
||||
}
|
||||
// None of the imports (direct or indirect) defined extensions, so no need to add
|
||||
// them to this registry.
|
||||
}
|
||||
return registry;
|
||||
}
|
||||
@end
|
||||
|
||||
@interface MessageClassNameTests : GPBTestCase
|
||||
@end
|
||||
|
||||
@implementation MessageClassNameTests
|
||||
|
||||
- (void)testClassNameSupported {
|
||||
// This tests backwards compatibility to make sure we support older sources
|
||||
// that use class names instead of references.
|
||||
GPBDescriptor *desc = [MessageLackingClazz descriptor];
|
||||
GPBFieldDescriptor *fieldDesc = [desc fieldWithName:@"foo"];
|
||||
XCTAssertEqualObjects(fieldDesc.msgClass, [NSString class]);
|
||||
}
|
||||
|
||||
- (void)testSetupContainingMessageClassNameSupported {
|
||||
// This tests backwards compatibility to make sure we support older sources
|
||||
// that use class names instead of references.
|
||||
GPBDescriptor *desc = [MessageLackingClazz descriptor];
|
||||
GPBDescriptor *container = [desc containingType];
|
||||
XCTAssertEqualObjects(container.messageClass, [MessageLackingClazz class]);
|
||||
}
|
||||
|
||||
- (void)testExtensionsNameSupported {
|
||||
// This tests backwards compatibility to make sure we support older sources
|
||||
// that use class names instead of references.
|
||||
GPBExtensionDescriptor *desc = [MessageLackingClazzRoot ext1];
|
||||
Class containerClass = [desc containingMessageClass];
|
||||
XCTAssertEqualObjects(containerClass, [MessageLackingClazz class]);
|
||||
Class msgClass = [desc msgClass];
|
||||
XCTAssertEqualObjects(msgClass, [MessageLackingClazz class]);
|
||||
}
|
||||
|
||||
@end
|
||||
702
objectivec/Tests/GPBMessageTests+Merge.m
Normal file
702
objectivec/Tests/GPBMessageTests+Merge.m
Normal file
@@ -0,0 +1,702 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#import "GPBMessage.h"
|
||||
|
||||
#import "objectivec/Tests/MapUnittest.pbobjc.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestPreserveUnknownEnum.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto3.pbobjc.h"
|
||||
|
||||
@interface MessageMergeTests : GPBTestCase
|
||||
@end
|
||||
|
||||
@implementation MessageMergeTests
|
||||
|
||||
// TODO(thomasvl): Pull tests over from GPBMessageTests that are merge specific.
|
||||
|
||||
- (void)testProto3MergingAndZeroValues {
|
||||
// Proto2 covered in other tests.
|
||||
|
||||
Message3 *src = [[Message3 alloc] init];
|
||||
Message3 *dst = [[Message3 alloc] init];
|
||||
NSData *testData1 = [@"abc" dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSData *testData2 = [@"def" dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
dst.optionalInt32 = 1;
|
||||
dst.optionalInt64 = 1;
|
||||
dst.optionalUint32 = 1;
|
||||
dst.optionalUint64 = 1;
|
||||
dst.optionalSint32 = 1;
|
||||
dst.optionalSint64 = 1;
|
||||
dst.optionalFixed32 = 1;
|
||||
dst.optionalFixed64 = 1;
|
||||
dst.optionalSfixed32 = 1;
|
||||
dst.optionalSfixed64 = 1;
|
||||
dst.optionalFloat = 1.0f;
|
||||
dst.optionalDouble = 1.0;
|
||||
dst.optionalBool = YES;
|
||||
dst.optionalString = @"bar";
|
||||
dst.optionalBytes = testData1;
|
||||
dst.optionalEnum = Message3_Enum_Bar;
|
||||
|
||||
// All zeros, nothing should overright.
|
||||
|
||||
src.optionalInt32 = 0;
|
||||
src.optionalInt64 = 0;
|
||||
src.optionalUint32 = 0;
|
||||
src.optionalUint64 = 0;
|
||||
src.optionalSint32 = 0;
|
||||
src.optionalSint64 = 0;
|
||||
src.optionalFixed32 = 0;
|
||||
src.optionalFixed64 = 0;
|
||||
src.optionalSfixed32 = 0;
|
||||
src.optionalSfixed64 = 0;
|
||||
src.optionalFloat = 0.0f;
|
||||
src.optionalDouble = 0.0;
|
||||
src.optionalBool = NO;
|
||||
src.optionalString = @"";
|
||||
src.optionalBytes = [NSData data];
|
||||
src.optionalEnum = Message3_Enum_Foo; // first value
|
||||
|
||||
[dst mergeFrom:src];
|
||||
|
||||
XCTAssertEqual(dst.optionalInt32, 1);
|
||||
XCTAssertEqual(dst.optionalInt64, 1);
|
||||
XCTAssertEqual(dst.optionalUint32, 1U);
|
||||
XCTAssertEqual(dst.optionalUint64, 1U);
|
||||
XCTAssertEqual(dst.optionalSint32, 1);
|
||||
XCTAssertEqual(dst.optionalSint64, 1);
|
||||
XCTAssertEqual(dst.optionalFixed32, 1U);
|
||||
XCTAssertEqual(dst.optionalFixed64, 1U);
|
||||
XCTAssertEqual(dst.optionalSfixed32, 1);
|
||||
XCTAssertEqual(dst.optionalSfixed64, 1);
|
||||
XCTAssertEqual(dst.optionalFloat, 1.0f);
|
||||
XCTAssertEqual(dst.optionalDouble, 1.0);
|
||||
XCTAssertEqual(dst.optionalBool, YES);
|
||||
XCTAssertEqualObjects(dst.optionalString, @"bar");
|
||||
XCTAssertEqualObjects(dst.optionalBytes, testData1);
|
||||
XCTAssertEqual(dst.optionalEnum, Message3_Enum_Bar);
|
||||
|
||||
// Half the values that will replace.
|
||||
|
||||
src.optionalInt32 = 0;
|
||||
src.optionalInt64 = 2;
|
||||
src.optionalUint32 = 0;
|
||||
src.optionalUint64 = 2;
|
||||
src.optionalSint32 = 0;
|
||||
src.optionalSint64 = 2;
|
||||
src.optionalFixed32 = 0;
|
||||
src.optionalFixed64 = 2;
|
||||
src.optionalSfixed32 = 0;
|
||||
src.optionalSfixed64 = 2;
|
||||
src.optionalFloat = 0.0f;
|
||||
src.optionalDouble = 2.0;
|
||||
src.optionalBool = YES; // No other value to use. :(
|
||||
src.optionalString = @"baz";
|
||||
src.optionalBytes = nil;
|
||||
src.optionalEnum = Message3_Enum_Baz;
|
||||
|
||||
[dst mergeFrom:src];
|
||||
|
||||
XCTAssertEqual(dst.optionalInt32, 1);
|
||||
XCTAssertEqual(dst.optionalInt64, 2);
|
||||
XCTAssertEqual(dst.optionalUint32, 1U);
|
||||
XCTAssertEqual(dst.optionalUint64, 2U);
|
||||
XCTAssertEqual(dst.optionalSint32, 1);
|
||||
XCTAssertEqual(dst.optionalSint64, 2);
|
||||
XCTAssertEqual(dst.optionalFixed32, 1U);
|
||||
XCTAssertEqual(dst.optionalFixed64, 2U);
|
||||
XCTAssertEqual(dst.optionalSfixed32, 1);
|
||||
XCTAssertEqual(dst.optionalSfixed64, 2);
|
||||
XCTAssertEqual(dst.optionalFloat, 1.0f);
|
||||
XCTAssertEqual(dst.optionalDouble, 2.0);
|
||||
XCTAssertEqual(dst.optionalBool, YES);
|
||||
XCTAssertEqualObjects(dst.optionalString, @"baz");
|
||||
XCTAssertEqualObjects(dst.optionalBytes, testData1);
|
||||
XCTAssertEqual(dst.optionalEnum, Message3_Enum_Baz);
|
||||
|
||||
// Other half the values that will replace.
|
||||
|
||||
src.optionalInt32 = 3;
|
||||
src.optionalInt64 = 0;
|
||||
src.optionalUint32 = 3;
|
||||
src.optionalUint64 = 0;
|
||||
src.optionalSint32 = 3;
|
||||
src.optionalSint64 = 0;
|
||||
src.optionalFixed32 = 3;
|
||||
src.optionalFixed64 = 0;
|
||||
src.optionalSfixed32 = 3;
|
||||
src.optionalSfixed64 = 0;
|
||||
src.optionalFloat = 3.0f;
|
||||
src.optionalDouble = 0.0;
|
||||
src.optionalBool = YES; // No other value to use. :(
|
||||
src.optionalString = nil;
|
||||
src.optionalBytes = testData2;
|
||||
src.optionalEnum = Message3_Enum_Foo;
|
||||
|
||||
[dst mergeFrom:src];
|
||||
|
||||
XCTAssertEqual(dst.optionalInt32, 3);
|
||||
XCTAssertEqual(dst.optionalInt64, 2);
|
||||
XCTAssertEqual(dst.optionalUint32, 3U);
|
||||
XCTAssertEqual(dst.optionalUint64, 2U);
|
||||
XCTAssertEqual(dst.optionalSint32, 3);
|
||||
XCTAssertEqual(dst.optionalSint64, 2);
|
||||
XCTAssertEqual(dst.optionalFixed32, 3U);
|
||||
XCTAssertEqual(dst.optionalFixed64, 2U);
|
||||
XCTAssertEqual(dst.optionalSfixed32, 3);
|
||||
XCTAssertEqual(dst.optionalSfixed64, 2);
|
||||
XCTAssertEqual(dst.optionalFloat, 3.0f);
|
||||
XCTAssertEqual(dst.optionalDouble, 2.0);
|
||||
XCTAssertEqual(dst.optionalBool, YES);
|
||||
XCTAssertEqualObjects(dst.optionalString, @"baz");
|
||||
XCTAssertEqualObjects(dst.optionalBytes, testData2);
|
||||
XCTAssertEqual(dst.optionalEnum, Message3_Enum_Baz);
|
||||
|
||||
[src release];
|
||||
[dst release];
|
||||
}
|
||||
|
||||
- (void)testProto3MergingEnums {
|
||||
UnknownEnumsMyMessage *src = [UnknownEnumsMyMessage message];
|
||||
UnknownEnumsMyMessage *dst = [UnknownEnumsMyMessage message];
|
||||
|
||||
// Known value.
|
||||
|
||||
src.e = UnknownEnumsMyEnum_Bar;
|
||||
src.repeatedEArray = [GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:UnknownEnumsMyEnum_Bar];
|
||||
src.repeatedPackedEArray =
|
||||
[GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:UnknownEnumsMyEnum_Bar];
|
||||
src.oneofE1 = UnknownEnumsMyEnum_Bar;
|
||||
|
||||
[dst mergeFrom:src];
|
||||
|
||||
XCTAssertEqual(dst.e, UnknownEnumsMyEnum_Bar);
|
||||
XCTAssertEqual(dst.repeatedEArray.count, 1U);
|
||||
XCTAssertEqual([dst.repeatedEArray valueAtIndex:0], UnknownEnumsMyEnum_Bar);
|
||||
XCTAssertEqual(dst.repeatedPackedEArray.count, 1U);
|
||||
XCTAssertEqual([dst.repeatedPackedEArray valueAtIndex:0], UnknownEnumsMyEnum_Bar);
|
||||
XCTAssertEqual(dst.oneofE1, UnknownEnumsMyEnum_Bar);
|
||||
|
||||
// Unknown value.
|
||||
|
||||
const int32_t kUnknownValue = 666;
|
||||
|
||||
SetUnknownEnumsMyMessage_E_RawValue(src, kUnknownValue);
|
||||
src.repeatedEArray = [GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:kUnknownValue];
|
||||
src.repeatedPackedEArray =
|
||||
[GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:kUnknownValue];
|
||||
SetUnknownEnumsMyMessage_OneofE1_RawValue(src, kUnknownValue);
|
||||
|
||||
[dst mergeFrom:src];
|
||||
|
||||
XCTAssertEqual(dst.e, UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual(UnknownEnumsMyMessage_E_RawValue(dst), kUnknownValue);
|
||||
XCTAssertEqual(dst.repeatedEArray.count, 2U);
|
||||
XCTAssertEqual([dst.repeatedEArray valueAtIndex:0], UnknownEnumsMyEnum_Bar);
|
||||
XCTAssertEqual([dst.repeatedEArray valueAtIndex:1],
|
||||
UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual([dst.repeatedEArray rawValueAtIndex:1], kUnknownValue);
|
||||
XCTAssertEqual(dst.repeatedPackedEArray.count, 2U);
|
||||
XCTAssertEqual([dst.repeatedPackedEArray valueAtIndex:0], UnknownEnumsMyEnum_Bar);
|
||||
XCTAssertEqual([dst.repeatedPackedEArray valueAtIndex:1],
|
||||
UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual([dst.repeatedPackedEArray rawValueAtIndex:1], kUnknownValue);
|
||||
XCTAssertEqual(dst.oneofE1, UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual(UnknownEnumsMyMessage_OneofE1_RawValue(dst), kUnknownValue);
|
||||
}
|
||||
|
||||
- (void)testProto2MergeOneof {
|
||||
Message2 *src = [Message2 message];
|
||||
Message2 *dst = [Message2 message];
|
||||
|
||||
//
|
||||
// Make sure whatever is in dst gets cleared out be merging in something else.
|
||||
//
|
||||
|
||||
dst.oneofEnum = Message2_Enum_Bar;
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-DEFINE MERGE2_TEST(SET_NAME, SET_VALUE, CLEARED_NAME, CLEARED_DEFAULT)
|
||||
//% src.oneof##SET_NAME = SET_VALUE;
|
||||
//% [dst mergeFrom:src];
|
||||
//% XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_Oneof##SET_NAME);
|
||||
//% XCTAssertEqual(dst.oneof##SET_NAME, SET_VALUE);
|
||||
//% XCTAssertEqual(dst.oneof##CLEARED_NAME, CLEARED_DEFAULT);
|
||||
//%
|
||||
//%PDDM-EXPAND MERGE2_TEST(Int32, 10, Enum, Message2_Enum_Baz)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofInt32 = 10;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofInt32);
|
||||
XCTAssertEqual(dst.oneofInt32, 10);
|
||||
XCTAssertEqual(dst.oneofEnum, Message2_Enum_Baz);
|
||||
|
||||
//%PDDM-EXPAND MERGE2_TEST(Int64, 11, Int32, 100)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofInt64 = 11;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofInt64);
|
||||
XCTAssertEqual(dst.oneofInt64, 11);
|
||||
XCTAssertEqual(dst.oneofInt32, 100);
|
||||
|
||||
//%PDDM-EXPAND MERGE2_TEST(Uint32, 12U, Int64, 101)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofUint32 = 12U;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofUint32);
|
||||
XCTAssertEqual(dst.oneofUint32, 12U);
|
||||
XCTAssertEqual(dst.oneofInt64, 101);
|
||||
|
||||
//%PDDM-EXPAND MERGE2_TEST(Uint64, 13U, Uint32, 102U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofUint64 = 13U;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofUint64);
|
||||
XCTAssertEqual(dst.oneofUint64, 13U);
|
||||
XCTAssertEqual(dst.oneofUint32, 102U);
|
||||
|
||||
//%PDDM-EXPAND MERGE2_TEST(Sint32, 14, Uint64, 103U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofSint32 = 14;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofSint32);
|
||||
XCTAssertEqual(dst.oneofSint32, 14);
|
||||
XCTAssertEqual(dst.oneofUint64, 103U);
|
||||
|
||||
//%PDDM-EXPAND MERGE2_TEST(Sint64, 15, Sint32, 104)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofSint64 = 15;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofSint64);
|
||||
XCTAssertEqual(dst.oneofSint64, 15);
|
||||
XCTAssertEqual(dst.oneofSint32, 104);
|
||||
|
||||
//%PDDM-EXPAND MERGE2_TEST(Fixed32, 16U, Sint64, 105)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofFixed32 = 16U;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofFixed32);
|
||||
XCTAssertEqual(dst.oneofFixed32, 16U);
|
||||
XCTAssertEqual(dst.oneofSint64, 105);
|
||||
|
||||
//%PDDM-EXPAND MERGE2_TEST(Fixed64, 17U, Fixed32, 106U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofFixed64 = 17U;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofFixed64);
|
||||
XCTAssertEqual(dst.oneofFixed64, 17U);
|
||||
XCTAssertEqual(dst.oneofFixed32, 106U);
|
||||
|
||||
//%PDDM-EXPAND MERGE2_TEST(Sfixed32, 18, Fixed64, 107U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofSfixed32 = 18;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofSfixed32);
|
||||
XCTAssertEqual(dst.oneofSfixed32, 18);
|
||||
XCTAssertEqual(dst.oneofFixed64, 107U);
|
||||
|
||||
//%PDDM-EXPAND MERGE2_TEST(Sfixed64, 19, Sfixed32, 108)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofSfixed64 = 19;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofSfixed64);
|
||||
XCTAssertEqual(dst.oneofSfixed64, 19);
|
||||
XCTAssertEqual(dst.oneofSfixed32, 108);
|
||||
|
||||
//%PDDM-EXPAND MERGE2_TEST(Float, 20.0f, Sfixed64, 109)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofFloat = 20.0f;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofFloat);
|
||||
XCTAssertEqual(dst.oneofFloat, 20.0f);
|
||||
XCTAssertEqual(dst.oneofSfixed64, 109);
|
||||
|
||||
//%PDDM-EXPAND MERGE2_TEST(Double, 21.0, Float, 110.0f)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofDouble = 21.0;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofDouble);
|
||||
XCTAssertEqual(dst.oneofDouble, 21.0);
|
||||
XCTAssertEqual(dst.oneofFloat, 110.0f);
|
||||
|
||||
//%PDDM-EXPAND MERGE2_TEST(Bool, NO, Double, 111.0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofBool = NO;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofBool);
|
||||
XCTAssertEqual(dst.oneofBool, NO);
|
||||
XCTAssertEqual(dst.oneofDouble, 111.0);
|
||||
|
||||
//%PDDM-EXPAND MERGE2_TEST(Enum, Message2_Enum_Bar, Bool, YES)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofEnum = Message2_Enum_Bar;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofEnum);
|
||||
XCTAssertEqual(dst.oneofEnum, Message2_Enum_Bar);
|
||||
XCTAssertEqual(dst.oneofBool, YES);
|
||||
|
||||
//%PDDM-EXPAND-END (14 expansions)
|
||||
|
||||
// clang-format on
|
||||
|
||||
NSString *oneofStringDefault = @"string";
|
||||
NSData *oneofBytesDefault = [@"data" dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
src.oneofString = @"foo";
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofString);
|
||||
XCTAssertEqualObjects(dst.oneofString, @"foo");
|
||||
XCTAssertEqual(dst.oneofEnum, Message2_Enum_Baz);
|
||||
|
||||
src.oneofBytes = [@"bar" dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofBytes);
|
||||
XCTAssertEqualObjects(dst.oneofBytes, [@"bar" dataUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertEqualObjects(dst.oneofString, oneofStringDefault);
|
||||
|
||||
Message2_OneofGroup *group = [Message2_OneofGroup message];
|
||||
group.a = 666;
|
||||
src.oneofGroup = group;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofGroup);
|
||||
Message2_OneofGroup *mergedGroup = [[dst.oneofGroup retain] autorelease];
|
||||
XCTAssertNotNil(mergedGroup);
|
||||
XCTAssertNotEqual(mergedGroup, group); // Pointer comparison.
|
||||
XCTAssertEqualObjects(mergedGroup, group);
|
||||
XCTAssertEqualObjects(dst.oneofBytes, oneofBytesDefault);
|
||||
|
||||
Message2 *subMessage = [Message2 message];
|
||||
subMessage.optionalInt32 = 777;
|
||||
src.oneofMessage = subMessage;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofMessage);
|
||||
Message2 *mergedSubMessage = [[dst.oneofMessage retain] autorelease];
|
||||
XCTAssertNotNil(mergedSubMessage);
|
||||
XCTAssertNotEqual(mergedSubMessage, subMessage); // Pointer comparison.
|
||||
XCTAssertEqualObjects(mergedSubMessage, subMessage);
|
||||
XCTAssertNotNil(dst.oneofGroup);
|
||||
XCTAssertNotEqual(dst.oneofGroup, mergedGroup); // Pointer comparison.
|
||||
|
||||
// Back to something else to make sure message clears out ok.
|
||||
|
||||
src.oneofInt32 = 10;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofInt32);
|
||||
XCTAssertNotNil(dst.oneofMessage);
|
||||
XCTAssertNotEqual(dst.oneofMessage,
|
||||
mergedSubMessage); // Pointer comparison.
|
||||
|
||||
//
|
||||
// Test merging in to message/group when they already had something.
|
||||
//
|
||||
|
||||
src.oneofGroup = group;
|
||||
mergedGroup = [Message2_OneofGroup message];
|
||||
mergedGroup.b = 888;
|
||||
dst.oneofGroup = mergedGroup;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofGroup);
|
||||
// Shouldn't have been a new object.
|
||||
XCTAssertEqual(dst.oneofGroup, mergedGroup); // Pointer comparison.
|
||||
XCTAssertEqual(dst.oneofGroup.a, 666); // Pointer comparison.
|
||||
XCTAssertEqual(dst.oneofGroup.b, 888); // Pointer comparison.
|
||||
|
||||
src.oneofMessage = subMessage;
|
||||
mergedSubMessage = [Message2 message];
|
||||
mergedSubMessage.optionalInt64 = 999;
|
||||
dst.oneofMessage = mergedSubMessage;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofMessage);
|
||||
// Shouldn't have been a new object.
|
||||
XCTAssertEqual(dst.oneofMessage, mergedSubMessage); // Pointer comparison.
|
||||
XCTAssertEqual(dst.oneofMessage.optionalInt32, 777); // Pointer comparison.
|
||||
XCTAssertEqual(dst.oneofMessage.optionalInt64, 999); // Pointer comparison.
|
||||
}
|
||||
|
||||
- (void)testProto3MergeOneof {
|
||||
Message3 *src = [Message3 message];
|
||||
Message3 *dst = [Message3 message];
|
||||
|
||||
//
|
||||
// Make sure whatever is in dst gets cleared out be merging in something else.
|
||||
//
|
||||
|
||||
dst.oneofEnum = Message3_Enum_Bar;
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-DEFINE MERGE3_TEST(SET_NAME, SET_VALUE, CLEARED_NAME, CLEARED_DEFAULT)
|
||||
//% src.oneof##SET_NAME = SET_VALUE;
|
||||
//% [dst mergeFrom:src];
|
||||
//% XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_Oneof##SET_NAME);
|
||||
//% XCTAssertEqual(dst.oneof##SET_NAME, SET_VALUE);
|
||||
//% XCTAssertEqual(dst.oneof##CLEARED_NAME, CLEARED_DEFAULT);
|
||||
//%
|
||||
//%PDDM-EXPAND MERGE3_TEST(Int32, 10, Enum, Message3_Enum_Foo)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofInt32 = 10;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofInt32);
|
||||
XCTAssertEqual(dst.oneofInt32, 10);
|
||||
XCTAssertEqual(dst.oneofEnum, Message3_Enum_Foo);
|
||||
|
||||
//%PDDM-EXPAND MERGE3_TEST(Int64, 11, Int32, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofInt64 = 11;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofInt64);
|
||||
XCTAssertEqual(dst.oneofInt64, 11);
|
||||
XCTAssertEqual(dst.oneofInt32, 0);
|
||||
|
||||
//%PDDM-EXPAND MERGE3_TEST(Uint32, 12U, Int64, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofUint32 = 12U;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofUint32);
|
||||
XCTAssertEqual(dst.oneofUint32, 12U);
|
||||
XCTAssertEqual(dst.oneofInt64, 0);
|
||||
|
||||
//%PDDM-EXPAND MERGE3_TEST(Uint64, 13U, Uint32, 0U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofUint64 = 13U;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofUint64);
|
||||
XCTAssertEqual(dst.oneofUint64, 13U);
|
||||
XCTAssertEqual(dst.oneofUint32, 0U);
|
||||
|
||||
//%PDDM-EXPAND MERGE3_TEST(Sint32, 14, Uint64, 0U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofSint32 = 14;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofSint32);
|
||||
XCTAssertEqual(dst.oneofSint32, 14);
|
||||
XCTAssertEqual(dst.oneofUint64, 0U);
|
||||
|
||||
//%PDDM-EXPAND MERGE3_TEST(Sint64, 15, Sint32, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofSint64 = 15;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofSint64);
|
||||
XCTAssertEqual(dst.oneofSint64, 15);
|
||||
XCTAssertEqual(dst.oneofSint32, 0);
|
||||
|
||||
//%PDDM-EXPAND MERGE3_TEST(Fixed32, 16U, Sint64, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofFixed32 = 16U;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofFixed32);
|
||||
XCTAssertEqual(dst.oneofFixed32, 16U);
|
||||
XCTAssertEqual(dst.oneofSint64, 0);
|
||||
|
||||
//%PDDM-EXPAND MERGE3_TEST(Fixed64, 17U, Fixed32, 0U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofFixed64 = 17U;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofFixed64);
|
||||
XCTAssertEqual(dst.oneofFixed64, 17U);
|
||||
XCTAssertEqual(dst.oneofFixed32, 0U);
|
||||
|
||||
//%PDDM-EXPAND MERGE3_TEST(Sfixed32, 18, Fixed64, 0U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofSfixed32 = 18;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofSfixed32);
|
||||
XCTAssertEqual(dst.oneofSfixed32, 18);
|
||||
XCTAssertEqual(dst.oneofFixed64, 0U);
|
||||
|
||||
//%PDDM-EXPAND MERGE3_TEST(Sfixed64, 19, Sfixed32, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofSfixed64 = 19;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofSfixed64);
|
||||
XCTAssertEqual(dst.oneofSfixed64, 19);
|
||||
XCTAssertEqual(dst.oneofSfixed32, 0);
|
||||
|
||||
//%PDDM-EXPAND MERGE3_TEST(Float, 20.0f, Sfixed64, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofFloat = 20.0f;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofFloat);
|
||||
XCTAssertEqual(dst.oneofFloat, 20.0f);
|
||||
XCTAssertEqual(dst.oneofSfixed64, 0);
|
||||
|
||||
//%PDDM-EXPAND MERGE3_TEST(Double, 21.0, Float, 0.0f)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofDouble = 21.0;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofDouble);
|
||||
XCTAssertEqual(dst.oneofDouble, 21.0);
|
||||
XCTAssertEqual(dst.oneofFloat, 0.0f);
|
||||
|
||||
//%PDDM-EXPAND MERGE3_TEST(Bool, YES, Double, 0.0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofBool = YES;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofBool);
|
||||
XCTAssertEqual(dst.oneofBool, YES);
|
||||
XCTAssertEqual(dst.oneofDouble, 0.0);
|
||||
|
||||
//%PDDM-EXPAND MERGE3_TEST(Enum, Message3_Enum_Bar, Bool, NO)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
|
||||
src.oneofEnum = Message3_Enum_Bar;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofEnum);
|
||||
XCTAssertEqual(dst.oneofEnum, Message3_Enum_Bar);
|
||||
XCTAssertEqual(dst.oneofBool, NO);
|
||||
|
||||
//%PDDM-EXPAND-END (14 expansions)
|
||||
|
||||
// clang-format on
|
||||
|
||||
NSString *oneofStringDefault = @"";
|
||||
NSData *oneofBytesDefault = [NSData data];
|
||||
|
||||
src.oneofString = @"foo";
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofString);
|
||||
XCTAssertEqualObjects(dst.oneofString, @"foo");
|
||||
XCTAssertEqual(dst.oneofEnum, Message3_Enum_Foo);
|
||||
|
||||
src.oneofBytes = [@"bar" dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofBytes);
|
||||
XCTAssertEqualObjects(dst.oneofBytes, [@"bar" dataUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertEqualObjects(dst.oneofString, oneofStringDefault);
|
||||
|
||||
Message3 *subMessage = [Message3 message];
|
||||
subMessage.optionalInt32 = 777;
|
||||
src.oneofMessage = subMessage;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofMessage);
|
||||
Message3 *mergedSubMessage = [[dst.oneofMessage retain] autorelease];
|
||||
XCTAssertNotNil(mergedSubMessage);
|
||||
XCTAssertNotEqual(mergedSubMessage, subMessage); // Pointer comparison.
|
||||
XCTAssertEqualObjects(mergedSubMessage, subMessage);
|
||||
XCTAssertEqualObjects(dst.oneofBytes, oneofBytesDefault);
|
||||
|
||||
// Back to something else to make sure message clears out ok.
|
||||
|
||||
src.oneofInt32 = 10;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofInt32);
|
||||
XCTAssertNotNil(dst.oneofMessage);
|
||||
XCTAssertNotEqual(dst.oneofMessage,
|
||||
mergedSubMessage); // Pointer comparison.
|
||||
|
||||
//
|
||||
// Test merging in to message when they already had something.
|
||||
//
|
||||
|
||||
src.oneofMessage = subMessage;
|
||||
mergedSubMessage = [Message3 message];
|
||||
mergedSubMessage.optionalInt64 = 999;
|
||||
dst.oneofMessage = mergedSubMessage;
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofMessage);
|
||||
// Shouldn't have been a new object.
|
||||
XCTAssertEqual(dst.oneofMessage, mergedSubMessage); // Pointer comparison.
|
||||
XCTAssertEqual(dst.oneofMessage.optionalInt32, 777); // Pointer comparison.
|
||||
XCTAssertEqual(dst.oneofMessage.optionalInt64, 999); // Pointer comparison.
|
||||
}
|
||||
|
||||
#pragma mark - Subset from from map_tests.cc
|
||||
|
||||
// TEST(GeneratedMapFieldTest, CopyFromMessageMap)
|
||||
- (void)testMap_CopyFromMessageMap {
|
||||
TestMessageMap *msg1 = [[TestMessageMap alloc] init];
|
||||
TestMessageMap *msg2 = [[TestMessageMap alloc] init];
|
||||
|
||||
TestAllTypes *subMsg = [TestAllTypes message];
|
||||
subMsg.repeatedInt32Array = [GPBInt32Array arrayWithValue:100];
|
||||
[msg1.mapInt32Message setObject:subMsg forKey:0];
|
||||
subMsg = nil;
|
||||
|
||||
subMsg = [TestAllTypes message];
|
||||
subMsg.repeatedInt32Array = [GPBInt32Array arrayWithValue:101];
|
||||
|
||||
[msg2.mapInt32Message setObject:subMsg forKey:0];
|
||||
subMsg = nil;
|
||||
|
||||
[msg1 mergeFrom:msg2];
|
||||
|
||||
// Checks repeated field is overwritten.
|
||||
XCTAssertEqual(msg1.mapInt32Message.count, 1U);
|
||||
subMsg = [msg1.mapInt32Message objectForKey:0];
|
||||
XCTAssertNotNil(subMsg);
|
||||
XCTAssertEqual(subMsg.repeatedInt32Array.count, 1U);
|
||||
XCTAssertEqual([subMsg.repeatedInt32Array valueAtIndex:0], 101);
|
||||
|
||||
[msg2 release];
|
||||
[msg1 release];
|
||||
}
|
||||
|
||||
@end
|
||||
2736
objectivec/Tests/GPBMessageTests+Runtime.m
Normal file
2736
objectivec/Tests/GPBMessageTests+Runtime.m
Normal file
File diff suppressed because it is too large
Load Diff
1512
objectivec/Tests/GPBMessageTests+Serialization.m
Normal file
1512
objectivec/Tests/GPBMessageTests+Serialization.m
Normal file
File diff suppressed because it is too large
Load Diff
2171
objectivec/Tests/GPBMessageTests.m
Normal file
2171
objectivec/Tests/GPBMessageTests.m
Normal file
File diff suppressed because it is too large
Load Diff
66
objectivec/Tests/GPBObjectiveCPlusPlusTest.mm
Normal file
66
objectivec/Tests/GPBObjectiveCPlusPlusTest.mm
Normal file
@@ -0,0 +1,66 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2013 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
//
|
||||
// This is just a compile test (here to make sure things never regress).
|
||||
//
|
||||
// Objective C++ can run into issues with how the NS_ENUM/CF_ENUM declaration
|
||||
// works because of the C++ spec being used for that compilation unit. So
|
||||
// the fact that these imports all work without errors/warning means things
|
||||
// are still good.
|
||||
//
|
||||
// The "well know types" should have cross file enums needing imports.
|
||||
#import "GPBProtocolBuffers.h"
|
||||
// Some of the tests explicitly use cross file enums also.
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestImport.pbobjc.h"
|
||||
|
||||
// Sanity check the conditions of the test within the Xcode project.
|
||||
#if !__cplusplus
|
||||
#error This isn't compiled as Objective C++?
|
||||
#elif __cplusplus >= 201103L
|
||||
// If this trips, it means the Xcode default might have change (or someone
|
||||
// edited the testing project) and it might be time to revisit the GPB_ENUM
|
||||
// define in GPBBootstrap.h.
|
||||
#warning Did the Xcode default for C++ spec change?
|
||||
#endif
|
||||
|
||||
// Dummy XCTest.
|
||||
@interface GPBObjectiveCPlusPlusTests : GPBTestCase
|
||||
@end
|
||||
|
||||
@implementation GPBObjectiveCPlusPlusTests
|
||||
- (void)testCPlusPlus {
|
||||
// Nothing, This was a compile test.
|
||||
XCTAssertTrue(YES);
|
||||
}
|
||||
@end
|
||||
416
objectivec/Tests/GPBPerfTests.m
Normal file
416
objectivec/Tests/GPBPerfTests.m
Normal file
@@ -0,0 +1,416 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2013 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestImport.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjc.pbobjc.h"
|
||||
|
||||
//
|
||||
// This file really just uses the unittests framework as a testbed to
|
||||
// run some simple performance tests. The data can then be used to help
|
||||
// evaluate changes to the runtime.
|
||||
//
|
||||
|
||||
static const uint32_t kRepeatedCount = 100;
|
||||
|
||||
@interface PerfTests : GPBTestCase
|
||||
@end
|
||||
|
||||
@implementation PerfTests
|
||||
|
||||
- (void)setUp {
|
||||
// A convenient place to put a break point if you want to connect instruments.
|
||||
[super setUp];
|
||||
}
|
||||
|
||||
- (void)testMessagePerformance {
|
||||
[self measureBlock:^{
|
||||
for (int i = 0; i < 200; ++i) {
|
||||
TestAllTypes* message = [[TestAllTypes alloc] init];
|
||||
[self setAllFields:message repeatedCount:kRepeatedCount];
|
||||
NSData* rawBytes = [message data];
|
||||
[message release];
|
||||
message = [[TestAllTypes alloc] initWithData:rawBytes error:NULL];
|
||||
[message release];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testMessageSerialParsingPerformance {
|
||||
// This and the next test are meant to monitor that the parsing functionality of protos does not
|
||||
// lock across threads when parsing different instances. The Serial version of the test should run
|
||||
// around ~2 times slower than the Parallel version since it's parsing the protos in the same
|
||||
// thread.
|
||||
TestAllTypes* allTypesMessage = [TestAllTypes message];
|
||||
[self setAllFields:allTypesMessage repeatedCount:2];
|
||||
NSData* allTypesData = allTypesMessage.data;
|
||||
|
||||
[self measureBlock:^{
|
||||
for (int i = 0; i < 500; ++i) {
|
||||
[TestAllTypes parseFromData:allTypesData error:NULL];
|
||||
[TestAllTypes parseFromData:allTypesData error:NULL];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testMessageParallelParsingPerformance {
|
||||
// This and the previous test are meant to monitor that the parsing functionality of protos does
|
||||
// not lock across threads when parsing different instances. The Serial version of the test should
|
||||
// run around ~2 times slower than the Parallel version since it's parsing the protos in the same
|
||||
// thread.
|
||||
TestAllTypes* allTypesMessage = [TestAllTypes message];
|
||||
[self setAllFields:allTypesMessage repeatedCount:2];
|
||||
NSData* allTypesData = allTypesMessage.data;
|
||||
|
||||
dispatch_queue_t concurrentQueue = dispatch_queue_create("perfQueue", DISPATCH_QUEUE_CONCURRENT);
|
||||
|
||||
[self measureBlock:^{
|
||||
for (int i = 0; i < 500; ++i) {
|
||||
dispatch_group_t group = dispatch_group_create();
|
||||
|
||||
dispatch_group_async(group, concurrentQueue, ^{
|
||||
[TestAllTypes parseFromData:allTypesData error:NULL];
|
||||
});
|
||||
|
||||
dispatch_group_async(group, concurrentQueue, ^{
|
||||
[TestAllTypes parseFromData:allTypesData error:NULL];
|
||||
});
|
||||
|
||||
dispatch_group_notify(group, concurrentQueue,
|
||||
^{
|
||||
});
|
||||
|
||||
dispatch_release(group);
|
||||
}
|
||||
}];
|
||||
|
||||
dispatch_release(concurrentQueue);
|
||||
}
|
||||
|
||||
- (void)testMessageSerialExtensionsParsingPerformance {
|
||||
// This and the next test are meant to monitor that the parsing functionality of protos does not
|
||||
// lock across threads when parsing different instances when using extensions. The Serial version
|
||||
// of the test should run around ~2 times slower than the Parallel version since it's parsing the
|
||||
// protos in the same thread.
|
||||
TestAllExtensions* allExtensionsMessage = [TestAllExtensions message];
|
||||
[self setAllExtensions:allExtensionsMessage repeatedCount:2];
|
||||
NSData* allExtensionsData = allExtensionsMessage.data;
|
||||
|
||||
[self measureBlock:^{
|
||||
for (int i = 0; i < 500; ++i) {
|
||||
[TestAllExtensions parseFromData:allExtensionsData
|
||||
extensionRegistry:[self extensionRegistry]
|
||||
error:NULL];
|
||||
[TestAllExtensions parseFromData:allExtensionsData
|
||||
extensionRegistry:[self extensionRegistry]
|
||||
error:NULL];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testMessageParallelExtensionsParsingPerformance {
|
||||
// This and the previous test are meant to monitor that the parsing functionality of protos does
|
||||
// not lock across threads when parsing different instances when using extensions. The Serial
|
||||
// version of the test should run around ~2 times slower than the Parallel version since it's
|
||||
// parsing the protos in the same thread.
|
||||
TestAllExtensions* allExtensionsMessage = [TestAllExtensions message];
|
||||
[self setAllExtensions:allExtensionsMessage repeatedCount:2];
|
||||
NSData* allExtensionsData = allExtensionsMessage.data;
|
||||
|
||||
dispatch_queue_t concurrentQueue = dispatch_queue_create("perfQueue", DISPATCH_QUEUE_CONCURRENT);
|
||||
|
||||
[self measureBlock:^{
|
||||
for (int i = 0; i < 500; ++i) {
|
||||
dispatch_group_t group = dispatch_group_create();
|
||||
|
||||
dispatch_group_async(group, concurrentQueue, ^{
|
||||
[TestAllExtensions parseFromData:allExtensionsData
|
||||
extensionRegistry:[UnittestRoot extensionRegistry]
|
||||
error:NULL];
|
||||
});
|
||||
|
||||
dispatch_group_async(group, concurrentQueue, ^{
|
||||
[TestAllExtensions parseFromData:allExtensionsData
|
||||
extensionRegistry:[UnittestRoot extensionRegistry]
|
||||
error:NULL];
|
||||
});
|
||||
|
||||
dispatch_group_notify(group, concurrentQueue,
|
||||
^{
|
||||
});
|
||||
|
||||
dispatch_release(group);
|
||||
}
|
||||
}];
|
||||
|
||||
dispatch_release(concurrentQueue);
|
||||
}
|
||||
|
||||
- (void)testExtensionsPerformance {
|
||||
[self measureBlock:^{
|
||||
for (int i = 0; i < 200; ++i) {
|
||||
TestAllExtensions* message = [[TestAllExtensions alloc] init];
|
||||
[self setAllExtensions:message repeatedCount:kRepeatedCount];
|
||||
NSData* rawBytes = [message data];
|
||||
[message release];
|
||||
TestAllExtensions* message2 = [[TestAllExtensions alloc] initWithData:rawBytes error:NULL];
|
||||
[message2 release];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testPackedTypesPerformance {
|
||||
[self measureBlock:^{
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
TestPackedTypes* message = [[TestPackedTypes alloc] init];
|
||||
[self setPackedFields:message repeatedCount:kRepeatedCount];
|
||||
NSData* rawBytes = [message data];
|
||||
[message release];
|
||||
message = [[TestPackedTypes alloc] initWithData:rawBytes error:NULL];
|
||||
[message release];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testPackedExtensionsPerformance {
|
||||
[self measureBlock:^{
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
TestPackedExtensions* message = [[TestPackedExtensions alloc] init];
|
||||
[self setPackedExtensions:message repeatedCount:kRepeatedCount];
|
||||
NSData* rawBytes = [message data];
|
||||
[message release];
|
||||
TestPackedExtensions* message2 = [[TestPackedExtensions alloc] initWithData:rawBytes
|
||||
error:NULL];
|
||||
[message2 release];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testHas {
|
||||
TestAllTypes* message = [self allSetRepeatedCount:1];
|
||||
[self measureBlock:^{
|
||||
for (int i = 0; i < 10000; ++i) {
|
||||
[message hasOptionalInt32];
|
||||
message.hasOptionalInt32 = NO;
|
||||
[message hasOptionalInt32];
|
||||
|
||||
[message hasOptionalInt64];
|
||||
message.hasOptionalInt64 = NO;
|
||||
[message hasOptionalInt64];
|
||||
|
||||
[message hasOptionalUint32];
|
||||
message.hasOptionalUint32 = NO;
|
||||
[message hasOptionalUint32];
|
||||
|
||||
[message hasOptionalUint64];
|
||||
message.hasOptionalUint64 = NO;
|
||||
[message hasOptionalUint64];
|
||||
|
||||
[message hasOptionalSint32];
|
||||
message.hasOptionalSint32 = NO;
|
||||
[message hasOptionalSint32];
|
||||
|
||||
[message hasOptionalSint64];
|
||||
message.hasOptionalSint64 = NO;
|
||||
[message hasOptionalSint64];
|
||||
|
||||
[message hasOptionalFixed32];
|
||||
message.hasOptionalFixed32 = NO;
|
||||
[message hasOptionalFixed32];
|
||||
|
||||
[message hasOptionalFixed64];
|
||||
message.hasOptionalFixed64 = NO;
|
||||
[message hasOptionalFixed64];
|
||||
|
||||
[message hasOptionalSfixed32];
|
||||
message.hasOptionalSfixed32 = NO;
|
||||
[message hasOptionalSfixed32];
|
||||
|
||||
[message hasOptionalSfixed64];
|
||||
message.hasOptionalSfixed64 = NO;
|
||||
[message hasOptionalSfixed64];
|
||||
|
||||
[message hasOptionalFloat];
|
||||
message.hasOptionalFloat = NO;
|
||||
[message hasOptionalFloat];
|
||||
|
||||
[message hasOptionalDouble];
|
||||
message.hasOptionalDouble = NO;
|
||||
[message hasOptionalDouble];
|
||||
|
||||
[message hasOptionalBool];
|
||||
message.hasOptionalBool = NO;
|
||||
[message hasOptionalBool];
|
||||
|
||||
[message hasOptionalString];
|
||||
message.hasOptionalString = NO;
|
||||
[message hasOptionalString];
|
||||
|
||||
[message hasOptionalBytes];
|
||||
message.hasOptionalBytes = NO;
|
||||
[message hasOptionalBytes];
|
||||
|
||||
[message hasOptionalGroup];
|
||||
message.hasOptionalGroup = NO;
|
||||
[message hasOptionalGroup];
|
||||
|
||||
[message hasOptionalNestedMessage];
|
||||
message.hasOptionalNestedMessage = NO;
|
||||
[message hasOptionalNestedMessage];
|
||||
|
||||
[message hasOptionalForeignMessage];
|
||||
message.hasOptionalForeignMessage = NO;
|
||||
[message hasOptionalForeignMessage];
|
||||
|
||||
[message hasOptionalImportMessage];
|
||||
message.hasOptionalImportMessage = NO;
|
||||
[message hasOptionalImportMessage];
|
||||
|
||||
[message.optionalGroup hasA];
|
||||
message.optionalGroup.hasA = NO;
|
||||
[message.optionalGroup hasA];
|
||||
|
||||
[message.optionalNestedMessage hasBb];
|
||||
message.optionalNestedMessage.hasBb = NO;
|
||||
[message.optionalNestedMessage hasBb];
|
||||
|
||||
[message.optionalForeignMessage hasC];
|
||||
message.optionalForeignMessage.hasC = NO;
|
||||
[message.optionalForeignMessage hasC];
|
||||
|
||||
[message.optionalImportMessage hasD];
|
||||
message.optionalImportMessage.hasD = NO;
|
||||
[message.optionalImportMessage hasD];
|
||||
|
||||
[message hasOptionalNestedEnum];
|
||||
message.hasOptionalNestedEnum = NO;
|
||||
[message hasOptionalNestedEnum];
|
||||
|
||||
[message hasOptionalForeignEnum];
|
||||
message.hasOptionalForeignEnum = NO;
|
||||
[message hasOptionalForeignEnum];
|
||||
|
||||
[message hasOptionalImportEnum];
|
||||
message.hasOptionalImportEnum = NO;
|
||||
[message hasOptionalImportEnum];
|
||||
|
||||
[message hasOptionalStringPiece];
|
||||
message.hasOptionalStringPiece = NO;
|
||||
[message hasOptionalStringPiece];
|
||||
|
||||
[message hasOptionalCord];
|
||||
message.hasOptionalCord = NO;
|
||||
[message hasOptionalCord];
|
||||
|
||||
[message hasDefaultInt32];
|
||||
message.hasDefaultInt32 = NO;
|
||||
[message hasDefaultInt32];
|
||||
|
||||
[message hasDefaultInt64];
|
||||
message.hasDefaultInt64 = NO;
|
||||
[message hasDefaultInt64];
|
||||
|
||||
[message hasDefaultUint32];
|
||||
message.hasDefaultUint32 = NO;
|
||||
[message hasDefaultUint32];
|
||||
|
||||
[message hasDefaultUint64];
|
||||
message.hasDefaultUint64 = NO;
|
||||
[message hasDefaultUint64];
|
||||
|
||||
[message hasDefaultSint32];
|
||||
message.hasDefaultSint32 = NO;
|
||||
[message hasDefaultSint32];
|
||||
|
||||
[message hasDefaultSint64];
|
||||
message.hasDefaultSint64 = NO;
|
||||
[message hasDefaultSint64];
|
||||
|
||||
[message hasDefaultFixed32];
|
||||
message.hasDefaultFixed32 = NO;
|
||||
[message hasDefaultFixed32];
|
||||
|
||||
[message hasDefaultFixed64];
|
||||
message.hasDefaultFixed64 = NO;
|
||||
[message hasDefaultFixed64];
|
||||
|
||||
[message hasDefaultSfixed32];
|
||||
message.hasDefaultSfixed32 = NO;
|
||||
[message hasDefaultSfixed32];
|
||||
|
||||
[message hasDefaultSfixed64];
|
||||
message.hasDefaultSfixed64 = NO;
|
||||
[message hasDefaultSfixed64];
|
||||
|
||||
[message hasDefaultFloat];
|
||||
message.hasDefaultFloat = NO;
|
||||
[message hasDefaultFloat];
|
||||
|
||||
[message hasDefaultDouble];
|
||||
message.hasDefaultDouble = NO;
|
||||
[message hasDefaultDouble];
|
||||
|
||||
[message hasDefaultBool];
|
||||
message.hasDefaultBool = NO;
|
||||
[message hasDefaultBool];
|
||||
|
||||
[message hasDefaultString];
|
||||
message.hasDefaultString = NO;
|
||||
[message hasDefaultString];
|
||||
|
||||
[message hasDefaultBytes];
|
||||
message.hasDefaultBytes = NO;
|
||||
[message hasDefaultBytes];
|
||||
|
||||
[message hasDefaultNestedEnum];
|
||||
message.hasDefaultNestedEnum = NO;
|
||||
[message hasDefaultNestedEnum];
|
||||
|
||||
[message hasDefaultForeignEnum];
|
||||
message.hasDefaultForeignEnum = NO;
|
||||
[message hasDefaultForeignEnum];
|
||||
|
||||
[message hasDefaultImportEnum];
|
||||
message.hasDefaultImportEnum = NO;
|
||||
[message hasDefaultImportEnum];
|
||||
|
||||
[message hasDefaultStringPiece];
|
||||
message.hasDefaultStringPiece = NO;
|
||||
[message hasDefaultStringPiece];
|
||||
|
||||
[message hasDefaultCord];
|
||||
message.hasDefaultCord = NO;
|
||||
[message hasDefaultCord];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
460
objectivec/Tests/GPBSwiftTests.swift
Normal file
460
objectivec/Tests/GPBSwiftTests.swift
Normal file
@@ -0,0 +1,460 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
|
||||
// Test some usage of the ObjC library from Swift.
|
||||
|
||||
class GPBBridgeTests: XCTestCase {
|
||||
|
||||
func testProto2Basics() {
|
||||
let msg = Message2()
|
||||
let msg2 = Message2()
|
||||
let msg3 = Message2_OptionalGroup()
|
||||
|
||||
msg.optionalInt32 = 100
|
||||
msg.optionalString = "abc"
|
||||
msg.optionalEnum = .bar
|
||||
msg2.optionalString = "other"
|
||||
msg.optional = msg2
|
||||
msg3.a = 200
|
||||
msg.optionalGroup = msg3
|
||||
msg.repeatedInt32Array.addValue(300)
|
||||
msg.repeatedInt32Array.addValue(301)
|
||||
msg.repeatedStringArray.add("mno")
|
||||
msg.repeatedStringArray.add("pqr")
|
||||
msg.repeatedEnumArray.addValue(Message2_Enum.bar.rawValue)
|
||||
msg.repeatedEnumArray.addValue(Message2_Enum.baz.rawValue)
|
||||
msg.mapInt32Int32.setInt32(400, forKey:500)
|
||||
msg.mapInt32Int32.setInt32(401, forKey:501)
|
||||
msg.mapStringString.setObject("foo", forKey:"bar" as NSString)
|
||||
msg.mapStringString.setObject("abc", forKey:"xyz" as NSString)
|
||||
msg.mapInt32Enum.setEnum(Message2_Enum.bar.rawValue, forKey:600)
|
||||
msg.mapInt32Enum.setEnum(Message2_Enum.baz.rawValue, forKey:601)
|
||||
|
||||
// Check has*.
|
||||
XCTAssertTrue(msg.hasOptionalInt32)
|
||||
XCTAssertTrue(msg.hasOptionalString)
|
||||
XCTAssertTrue(msg.hasOptionalEnum)
|
||||
XCTAssertTrue(msg2.hasOptionalString)
|
||||
XCTAssertTrue(msg.hasOptionalMessage)
|
||||
XCTAssertTrue(msg3.hasA)
|
||||
XCTAssertTrue(msg.hasOptionalGroup)
|
||||
XCTAssertFalse(msg.hasOptionalInt64)
|
||||
XCTAssertFalse(msg.hasOptionalFloat)
|
||||
|
||||
// Check values.
|
||||
XCTAssertEqual(msg.optionalInt32, Int32(100))
|
||||
XCTAssertEqual(msg.optionalString, "abc")
|
||||
XCTAssertEqual(msg2.optionalString, "other")
|
||||
XCTAssertTrue(msg.optional === msg2)
|
||||
XCTAssertEqual(msg.optionalEnum, Message2_Enum.bar)
|
||||
XCTAssertEqual(msg3.a, Int32(200))
|
||||
XCTAssertTrue(msg.optionalGroup === msg3)
|
||||
XCTAssertEqual(msg.repeatedInt32Array.count, UInt(2))
|
||||
XCTAssertEqual(msg.repeatedInt32Array.value(at: 0), Int32(300))
|
||||
XCTAssertEqual(msg.repeatedInt32Array.value(at: 1), Int32(301))
|
||||
XCTAssertEqual(msg.repeatedStringArray.count, Int(2))
|
||||
XCTAssertEqual(msg.repeatedStringArray.object(at: 0) as? String, "mno")
|
||||
XCTAssertEqual(msg.repeatedStringArray.object(at: 1) as? String, "pqr")
|
||||
XCTAssertEqual(msg.repeatedEnumArray.count, UInt(2))
|
||||
XCTAssertEqual(msg.repeatedEnumArray.value(at: 0), Message2_Enum.bar.rawValue)
|
||||
XCTAssertEqual(msg.repeatedEnumArray.value(at: 1), Message2_Enum.baz.rawValue)
|
||||
XCTAssertEqual(msg.repeatedInt64Array.count, UInt(0))
|
||||
XCTAssertEqual(msg.mapInt32Int32.count, UInt(2))
|
||||
var intValue: Int32 = 0
|
||||
XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey: 500))
|
||||
XCTAssertEqual(intValue, Int32(400))
|
||||
XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey: 501))
|
||||
XCTAssertEqual(intValue, Int32(401))
|
||||
XCTAssertEqual(msg.mapStringString.count, Int(2))
|
||||
XCTAssertEqual(msg.mapStringString.object(forKey: "bar") as? String, "foo")
|
||||
XCTAssertEqual(msg.mapStringString.object(forKey: "xyz") as? String, "abc")
|
||||
XCTAssertEqual(msg.mapInt32Enum.count, UInt(2))
|
||||
XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:600))
|
||||
XCTAssertEqual(intValue, Message2_Enum.bar.rawValue)
|
||||
XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:601))
|
||||
XCTAssertEqual(intValue, Message2_Enum.baz.rawValue)
|
||||
|
||||
// Clearing a string with nil.
|
||||
msg2.optionalString = nil
|
||||
XCTAssertFalse(msg2.hasOptionalString)
|
||||
XCTAssertEqual(msg2.optionalString, "")
|
||||
|
||||
// Clearing a message with nil.
|
||||
msg.optionalGroup = nil
|
||||
XCTAssertFalse(msg.hasOptionalGroup)
|
||||
XCTAssertTrue(msg.optionalGroup !== msg3) // New instance
|
||||
|
||||
// Clear.
|
||||
msg.clear()
|
||||
XCTAssertFalse(msg.hasOptionalInt32)
|
||||
XCTAssertFalse(msg.hasOptionalString)
|
||||
XCTAssertFalse(msg.hasOptionalEnum)
|
||||
XCTAssertFalse(msg.hasOptionalMessage)
|
||||
XCTAssertFalse(msg.hasOptionalInt64)
|
||||
XCTAssertFalse(msg.hasOptionalFloat)
|
||||
XCTAssertEqual(msg.optionalInt32, Int32(0))
|
||||
XCTAssertEqual(msg.optionalString, "")
|
||||
XCTAssertTrue(msg.optional !== msg2) // New instance
|
||||
XCTAssertEqual(msg.optionalEnum, Message2_Enum.foo) // Default
|
||||
XCTAssertEqual(msg.repeatedInt32Array.count, UInt(0))
|
||||
XCTAssertEqual(msg.repeatedStringArray.count, Int(0))
|
||||
XCTAssertEqual(msg.repeatedEnumArray.count, UInt(0))
|
||||
XCTAssertEqual(msg.mapInt32Int32.count, UInt(0))
|
||||
XCTAssertEqual(msg.mapStringString.count, Int(0))
|
||||
XCTAssertEqual(msg.mapInt32Enum.count, UInt(0))
|
||||
}
|
||||
|
||||
func testProto3Basics() {
|
||||
let msg = Message3()
|
||||
let msg2 = Message3()
|
||||
|
||||
msg.optionalInt32 = 100
|
||||
msg.optionalString = "abc"
|
||||
msg.optionalEnum = .bar
|
||||
msg2.optionalString = "other"
|
||||
msg.optional = msg2
|
||||
msg.repeatedInt32Array.addValue(300)
|
||||
msg.repeatedInt32Array.addValue(301)
|
||||
msg.repeatedStringArray.add("mno")
|
||||
msg.repeatedStringArray.add("pqr")
|
||||
// "proto3" syntax lets enum get unknown values.
|
||||
msg.repeatedEnumArray.addValue(Message3_Enum.bar.rawValue)
|
||||
msg.repeatedEnumArray.addRawValue(666)
|
||||
SetMessage3_OptionalEnum_RawValue(msg2, 666)
|
||||
msg.mapInt32Int32.setInt32(400, forKey:500)
|
||||
msg.mapInt32Int32.setInt32(401, forKey:501)
|
||||
msg.mapStringString.setObject("foo", forKey:"bar" as NSString)
|
||||
msg.mapStringString.setObject("abc", forKey:"xyz" as NSString)
|
||||
msg.mapInt32Enum.setEnum(Message2_Enum.bar.rawValue, forKey:600)
|
||||
// "proto3" syntax lets enum get unknown values.
|
||||
msg.mapInt32Enum.setRawValue(666, forKey:601)
|
||||
|
||||
// Has only exists on for message fields.
|
||||
XCTAssertTrue(msg.hasOptionalMessage)
|
||||
XCTAssertFalse(msg2.hasOptionalMessage)
|
||||
|
||||
// Check values.
|
||||
XCTAssertEqual(msg.optionalInt32, Int32(100))
|
||||
XCTAssertEqual(msg.optionalString, "abc")
|
||||
XCTAssertEqual(msg2.optionalString, "other")
|
||||
XCTAssertTrue(msg.optional === msg2)
|
||||
XCTAssertEqual(msg.optionalEnum, Message3_Enum.bar)
|
||||
XCTAssertEqual(msg.repeatedInt32Array.count, UInt(2))
|
||||
XCTAssertEqual(msg.repeatedInt32Array.value(at: 0), Int32(300))
|
||||
XCTAssertEqual(msg.repeatedInt32Array.value(at: 1), Int32(301))
|
||||
XCTAssertEqual(msg.repeatedStringArray.count, Int(2))
|
||||
XCTAssertEqual(msg.repeatedStringArray.object(at: 0) as? String, "mno")
|
||||
XCTAssertEqual(msg.repeatedStringArray.object(at: 1) as? String, "pqr")
|
||||
XCTAssertEqual(msg.repeatedInt64Array.count, UInt(0))
|
||||
XCTAssertEqual(msg.repeatedEnumArray.count, UInt(2))
|
||||
XCTAssertEqual(msg.repeatedEnumArray.value(at: 0), Message3_Enum.bar.rawValue)
|
||||
XCTAssertEqual(msg.repeatedEnumArray.value(at: 1), Message3_Enum.gpbUnrecognizedEnumeratorValue.rawValue)
|
||||
XCTAssertEqual(msg.repeatedEnumArray.rawValue(at: 1), 666)
|
||||
XCTAssertEqual(msg2.optionalEnum, Message3_Enum.gpbUnrecognizedEnumeratorValue)
|
||||
XCTAssertEqual(Message3_OptionalEnum_RawValue(msg2), Int32(666))
|
||||
XCTAssertEqual(msg.mapInt32Int32.count, UInt(2))
|
||||
var intValue: Int32 = 0
|
||||
XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey:500))
|
||||
XCTAssertEqual(intValue, Int32(400))
|
||||
XCTAssertTrue(msg.mapInt32Int32.getInt32(&intValue, forKey:501))
|
||||
XCTAssertEqual(intValue, Int32(401))
|
||||
XCTAssertEqual(msg.mapStringString.count, Int(2))
|
||||
XCTAssertEqual(msg.mapStringString.object(forKey: "bar") as? String, "foo")
|
||||
XCTAssertEqual(msg.mapStringString.object(forKey: "xyz") as? String, "abc")
|
||||
XCTAssertEqual(msg.mapInt32Enum.count, UInt(2))
|
||||
XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:600))
|
||||
XCTAssertEqual(intValue, Message2_Enum.bar.rawValue)
|
||||
XCTAssertTrue(msg.mapInt32Enum.getEnum(&intValue, forKey:601))
|
||||
XCTAssertEqual(intValue, Message3_Enum.gpbUnrecognizedEnumeratorValue.rawValue)
|
||||
XCTAssertTrue(msg.mapInt32Enum.getRawValue(&intValue, forKey:601))
|
||||
XCTAssertEqual(intValue, 666)
|
||||
|
||||
// Clearing a string with nil.
|
||||
msg2.optionalString = nil
|
||||
XCTAssertEqual(msg2.optionalString, "")
|
||||
|
||||
// Clearing a message with nil.
|
||||
msg.optional = nil
|
||||
XCTAssertFalse(msg.hasOptionalMessage)
|
||||
XCTAssertTrue(msg.optional !== msg2) // New instance
|
||||
|
||||
// Clear.
|
||||
msg.clear()
|
||||
XCTAssertFalse(msg.hasOptionalMessage)
|
||||
XCTAssertEqual(msg.optionalInt32, Int32(0))
|
||||
XCTAssertEqual(msg.optionalString, "")
|
||||
XCTAssertTrue(msg.optional !== msg2) // New instance
|
||||
XCTAssertEqual(msg.optionalEnum, Message3_Enum.foo) // Default
|
||||
XCTAssertEqual(msg.repeatedInt32Array.count, UInt(0))
|
||||
XCTAssertEqual(msg.repeatedStringArray.count, Int(0))
|
||||
XCTAssertEqual(msg.repeatedEnumArray.count, UInt(0))
|
||||
msg2.clear()
|
||||
XCTAssertEqual(msg2.optionalEnum, Message3_Enum.foo) // Default
|
||||
XCTAssertEqual(Message3_OptionalEnum_RawValue(msg2), Message3_Enum.foo.rawValue)
|
||||
XCTAssertEqual(msg.mapInt32Int32.count, UInt(0))
|
||||
XCTAssertEqual(msg.mapStringString.count, Int(0))
|
||||
XCTAssertEqual(msg.mapInt32Enum.count, UInt(0))
|
||||
}
|
||||
|
||||
func testAutoCreation() {
|
||||
let msg = Message2()
|
||||
|
||||
XCTAssertFalse(msg.hasOptionalGroup)
|
||||
XCTAssertFalse(msg.hasOptionalMessage)
|
||||
|
||||
// Access shouldn't result in has* but should return objects.
|
||||
let msg2 = msg.optionalGroup
|
||||
let msg3 = msg.optional.optional
|
||||
let msg4 = msg.optional
|
||||
XCTAssertNotNil(msg2)
|
||||
XCTAssertNotNil(msg3)
|
||||
XCTAssertFalse(msg.hasOptionalGroup)
|
||||
XCTAssertFalse(msg.optional.hasOptionalMessage)
|
||||
XCTAssertFalse(msg.hasOptionalMessage)
|
||||
|
||||
// Setting things should trigger has* getting set.
|
||||
msg.optionalGroup.a = 10
|
||||
msg.optional.optional.optionalInt32 = 100
|
||||
XCTAssertTrue(msg.hasOptionalGroup)
|
||||
XCTAssertTrue(msg.optional.hasOptionalMessage)
|
||||
XCTAssertTrue(msg.hasOptionalMessage)
|
||||
|
||||
// And they should be the same pointer as before.
|
||||
XCTAssertTrue(msg2 === msg.optionalGroup)
|
||||
XCTAssertTrue(msg3 === msg.optional.optional)
|
||||
XCTAssertTrue(msg4 === msg.optional)
|
||||
|
||||
// Clear gets us new objects next time around.
|
||||
msg.clear()
|
||||
XCTAssertFalse(msg.hasOptionalGroup)
|
||||
XCTAssertFalse(msg.optional.hasOptionalMessage)
|
||||
XCTAssertFalse(msg.hasOptionalMessage)
|
||||
msg.optionalGroup.a = 20
|
||||
msg.optional.optional.optionalInt32 = 200
|
||||
XCTAssertTrue(msg.hasOptionalGroup)
|
||||
XCTAssertTrue(msg.optional.hasOptionalMessage)
|
||||
XCTAssertTrue(msg.hasOptionalMessage)
|
||||
XCTAssertTrue(msg2 !== msg.optionalGroup)
|
||||
XCTAssertTrue(msg3 !== msg.optional.optional)
|
||||
XCTAssertTrue(msg4 !== msg.optional)
|
||||
|
||||
// Explicit set of a message, means autocreated object doesn't bind.
|
||||
msg.clear()
|
||||
let autoCreated = msg.optional
|
||||
XCTAssertFalse(msg.hasOptionalMessage)
|
||||
let msg5 = Message2()
|
||||
msg5.optionalInt32 = 123
|
||||
msg.optional = msg5
|
||||
XCTAssertTrue(msg.hasOptionalMessage)
|
||||
// Modifying the autocreated doesn't replaced the explicit set one.
|
||||
autoCreated?.optionalInt32 = 456
|
||||
XCTAssertTrue(msg.hasOptionalMessage)
|
||||
XCTAssertTrue(msg.optional === msg5)
|
||||
XCTAssertEqual(msg.optional.optionalInt32, Int32(123))
|
||||
}
|
||||
|
||||
func testProto2OneOfSupport() {
|
||||
let msg = Message2()
|
||||
|
||||
XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
|
||||
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
|
||||
XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
|
||||
let autoCreated = msg.oneof // Default create one.
|
||||
XCTAssertNotNil(autoCreated)
|
||||
XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
|
||||
|
||||
msg.oneofInt32 = 10
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(10))
|
||||
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
|
||||
XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
|
||||
XCTAssertTrue(msg.oneof === autoCreated) // Still the same
|
||||
XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofInt32)
|
||||
|
||||
msg.oneofFloat = 20.0
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
|
||||
XCTAssertEqual(msg.oneofFloat, Float(20.0))
|
||||
XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
|
||||
XCTAssertTrue(msg.oneof === autoCreated) // Still the same
|
||||
XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofFloat)
|
||||
|
||||
msg.oneofEnum = .bar
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
|
||||
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
|
||||
XCTAssertEqual(msg.oneofEnum, Message2_Enum.bar)
|
||||
XCTAssertTrue(msg.oneof === autoCreated) // Still the same
|
||||
XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofEnum)
|
||||
|
||||
// Sets via the autocreated instance.
|
||||
msg.oneof.optionalInt32 = 200
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
|
||||
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
|
||||
XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
|
||||
XCTAssertTrue(msg.oneof === autoCreated) // Still the same
|
||||
XCTAssertEqual(msg.oneof.optionalInt32, Int32(200))
|
||||
XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofMessage)
|
||||
|
||||
// Clear the oneof.
|
||||
Message2_ClearOOneOfCase(msg)
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
|
||||
XCTAssertEqual(msg.oneofFloat, Float(110.0)) // Default
|
||||
XCTAssertEqual(msg.oneofEnum, Message2_Enum.baz) // Default
|
||||
let autoCreated2 = msg.oneof // Default create one
|
||||
XCTAssertNotNil(autoCreated2)
|
||||
XCTAssertTrue(autoCreated2 !== autoCreated) // New instance
|
||||
XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
|
||||
XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
|
||||
|
||||
msg.oneofInt32 = 10
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(10))
|
||||
XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofInt32)
|
||||
|
||||
// Confirm Message.clear() handles the oneof correctly.
|
||||
msg.clear()
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(100)) // Default
|
||||
XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
|
||||
|
||||
// Sets via the autocreated instance.
|
||||
msg.oneof.optionalInt32 = 300
|
||||
XCTAssertTrue(msg.oneof !== autoCreated) // New instance
|
||||
XCTAssertTrue(msg.oneof !== autoCreated2) // New instance
|
||||
XCTAssertEqual(msg.oneof.optionalInt32, Int32(300))
|
||||
XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.oneofMessage)
|
||||
|
||||
// Set message to nil clears the oneof.
|
||||
msg.oneof = nil
|
||||
XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
|
||||
XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase.gpbUnsetOneOfCase)
|
||||
}
|
||||
|
||||
func testProto3OneOfSupport() {
|
||||
let msg = Message3()
|
||||
|
||||
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
|
||||
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
|
||||
XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
|
||||
let autoCreated = msg.oneof // Default create one.
|
||||
XCTAssertNotNil(autoCreated)
|
||||
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
|
||||
|
||||
msg.oneofInt32 = 10
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(10))
|
||||
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
|
||||
XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
|
||||
XCTAssertTrue(msg.oneof === autoCreated) // Still the same
|
||||
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofInt32)
|
||||
|
||||
msg.oneofFloat = 20.0
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
|
||||
XCTAssertEqual(msg.oneofFloat, Float(20.0))
|
||||
XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
|
||||
XCTAssertTrue(msg.oneof === autoCreated) // Still the same
|
||||
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofFloat)
|
||||
|
||||
msg.oneofEnum = .bar
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
|
||||
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
|
||||
XCTAssertEqual(msg.oneofEnum, Message3_Enum.bar)
|
||||
XCTAssertTrue(msg.oneof === autoCreated) // Still the same
|
||||
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofEnum)
|
||||
|
||||
// Sets via the autocreated instance.
|
||||
msg.oneof.optionalInt32 = 200
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
|
||||
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
|
||||
XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
|
||||
XCTAssertTrue(msg.oneof === autoCreated) // Still the same
|
||||
XCTAssertEqual(msg.oneof.optionalInt32, Int32(200))
|
||||
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofMessage)
|
||||
|
||||
// Clear the oneof.
|
||||
Message3_ClearOOneOfCase(msg)
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
|
||||
XCTAssertEqual(msg.oneofFloat, Float(0.0)) // Default
|
||||
XCTAssertEqual(msg.oneofEnum, Message3_Enum.foo) // Default
|
||||
let autoCreated2 = msg.oneof // Default create one
|
||||
XCTAssertNotNil(autoCreated2)
|
||||
XCTAssertTrue(autoCreated2 !== autoCreated) // New instance
|
||||
XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
|
||||
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
|
||||
|
||||
msg.oneofInt32 = 10
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(10))
|
||||
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofInt32)
|
||||
|
||||
// Confirm Message.clear() handles the oneof correctly.
|
||||
msg.clear()
|
||||
XCTAssertEqual(msg.oneofInt32, Int32(0)) // Default
|
||||
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
|
||||
|
||||
// Sets via the autocreated instance.
|
||||
msg.oneof.optionalInt32 = 300
|
||||
XCTAssertTrue(msg.oneof !== autoCreated) // New instance
|
||||
XCTAssertTrue(msg.oneof !== autoCreated2) // New instance
|
||||
XCTAssertEqual(msg.oneof.optionalInt32, Int32(300))
|
||||
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.oneofMessage)
|
||||
|
||||
// Set message to nil clears the oneof.
|
||||
msg.oneof = nil
|
||||
XCTAssertEqual(msg.oneof.optionalInt32, Int32(0)) // Default
|
||||
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase.gpbUnsetOneOfCase)
|
||||
}
|
||||
|
||||
func testSerialization() {
|
||||
let msg = Message2()
|
||||
|
||||
msg.optionalInt32 = 100
|
||||
msg.optionalInt64 = 101
|
||||
msg.optionalGroup.a = 102
|
||||
msg.repeatedStringArray.add("abc")
|
||||
msg.repeatedStringArray.add("def")
|
||||
msg.mapInt32Int32.setInt32(200, forKey:300)
|
||||
msg.mapInt32Int32.setInt32(201, forKey:201)
|
||||
msg.mapStringString.setObject("foo", forKey:"bar" as NSString)
|
||||
msg.mapStringString.setObject("abc", forKey:"xyz" as NSString)
|
||||
|
||||
let data = msg.data()
|
||||
|
||||
let msg2 = try! Message2(data: data!)
|
||||
XCTAssertTrue(msg2 !== msg) // New instance
|
||||
XCTAssertEqual(msg.optionalInt32, Int32(100))
|
||||
XCTAssertEqual(msg.optionalInt64, Int64(101))
|
||||
XCTAssertEqual(msg.optionalGroup.a, Int32(102))
|
||||
XCTAssertEqual(msg.repeatedStringArray.count, Int(2))
|
||||
XCTAssertEqual(msg.mapInt32Int32.count, UInt(2))
|
||||
XCTAssertEqual(msg.mapStringString.count, Int(2))
|
||||
XCTAssertEqual(msg2, msg)
|
||||
}
|
||||
|
||||
}
|
||||
90
objectivec/Tests/GPBTestUtilities.h
Normal file
90
objectivec/Tests/GPBTestUtilities.h
Normal file
@@ -0,0 +1,90 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
@class TestAllExtensions;
|
||||
@class TestAllTypes;
|
||||
@class TestMap;
|
||||
@class TestPackedTypes;
|
||||
@class TestPackedExtensions;
|
||||
@class TestUnpackedTypes;
|
||||
@class TestUnpackedExtensions;
|
||||
@class GPBExtensionRegistry;
|
||||
|
||||
static inline NSData *DataFromCStr(const char *str) {
|
||||
return [NSData dataWithBytes:str length:strlen(str)];
|
||||
}
|
||||
|
||||
// Helper for uses of C arrays in tests cases.
|
||||
#ifndef GPBARRAYSIZE
|
||||
#define GPBARRAYSIZE(a) ((sizeof(a) / sizeof((a[0]))))
|
||||
#endif // GPBARRAYSIZE
|
||||
|
||||
// The number of repetitions of any repeated objects inside of test messages.
|
||||
extern const uint32_t kGPBDefaultRepeatCount;
|
||||
|
||||
@interface GPBTestCase : XCTestCase
|
||||
|
||||
- (void)setAllFields:(TestAllTypes *)message repeatedCount:(uint32_t)count;
|
||||
- (void)clearAllFields:(TestAllTypes *)message;
|
||||
- (void)setAllExtensions:(TestAllExtensions *)message repeatedCount:(uint32_t)count;
|
||||
- (void)setPackedFields:(TestPackedTypes *)message repeatedCount:(uint32_t)count;
|
||||
- (void)setUnpackedFields:(TestUnpackedTypes *)message repeatedCount:(uint32_t)count;
|
||||
- (void)setPackedExtensions:(TestPackedExtensions *)message repeatedCount:(uint32_t)count;
|
||||
- (void)setUnpackedExtensions:(TestUnpackedExtensions *)message repeatedCount:(uint32_t)count;
|
||||
- (void)setAllMapFields:(TestMap *)message numEntries:(uint32_t)count;
|
||||
|
||||
- (TestAllTypes *)allSetRepeatedCount:(uint32_t)count;
|
||||
- (TestAllExtensions *)allExtensionsSetRepeatedCount:(uint32_t)count;
|
||||
- (TestPackedTypes *)packedSetRepeatedCount:(uint32_t)count;
|
||||
- (TestPackedExtensions *)packedExtensionsSetRepeatedCount:(uint32_t)count;
|
||||
|
||||
- (void)assertAllFieldsSet:(TestAllTypes *)message repeatedCount:(uint32_t)count;
|
||||
- (void)assertAllExtensionsSet:(TestAllExtensions *)message repeatedCount:(uint32_t)count;
|
||||
- (void)assertRepeatedFieldsModified:(TestAllTypes *)message repeatedCount:(uint32_t)count;
|
||||
- (void)assertRepeatedExtensionsModified:(TestAllExtensions *)message repeatedCount:(uint32_t)count;
|
||||
- (void)assertExtensionsClear:(TestAllExtensions *)message;
|
||||
- (void)assertClear:(TestAllTypes *)message;
|
||||
- (void)assertPackedFieldsSet:(TestPackedTypes *)message repeatedCount:(uint32_t)count;
|
||||
- (void)assertPackedExtensionsSet:(TestPackedExtensions *)message repeatedCount:(uint32_t)count;
|
||||
|
||||
- (void)modifyRepeatedExtensions:(TestAllExtensions *)message;
|
||||
- (void)modifyRepeatedFields:(TestAllTypes *)message;
|
||||
|
||||
- (GPBExtensionRegistry *)extensionRegistry;
|
||||
|
||||
- (NSData *)getDataFileNamed:(NSString *)name dataToWrite:(NSData *)dataToWrite;
|
||||
|
||||
- (void)assertAllFieldsKVCMatch:(TestAllTypes *)message;
|
||||
- (void)setAllFieldsViaKVC:(TestAllTypes *)message repeatedCount:(uint32_t)count;
|
||||
- (void)assertClearKVC:(TestAllTypes *)message;
|
||||
|
||||
@end
|
||||
2516
objectivec/Tests/GPBTestUtilities.m
Normal file
2516
objectivec/Tests/GPBTestUtilities.m
Normal file
File diff suppressed because it is too large
Load Diff
57
objectivec/Tests/GPBUnittestProtos.m
Normal file
57
objectivec/Tests/GPBUnittestProtos.m
Normal file
@@ -0,0 +1,57 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Collects all the compiled protos into one file and compiles them to make sure
|
||||
// the compiler is generating valid code.
|
||||
|
||||
#import "objectivec/Tests/AnyTest.pbobjc.m"
|
||||
#import "objectivec/Tests/MapProto2Unittest.pbobjc.m"
|
||||
#import "objectivec/Tests/MapUnittest.pbobjc.m"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestCycle.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestDeprecated.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestDeprecatedFile.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestImport.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestImportPublic.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestMset.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestObjc.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestObjcOptions.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestObjcStartup.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestPreserveUnknownEnum.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto3.pbobjc.m"
|
||||
|
||||
#import "objectivec/Tests/UnittestExtensionChainA.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestExtensionChainB.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestExtensionChainC.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestExtensionChainD.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestExtensionChainE.pbobjc.m"
|
||||
// See GPBUnittestProtos2.m for for "UnittestExtensionChainF.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestExtensionChainG.pbobjc.m"
|
||||
34
objectivec/Tests/GPBUnittestProtos2.m
Normal file
34
objectivec/Tests/GPBUnittestProtos2.m
Normal file
@@ -0,0 +1,34 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2016 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This one file in the chain tests is compiled by itself to ensure if was
|
||||
// generated with the extra #imports needed to pull in the indirect Root class
|
||||
// used in its Root registry.
|
||||
#import "objectivec/Tests/UnittestExtensionChainF.pbobjc.m"
|
||||
502
objectivec/Tests/GPBUnknownFieldSetTest.m
Normal file
502
objectivec/Tests/GPBUnknownFieldSetTest.m
Normal file
@@ -0,0 +1,502 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
#import "GPBUnknownField_PackagePrivate.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
|
||||
@interface GPBUnknownFieldSet (GPBUnknownFieldSetTest)
|
||||
- (void)getTags:(int32_t*)tags;
|
||||
@end
|
||||
|
||||
@interface UnknownFieldSetTest : GPBTestCase {
|
||||
@private
|
||||
TestAllTypes* allFields_;
|
||||
NSData* allFieldsData_;
|
||||
|
||||
// An empty message that has been parsed from allFieldsData. So, it has
|
||||
// unknown fields of every type.
|
||||
TestEmptyMessage* emptyMessage_;
|
||||
GPBUnknownFieldSet* unknownFields_;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UnknownFieldSetTest
|
||||
|
||||
- (void)setUp {
|
||||
allFields_ = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
allFieldsData_ = [allFields_ data];
|
||||
emptyMessage_ = [TestEmptyMessage parseFromData:allFieldsData_ error:NULL];
|
||||
unknownFields_ = emptyMessage_.unknownFields;
|
||||
}
|
||||
|
||||
- (void)testInvalidFieldNumber {
|
||||
GPBUnknownFieldSet* set = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* field = [[[GPBUnknownField alloc] initWithNumber:0] autorelease];
|
||||
XCTAssertThrowsSpecificNamed([set addField:field], NSException, NSInvalidArgumentException);
|
||||
}
|
||||
|
||||
- (void)testEqualityAndHash {
|
||||
// Empty
|
||||
|
||||
GPBUnknownFieldSet* set1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
XCTAssertTrue([set1 isEqual:set1]);
|
||||
XCTAssertFalse([set1 isEqual:@"foo"]);
|
||||
GPBUnknownFieldSet* set2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
XCTAssertEqualObjects(set1, set2);
|
||||
XCTAssertEqual([set1 hash], [set2 hash]);
|
||||
|
||||
// Varint
|
||||
|
||||
GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
[field1 addVarint:1];
|
||||
[set1 addField:field1];
|
||||
XCTAssertNotEqualObjects(set1, set2);
|
||||
GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
[field2 addVarint:1];
|
||||
[set2 addField:field2];
|
||||
XCTAssertEqualObjects(set1, set2);
|
||||
XCTAssertEqual([set1 hash], [set2 hash]);
|
||||
|
||||
// Fixed32
|
||||
|
||||
field1 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
|
||||
[field1 addFixed32:2];
|
||||
[set1 addField:field1];
|
||||
XCTAssertNotEqualObjects(set1, set2);
|
||||
field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
|
||||
[field2 addFixed32:2];
|
||||
[set2 addField:field2];
|
||||
XCTAssertEqualObjects(set1, set2);
|
||||
XCTAssertEqual([set1 hash], [set2 hash]);
|
||||
|
||||
// Fixed64
|
||||
|
||||
field1 = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
|
||||
[field1 addFixed64:3];
|
||||
[set1 addField:field1];
|
||||
XCTAssertNotEqualObjects(set1, set2);
|
||||
field2 = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
|
||||
[field2 addFixed64:3];
|
||||
[set2 addField:field2];
|
||||
XCTAssertEqualObjects(set1, set2);
|
||||
XCTAssertEqual([set1 hash], [set2 hash]);
|
||||
|
||||
// LengthDelimited
|
||||
|
||||
field1 = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
|
||||
[field1 addLengthDelimited:DataFromCStr("foo")];
|
||||
[set1 addField:field1];
|
||||
XCTAssertNotEqualObjects(set1, set2);
|
||||
field2 = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
|
||||
[field2 addLengthDelimited:DataFromCStr("foo")];
|
||||
[set2 addField:field2];
|
||||
XCTAssertEqualObjects(set1, set2);
|
||||
XCTAssertEqual([set1 hash], [set2 hash]);
|
||||
|
||||
// Group
|
||||
|
||||
GPBUnknownFieldSet* group1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup1 = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
|
||||
[fieldGroup1 addVarint:1];
|
||||
[group1 addField:fieldGroup1];
|
||||
GPBUnknownFieldSet* group2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup2 = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
|
||||
[fieldGroup2 addVarint:1];
|
||||
[group2 addField:fieldGroup2];
|
||||
|
||||
field1 = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
|
||||
[field1 addGroup:group1];
|
||||
[set1 addField:field1];
|
||||
XCTAssertNotEqualObjects(set1, set2);
|
||||
field2 = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
|
||||
[field2 addGroup:group2];
|
||||
[set2 addField:field2];
|
||||
XCTAssertEqualObjects(set1, set2);
|
||||
XCTAssertEqual([set1 hash], [set2 hash]);
|
||||
|
||||
// Exercise description for completeness.
|
||||
XCTAssertTrue(set1.description.length > 10);
|
||||
}
|
||||
|
||||
// Constructs a protocol buffer which contains fields with all the same
|
||||
// numbers as allFieldsData except that each field is some other wire
|
||||
// type.
|
||||
- (NSData*)getBizarroData {
|
||||
GPBUnknownFieldSet* bizarroFields = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
NSUInteger count = [unknownFields_ countOfFields];
|
||||
int32_t* tags = malloc(count * sizeof(int32_t));
|
||||
if (!tags) {
|
||||
XCTFail(@"Failed to make scratch buffer for testing");
|
||||
return [NSData data];
|
||||
}
|
||||
@try {
|
||||
[unknownFields_ getTags:tags];
|
||||
for (NSUInteger i = 0; i < count; ++i) {
|
||||
int32_t tag = tags[i];
|
||||
GPBUnknownField* field = [unknownFields_ getField:tag];
|
||||
if (field.varintList.count == 0) {
|
||||
// Original field is not a varint, so use a varint.
|
||||
GPBUnknownField* varintField = [[[GPBUnknownField alloc] initWithNumber:tag] autorelease];
|
||||
[varintField addVarint:1];
|
||||
[bizarroFields addField:varintField];
|
||||
} else {
|
||||
// Original field *is* a varint, so use something else.
|
||||
GPBUnknownField* fixed32Field = [[[GPBUnknownField alloc] initWithNumber:tag] autorelease];
|
||||
[fixed32Field addFixed32:1];
|
||||
[bizarroFields addField:fixed32Field];
|
||||
}
|
||||
}
|
||||
} @finally {
|
||||
free(tags);
|
||||
}
|
||||
|
||||
return [bizarroFields data];
|
||||
}
|
||||
|
||||
- (void)testSerialize {
|
||||
// Check that serializing the UnknownFieldSet produces the original data
|
||||
// again.
|
||||
NSData* data = [emptyMessage_ data];
|
||||
XCTAssertEqualObjects(allFieldsData_, data);
|
||||
}
|
||||
|
||||
- (void)testCopyFrom {
|
||||
TestEmptyMessage* message = [TestEmptyMessage message];
|
||||
[message mergeFrom:emptyMessage_];
|
||||
|
||||
XCTAssertEqualObjects(emptyMessage_.data, message.data);
|
||||
}
|
||||
|
||||
- (void)testMergeFrom {
|
||||
GPBUnknownFieldSet* set1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* field = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
|
||||
[field addVarint:2];
|
||||
[set1 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
|
||||
[field addVarint:4];
|
||||
[set1 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
|
||||
[field addFixed32:6];
|
||||
[set1 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
|
||||
[field addFixed64:20];
|
||||
[set1 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
|
||||
[field addLengthDelimited:DataFromCStr("data1")];
|
||||
[set1 addField:field];
|
||||
|
||||
GPBUnknownFieldSet* group1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup1 = [[[GPBUnknownField alloc] initWithNumber:200] autorelease];
|
||||
[fieldGroup1 addVarint:100];
|
||||
[group1 addField:fieldGroup1];
|
||||
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
|
||||
[field addGroup:group1];
|
||||
[set1 addField:field];
|
||||
|
||||
GPBUnknownFieldSet* set2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
[field addVarint:1];
|
||||
[set2 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
|
||||
[field addVarint:3];
|
||||
[set2 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
|
||||
[field addFixed32:7];
|
||||
[set2 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
|
||||
[field addFixed64:30];
|
||||
[set2 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
|
||||
[field addLengthDelimited:DataFromCStr("data2")];
|
||||
[set2 addField:field];
|
||||
|
||||
GPBUnknownFieldSet* group2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup2 = [[[GPBUnknownField alloc] initWithNumber:201] autorelease];
|
||||
[fieldGroup2 addVarint:99];
|
||||
[group2 addField:fieldGroup2];
|
||||
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
|
||||
[field addGroup:group2];
|
||||
[set2 addField:field];
|
||||
|
||||
GPBUnknownFieldSet* set3 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
[field addVarint:1];
|
||||
[set3 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
|
||||
[field addVarint:2];
|
||||
[set3 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
|
||||
[field addVarint:4];
|
||||
[set3 addField:field];
|
||||
[field addVarint:3];
|
||||
[set3 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:4] autorelease];
|
||||
[field addFixed32:6];
|
||||
[field addFixed32:7];
|
||||
[set3 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:5] autorelease];
|
||||
[field addFixed64:20];
|
||||
[field addFixed64:30];
|
||||
[set3 addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
|
||||
[field addLengthDelimited:DataFromCStr("data1")];
|
||||
[field addLengthDelimited:DataFromCStr("data2")];
|
||||
[set3 addField:field];
|
||||
|
||||
GPBUnknownFieldSet* group3a = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup3a1 = [[[GPBUnknownField alloc] initWithNumber:200] autorelease];
|
||||
[fieldGroup3a1 addVarint:100];
|
||||
[group3a addField:fieldGroup3a1];
|
||||
GPBUnknownFieldSet* group3b = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup3b2 = [[[GPBUnknownField alloc] initWithNumber:201] autorelease];
|
||||
[fieldGroup3b2 addVarint:99];
|
||||
[group3b addField:fieldGroup3b2];
|
||||
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:11] autorelease];
|
||||
[field addGroup:group1];
|
||||
[field addGroup:group3b];
|
||||
[set3 addField:field];
|
||||
|
||||
TestEmptyMessage* source1 = [TestEmptyMessage message];
|
||||
[source1 setUnknownFields:set1];
|
||||
TestEmptyMessage* source2 = [TestEmptyMessage message];
|
||||
[source2 setUnknownFields:set2];
|
||||
TestEmptyMessage* source3 = [TestEmptyMessage message];
|
||||
[source3 setUnknownFields:set3];
|
||||
|
||||
TestEmptyMessage* destination1 = [TestEmptyMessage message];
|
||||
[destination1 mergeFrom:source1];
|
||||
[destination1 mergeFrom:source2];
|
||||
|
||||
TestEmptyMessage* destination2 = [TestEmptyMessage message];
|
||||
[destination2 mergeFrom:source3];
|
||||
|
||||
XCTAssertEqualObjects(destination1.data, destination2.data);
|
||||
XCTAssertEqualObjects(destination1.data, source3.data);
|
||||
XCTAssertEqualObjects(destination2.data, source3.data);
|
||||
}
|
||||
|
||||
- (void)testClearMessage {
|
||||
TestEmptyMessage* message = [TestEmptyMessage message];
|
||||
[message mergeFrom:emptyMessage_];
|
||||
[message clear];
|
||||
XCTAssertEqual(message.serializedSize, (size_t)0);
|
||||
}
|
||||
|
||||
- (void)testParseKnownAndUnknown {
|
||||
// Test mixing known and unknown fields when parsing.
|
||||
GPBUnknownFieldSet* fields = [[unknownFields_ copy] autorelease];
|
||||
GPBUnknownField* field = [[[GPBUnknownField alloc] initWithNumber:123456] autorelease];
|
||||
[field addVarint:654321];
|
||||
[fields addField:field];
|
||||
|
||||
NSData* data = fields.data;
|
||||
TestAllTypes* destination = [TestAllTypes parseFromData:data error:NULL];
|
||||
|
||||
[self assertAllFieldsSet:destination repeatedCount:kGPBDefaultRepeatCount];
|
||||
XCTAssertEqual(destination.unknownFields.countOfFields, (NSUInteger)1);
|
||||
|
||||
GPBUnknownField* field2 = [destination.unknownFields getField:123456];
|
||||
XCTAssertEqual(field2.varintList.count, (NSUInteger)1);
|
||||
XCTAssertEqual(654321ULL, [field2.varintList valueAtIndex:0]);
|
||||
}
|
||||
|
||||
- (void)testWrongTypeTreatedAsUnknown {
|
||||
// Test that fields of the wrong wire type are treated like unknown fields
|
||||
// when parsing.
|
||||
|
||||
NSData* bizarroData = [self getBizarroData];
|
||||
TestAllTypes* allTypesMessage = [TestAllTypes parseFromData:bizarroData error:NULL];
|
||||
TestEmptyMessage* emptyMessage = [TestEmptyMessage parseFromData:bizarroData error:NULL];
|
||||
|
||||
// All fields should have been interpreted as unknown, so the debug strings
|
||||
// should be the same.
|
||||
XCTAssertEqualObjects(emptyMessage.data, allTypesMessage.data);
|
||||
}
|
||||
|
||||
- (void)testUnknownExtensions {
|
||||
// Make sure fields are properly parsed to the UnknownFieldSet even when
|
||||
// they are declared as extension numbers.
|
||||
|
||||
TestEmptyMessageWithExtensions* message =
|
||||
[TestEmptyMessageWithExtensions parseFromData:allFieldsData_ error:NULL];
|
||||
|
||||
XCTAssertEqual(unknownFields_.countOfFields, message.unknownFields.countOfFields);
|
||||
XCTAssertEqualObjects(allFieldsData_, message.data);
|
||||
}
|
||||
|
||||
- (void)testWrongExtensionTypeTreatedAsUnknown {
|
||||
// Test that fields of the wrong wire type are treated like unknown fields
|
||||
// when parsing extensions.
|
||||
|
||||
NSData* bizarroData = [self getBizarroData];
|
||||
TestAllExtensions* allExtensionsMessage = [TestAllExtensions parseFromData:bizarroData
|
||||
error:NULL];
|
||||
TestEmptyMessage* emptyMessage = [TestEmptyMessage parseFromData:bizarroData error:NULL];
|
||||
|
||||
// All fields should have been interpreted as unknown, so the debug strings
|
||||
// should be the same.
|
||||
XCTAssertEqualObjects(emptyMessage.data, allExtensionsMessage.data);
|
||||
}
|
||||
|
||||
- (void)testLargeVarint {
|
||||
GPBUnknownFieldSet* fields = [[unknownFields_ copy] autorelease];
|
||||
GPBUnknownField* field = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
[field addVarint:0x7FFFFFFFFFFFFFFFL];
|
||||
[fields addField:field];
|
||||
|
||||
NSData* data = [fields data];
|
||||
|
||||
GPBUnknownFieldSet* parsed = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
[parsed mergeFromData:data];
|
||||
GPBUnknownField* field2 = [parsed getField:1];
|
||||
XCTAssertEqual(field2.varintList.count, (NSUInteger)1);
|
||||
XCTAssertEqual(0x7FFFFFFFFFFFFFFFULL, [field2.varintList valueAtIndex:0]);
|
||||
}
|
||||
|
||||
#pragma mark - Field tests
|
||||
// Some tests directly on fields since the dictionary in FieldSet can gate
|
||||
// testing some of these.
|
||||
|
||||
- (void)testFieldEqualityAndHash {
|
||||
GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
XCTAssertTrue([field1 isEqual:field1]);
|
||||
XCTAssertFalse([field1 isEqual:@"foo"]);
|
||||
GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
|
||||
field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
|
||||
// Varint
|
||||
|
||||
[field1 addVarint:10];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addVarint:10];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
[field1 addVarint:11];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addVarint:11];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
|
||||
// Fixed32
|
||||
|
||||
[field1 addFixed32:20];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addFixed32:20];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
[field1 addFixed32:21];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addFixed32:21];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
|
||||
// Fixed64
|
||||
|
||||
[field1 addFixed64:30];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addFixed64:30];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
[field1 addFixed64:31];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addFixed64:31];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
|
||||
// LengthDelimited
|
||||
|
||||
[field1 addLengthDelimited:DataFromCStr("foo")];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addLengthDelimited:DataFromCStr("foo")];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
[field1 addLengthDelimited:DataFromCStr("bar")];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
[field2 addLengthDelimited:DataFromCStr("bar")];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
|
||||
// Group
|
||||
|
||||
GPBUnknownFieldSet* group = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup = [[[GPBUnknownField alloc] initWithNumber:100] autorelease];
|
||||
[fieldGroup addVarint:100];
|
||||
[group addField:fieldGroup];
|
||||
[field1 addGroup:group];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
group = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
fieldGroup = [[[GPBUnknownField alloc] initWithNumber:100] autorelease];
|
||||
[fieldGroup addVarint:100];
|
||||
[group addField:fieldGroup];
|
||||
[field2 addGroup:group];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
|
||||
group = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
fieldGroup = [[[GPBUnknownField alloc] initWithNumber:101] autorelease];
|
||||
[fieldGroup addVarint:101];
|
||||
[group addField:fieldGroup];
|
||||
[field1 addGroup:group];
|
||||
XCTAssertNotEqualObjects(field1, field2);
|
||||
group = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
fieldGroup = [[[GPBUnknownField alloc] initWithNumber:101] autorelease];
|
||||
[fieldGroup addVarint:101];
|
||||
[group addField:fieldGroup];
|
||||
[field2 addGroup:group];
|
||||
XCTAssertEqualObjects(field1, field2);
|
||||
XCTAssertEqual([field1 hash], [field2 hash]);
|
||||
|
||||
// Exercise description for completeness.
|
||||
XCTAssertTrue(field1.description.length > 10);
|
||||
}
|
||||
|
||||
- (void)testMergingFields {
|
||||
GPBUnknownField* field1 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
[field1 addVarint:1];
|
||||
[field1 addFixed32:2];
|
||||
[field1 addFixed64:3];
|
||||
[field1 addLengthDelimited:[NSData dataWithBytes:"hello" length:5]];
|
||||
[field1 addGroup:[[unknownFields_ copy] autorelease]];
|
||||
GPBUnknownField* field2 = [[[GPBUnknownField alloc] initWithNumber:1] autorelease];
|
||||
[field2 mergeFromField:field1];
|
||||
}
|
||||
|
||||
@end
|
||||
410
objectivec/Tests/GPBUtilitiesTests.m
Normal file
410
objectivec/Tests/GPBUtilitiesTests.m
Normal file
@@ -0,0 +1,410 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "GPBUtilities_PackagePrivate.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBDescriptor_PackagePrivate.h"
|
||||
#import "GPBMessage.h"
|
||||
#import "GPBUnknownField_PackagePrivate.h"
|
||||
|
||||
#import "objectivec/Tests/MapUnittest.pbobjc.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjc.pbobjc.h"
|
||||
|
||||
@interface UtilitiesTests : GPBTestCase
|
||||
@end
|
||||
|
||||
@implementation UtilitiesTests
|
||||
|
||||
- (void)testRightShiftFunctions {
|
||||
XCTAssertEqual((1UL << 31) >> 31, 1UL);
|
||||
XCTAssertEqual((int32_t)(1U << 31) >> 31, -1);
|
||||
XCTAssertEqual((1ULL << 63) >> 63, 1ULL);
|
||||
XCTAssertEqual((int64_t)(1ULL << 63) >> 63, -1LL);
|
||||
|
||||
XCTAssertEqual(GPBLogicalRightShift32((1U << 31), 31), 1);
|
||||
XCTAssertEqual(GPBLogicalRightShift64((1ULL << 63), 63), 1LL);
|
||||
}
|
||||
|
||||
- (void)testGPBDecodeTextFormatName {
|
||||
uint8_t decodeData[] = {
|
||||
// clang-format off
|
||||
0x6,
|
||||
// An inlined string (first to make sure the leading null is handled
|
||||
// correctly, and with a key of zero to check that).
|
||||
0x0, 0x0, 'z', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'I', 'J', 0x0,
|
||||
// All as is (00 op)
|
||||
0x1, 0x0A, 0x0,
|
||||
// Underscore, upper + 9 (10 op)
|
||||
0x3, 0xCA, 0x0,
|
||||
// Upper + 3 (10 op), underscore, upper + 5 (10 op)
|
||||
0x2, 0x44, 0xC6, 0x0,
|
||||
// All Upper for 4 (11 op), underscore, underscore, upper + 5 (10 op),
|
||||
// underscore, lower + 0 (01 op)
|
||||
0x4, 0x64, 0x80, 0xC5, 0xA1, 0x0,
|
||||
// 2 byte key: as is + 3 (00 op), underscore, lower + 4 (01 op),
|
||||
// underscore, lower + 3 (01 op), underscore, lower + 1 (01 op),
|
||||
// underscore, lower + 30 (01 op), as is + 30 (00 op), as is + 13 (00 op),
|
||||
// underscore, as is + 3 (00 op)
|
||||
0xE8, 0x07, 0x04, 0xA5, 0xA4, 0xA2, 0xBF, 0x1F, 0x0E, 0x84, 0x0,
|
||||
// clang-format on
|
||||
};
|
||||
NSString *inputStr = @"abcdefghIJ";
|
||||
|
||||
// Empty inputs
|
||||
|
||||
XCTAssertNil(GPBDecodeTextFormatName(nil, 1, NULL));
|
||||
XCTAssertNil(GPBDecodeTextFormatName(decodeData, 1, NULL));
|
||||
XCTAssertNil(GPBDecodeTextFormatName(nil, 1, inputStr));
|
||||
|
||||
// Keys not found.
|
||||
|
||||
XCTAssertNil(GPBDecodeTextFormatName(decodeData, 5, inputStr));
|
||||
XCTAssertNil(GPBDecodeTextFormatName(decodeData, -1, inputStr));
|
||||
|
||||
// Some name decodes.
|
||||
|
||||
XCTAssertEqualObjects(GPBDecodeTextFormatName(decodeData, 1, inputStr), @"abcdefghIJ");
|
||||
XCTAssertEqualObjects(GPBDecodeTextFormatName(decodeData, 2, inputStr), @"Abcd_EfghIJ");
|
||||
XCTAssertEqualObjects(GPBDecodeTextFormatName(decodeData, 3, inputStr), @"_AbcdefghIJ");
|
||||
XCTAssertEqualObjects(GPBDecodeTextFormatName(decodeData, 4, inputStr), @"ABCD__EfghI_j");
|
||||
|
||||
// An inlined string (and key of zero).
|
||||
XCTAssertEqualObjects(GPBDecodeTextFormatName(decodeData, 0, inputStr), @"zbcdefghIJ");
|
||||
|
||||
// clang-format off
|
||||
// Long name so multiple decode ops are needed.
|
||||
inputStr = @"longFieldNameIsLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1000";
|
||||
XCTAssertEqualObjects(GPBDecodeTextFormatName(decodeData, 1000, inputStr),
|
||||
@"long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_1000");
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
- (void)testTextFormat {
|
||||
TestAllTypes *message = [TestAllTypes message];
|
||||
|
||||
// Not kGPBDefaultRepeatCount because we are comparing to golden master file
|
||||
// which was generated with 2.
|
||||
[self setAllFields:message repeatedCount:2];
|
||||
|
||||
NSString *result = GPBTextFormatForMessage(message, nil);
|
||||
|
||||
NSString *fileName = @"text_format_unittest_data.txt";
|
||||
NSData *resultData = [result dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSData *expectedData = [self getDataFileNamed:fileName dataToWrite:resultData];
|
||||
NSString *expected = [[NSString alloc] initWithData:expectedData encoding:NSUTF8StringEncoding];
|
||||
XCTAssertEqualObjects(expected, result);
|
||||
[expected release];
|
||||
}
|
||||
|
||||
- (void)testTextFormatExtra {
|
||||
// -testTextFormat uses all protos with fields that don't require special
|
||||
// handing for figuring out the names. The ObjC proto has a bunch of oddball
|
||||
// field and enum names that require the decode info to get right, so this
|
||||
// confirms they generated and decoded correctly.
|
||||
|
||||
self_Class *message = [self_Class message];
|
||||
message.cmd = YES;
|
||||
message.isProxy_p = YES;
|
||||
message.subEnum = self_autorelease_RetainCount;
|
||||
message.new_p.copy_p = @"foo";
|
||||
|
||||
// clang-format off
|
||||
NSString *expected = @"_cmd: true\n"
|
||||
@"isProxy: true\n"
|
||||
@"SubEnum: retainCount\n"
|
||||
@"New {\n"
|
||||
@" copy: \"foo\"\n"
|
||||
@"}\n";
|
||||
// clang-format on
|
||||
NSString *result = GPBTextFormatForMessage(message, nil);
|
||||
XCTAssertEqualObjects(expected, result);
|
||||
}
|
||||
|
||||
- (void)testTextFormatMaps {
|
||||
TestMap *message = [TestMap message];
|
||||
|
||||
// Map iteration order doesn't have to be stable, so use only one entry.
|
||||
[self setAllMapFields:message numEntries:1];
|
||||
|
||||
NSString *result = GPBTextFormatForMessage(message, nil);
|
||||
|
||||
NSString *fileName = @"text_format_map_unittest_data.txt";
|
||||
NSData *resultData = [result dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSData *expectedData = [self getDataFileNamed:fileName dataToWrite:resultData];
|
||||
NSString *expected = [[NSString alloc] initWithData:expectedData encoding:NSUTF8StringEncoding];
|
||||
XCTAssertEqualObjects(expected, result);
|
||||
[expected release];
|
||||
}
|
||||
|
||||
- (void)testTextFormatExtensions {
|
||||
TestAllExtensions *message = [TestAllExtensions message];
|
||||
|
||||
// Not kGPBDefaultRepeatCount because we are comparing to golden master file
|
||||
// which was generated with 2.
|
||||
[self setAllExtensions:message repeatedCount:2];
|
||||
|
||||
NSString *result = GPBTextFormatForMessage(message, nil);
|
||||
|
||||
// NOTE: ObjC TextFormat doesn't have the proper extension names so it
|
||||
// uses comments for the ObjC name and raw numbers for the fields instead
|
||||
// of the bracketed extension name.
|
||||
NSString *fileName = @"text_format_extensions_unittest_data.txt";
|
||||
NSData *resultData = [result dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSData *expectedData = [self getDataFileNamed:fileName dataToWrite:resultData];
|
||||
NSString *expected = [[NSString alloc] initWithData:expectedData encoding:NSUTF8StringEncoding];
|
||||
XCTAssertEqualObjects(expected, result);
|
||||
[expected release];
|
||||
}
|
||||
|
||||
- (void)testSetRepeatedFields {
|
||||
TestAllTypes *message = [TestAllTypes message];
|
||||
|
||||
NSDictionary *repeatedFieldValues = @{
|
||||
@"repeatedStringArray" : [@[ @"foo", @"bar" ] mutableCopy],
|
||||
@"repeatedBoolArray" : [GPBBoolArray arrayWithValue:YES],
|
||||
@"repeatedInt32Array" : [GPBInt32Array arrayWithValue:14],
|
||||
@"repeatedInt64Array" : [GPBInt64Array arrayWithValue:15],
|
||||
@"repeatedUint32Array" : [GPBUInt32Array arrayWithValue:16],
|
||||
@"repeatedUint64Array" : [GPBUInt64Array arrayWithValue:16],
|
||||
@"repeatedFloatArray" : [GPBFloatArray arrayWithValue:16],
|
||||
@"repeatedDoubleArray" : [GPBDoubleArray arrayWithValue:16],
|
||||
@"repeatedNestedEnumArray" :
|
||||
[GPBEnumArray arrayWithValidationFunction:TestAllTypes_NestedEnum_IsValidValue
|
||||
rawValue:TestAllTypes_NestedEnum_Foo],
|
||||
};
|
||||
for (NSString *fieldName in repeatedFieldValues) {
|
||||
GPBFieldDescriptor *field = [message.descriptor fieldWithName:fieldName];
|
||||
XCTAssertNotNil(field, @"No field with name: %@", fieldName);
|
||||
id expectedValues = repeatedFieldValues[fieldName];
|
||||
GPBSetMessageRepeatedField(message, field, expectedValues);
|
||||
XCTAssertEqualObjects(expectedValues, [message valueForKeyPath:fieldName]);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to make an unknown field set with something in it.
|
||||
static GPBUnknownFieldSet *UnknownFieldsSetHelper(int num) {
|
||||
GPBUnknownFieldSet *result = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
|
||||
GPBUnknownField *field = [[[GPBUnknownField alloc] initWithNumber:num] autorelease];
|
||||
[field addVarint:num];
|
||||
[result addField:field];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)testDropMessageUnknownFieldsRecursively {
|
||||
TestAllExtensions *message = [TestAllExtensions message];
|
||||
|
||||
// Give it unknownFields.
|
||||
message.unknownFields = UnknownFieldsSetHelper(777);
|
||||
|
||||
// Given it extensions that include a message with unknown fields of its own.
|
||||
{
|
||||
// Int
|
||||
[message setExtension:[UnittestRoot optionalInt32Extension] value:@5];
|
||||
|
||||
// Group
|
||||
OptionalGroup_extension *optionalGroup = [OptionalGroup_extension message];
|
||||
optionalGroup.a = 123;
|
||||
optionalGroup.unknownFields = UnknownFieldsSetHelper(779);
|
||||
[message setExtension:[UnittestRoot optionalGroupExtension] value:optionalGroup];
|
||||
|
||||
// Message
|
||||
TestAllTypes_NestedMessage *nestedMessage = [TestAllTypes_NestedMessage message];
|
||||
nestedMessage.bb = 456;
|
||||
nestedMessage.unknownFields = UnknownFieldsSetHelper(778);
|
||||
[message setExtension:[UnittestRoot optionalNestedMessageExtension] value:nestedMessage];
|
||||
|
||||
// Repeated Group
|
||||
RepeatedGroup_extension *repeatedGroup = [[RepeatedGroup_extension alloc] init];
|
||||
repeatedGroup.a = 567;
|
||||
repeatedGroup.unknownFields = UnknownFieldsSetHelper(780);
|
||||
[message addExtension:[UnittestRoot repeatedGroupExtension] value:repeatedGroup];
|
||||
[repeatedGroup release];
|
||||
|
||||
// Repeated Message
|
||||
nestedMessage = [[TestAllTypes_NestedMessage alloc] init];
|
||||
nestedMessage.bb = 678;
|
||||
nestedMessage.unknownFields = UnknownFieldsSetHelper(781);
|
||||
[message addExtension:[UnittestRoot repeatedNestedMessageExtension] value:nestedMessage];
|
||||
[nestedMessage release];
|
||||
}
|
||||
|
||||
// Confirm everything is there.
|
||||
|
||||
XCTAssertNotNil(message);
|
||||
XCTAssertNotNil(message.unknownFields);
|
||||
XCTAssertTrue([message hasExtension:[UnittestRoot optionalInt32Extension]]);
|
||||
|
||||
{
|
||||
XCTAssertTrue([message hasExtension:[UnittestRoot optionalGroupExtension]]);
|
||||
OptionalGroup_extension *optionalGroup =
|
||||
[message getExtension:[UnittestRoot optionalGroupExtension]];
|
||||
XCTAssertNotNil(optionalGroup);
|
||||
XCTAssertEqual(optionalGroup.a, 123);
|
||||
XCTAssertNotNil(optionalGroup.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
XCTAssertTrue([message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
|
||||
TestAllTypes_NestedMessage *nestedMessage =
|
||||
[message getExtension:[UnittestRoot optionalNestedMessageExtension]];
|
||||
XCTAssertNotNil(nestedMessage);
|
||||
XCTAssertEqual(nestedMessage.bb, 456);
|
||||
XCTAssertNotNil(nestedMessage.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
XCTAssertTrue([message hasExtension:[UnittestRoot repeatedGroupExtension]]);
|
||||
NSArray *repeatedGroups = [message getExtension:[UnittestRoot repeatedGroupExtension]];
|
||||
XCTAssertEqual(repeatedGroups.count, (NSUInteger)1);
|
||||
RepeatedGroup_extension *repeatedGroup = repeatedGroups.firstObject;
|
||||
XCTAssertNotNil(repeatedGroup);
|
||||
XCTAssertEqual(repeatedGroup.a, 567);
|
||||
XCTAssertNotNil(repeatedGroup.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
XCTAssertTrue([message hasExtension:[UnittestRoot repeatedNestedMessageExtension]]);
|
||||
NSArray *repeatedNestedMessages =
|
||||
[message getExtension:[UnittestRoot repeatedNestedMessageExtension]];
|
||||
XCTAssertEqual(repeatedNestedMessages.count, (NSUInteger)1);
|
||||
TestAllTypes_NestedMessage *repeatedNestedMessage = repeatedNestedMessages.firstObject;
|
||||
XCTAssertNotNil(repeatedNestedMessage);
|
||||
XCTAssertEqual(repeatedNestedMessage.bb, 678);
|
||||
XCTAssertNotNil(repeatedNestedMessage.unknownFields);
|
||||
}
|
||||
|
||||
// Drop them.
|
||||
GPBMessageDropUnknownFieldsRecursively(message);
|
||||
|
||||
// Confirm unknowns are gone from within the messages.
|
||||
|
||||
XCTAssertNotNil(message);
|
||||
XCTAssertNil(message.unknownFields);
|
||||
XCTAssertTrue([message hasExtension:[UnittestRoot optionalInt32Extension]]);
|
||||
|
||||
{
|
||||
XCTAssertTrue([message hasExtension:[UnittestRoot optionalGroupExtension]]);
|
||||
OptionalGroup_extension *optionalGroup =
|
||||
[message getExtension:[UnittestRoot optionalGroupExtension]];
|
||||
XCTAssertNotNil(optionalGroup);
|
||||
XCTAssertEqual(optionalGroup.a, 123);
|
||||
XCTAssertNil(optionalGroup.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
XCTAssertTrue([message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
|
||||
TestAllTypes_NestedMessage *nestedMessage =
|
||||
[message getExtension:[UnittestRoot optionalNestedMessageExtension]];
|
||||
XCTAssertNotNil(nestedMessage);
|
||||
XCTAssertEqual(nestedMessage.bb, 456);
|
||||
XCTAssertNil(nestedMessage.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
XCTAssertTrue([message hasExtension:[UnittestRoot repeatedGroupExtension]]);
|
||||
NSArray *repeatedGroups = [message getExtension:[UnittestRoot repeatedGroupExtension]];
|
||||
XCTAssertEqual(repeatedGroups.count, (NSUInteger)1);
|
||||
RepeatedGroup_extension *repeatedGroup = repeatedGroups.firstObject;
|
||||
XCTAssertNotNil(repeatedGroup);
|
||||
XCTAssertEqual(repeatedGroup.a, 567);
|
||||
XCTAssertNil(repeatedGroup.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
XCTAssertTrue([message hasExtension:[UnittestRoot repeatedNestedMessageExtension]]);
|
||||
NSArray *repeatedNestedMessages =
|
||||
[message getExtension:[UnittestRoot repeatedNestedMessageExtension]];
|
||||
XCTAssertEqual(repeatedNestedMessages.count, (NSUInteger)1);
|
||||
TestAllTypes_NestedMessage *repeatedNestedMessage = repeatedNestedMessages.firstObject;
|
||||
XCTAssertNotNil(repeatedNestedMessage);
|
||||
XCTAssertEqual(repeatedNestedMessage.bb, 678);
|
||||
XCTAssertNil(repeatedNestedMessage.unknownFields);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testDropMessageUnknownFieldsRecursively_Maps {
|
||||
TestMap *message = [TestMap message];
|
||||
|
||||
{
|
||||
ForeignMessage *foreignMessage = [ForeignMessage message];
|
||||
foreignMessage.unknownFields = UnknownFieldsSetHelper(100);
|
||||
[message.mapInt32ForeignMessage setObject:foreignMessage forKey:100];
|
||||
|
||||
foreignMessage = [ForeignMessage message];
|
||||
foreignMessage.unknownFields = UnknownFieldsSetHelper(101);
|
||||
[message.mapStringForeignMessage setObject:foreignMessage forKey:@"101"];
|
||||
}
|
||||
|
||||
// Confirm everything is there.
|
||||
|
||||
XCTAssertNotNil(message);
|
||||
|
||||
{
|
||||
ForeignMessage *foreignMessage = [message.mapInt32ForeignMessage objectForKey:100];
|
||||
XCTAssertNotNil(foreignMessage);
|
||||
XCTAssertNotNil(foreignMessage.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
ForeignMessage *foreignMessage = [message.mapStringForeignMessage objectForKey:@"101"];
|
||||
XCTAssertNotNil(foreignMessage);
|
||||
XCTAssertNotNil(foreignMessage.unknownFields);
|
||||
}
|
||||
|
||||
GPBMessageDropUnknownFieldsRecursively(message);
|
||||
|
||||
// Confirm unknowns are gone from within the messages.
|
||||
|
||||
XCTAssertNotNil(message);
|
||||
|
||||
{
|
||||
ForeignMessage *foreignMessage = [message.mapInt32ForeignMessage objectForKey:100];
|
||||
XCTAssertNotNil(foreignMessage);
|
||||
XCTAssertNil(foreignMessage.unknownFields);
|
||||
}
|
||||
|
||||
{
|
||||
ForeignMessage *foreignMessage = [message.mapStringForeignMessage objectForKey:@"101"];
|
||||
XCTAssertNotNil(foreignMessage);
|
||||
XCTAssertNil(foreignMessage.unknownFields);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
187
objectivec/Tests/GPBWellKnownTypesTest.m
Normal file
187
objectivec/Tests/GPBWellKnownTypesTest.m
Normal file
@@ -0,0 +1,187 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBWellKnownTypes.h"
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
#import "objectivec/Tests/AnyTest.pbobjc.h"
|
||||
|
||||
// Nanosecond time accuracy
|
||||
static const NSTimeInterval kTimeAccuracy = 1e-9;
|
||||
|
||||
@interface WellKnownTypesTest : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation WellKnownTypesTest
|
||||
|
||||
- (void)testTimeStamp {
|
||||
// Test negative and positive values.
|
||||
NSTimeInterval values[] = {
|
||||
-428027599.483999967, -1234567.0, -0.5, 0, 0.75, 54321.0, 2468086, 483999967};
|
||||
for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
|
||||
NSTimeInterval value = values[i];
|
||||
|
||||
// Test Creation - date.
|
||||
NSDate *date = [NSDate dateWithTimeIntervalSince1970:value];
|
||||
GPBTimestamp *timeStamp = [[GPBTimestamp alloc] initWithDate:date];
|
||||
|
||||
XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0, @"Offset %f - Date: %@", (double)value, date);
|
||||
XCTAssertLessThan(timeStamp.nanos, 1e9, @"Offset %f - Date: %@", (double)value, date);
|
||||
|
||||
// Comparing timeIntervals instead of directly comparing dates because date
|
||||
// equality requires the time intervals to be exactly the same, and the
|
||||
// timeintervals go through a bit of floating point error as they are
|
||||
// converted back and forth from the internal representation.
|
||||
XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970, kTimeAccuracy,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
[timeStamp release];
|
||||
|
||||
// Test Creation - timeIntervalSince1970.
|
||||
timeStamp = [[GPBTimestamp alloc] initWithTimeIntervalSince1970:value];
|
||||
|
||||
XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0, @"Offset %f - Date: %@", (double)value, date);
|
||||
XCTAssertLessThan(timeStamp.nanos, 1e9, @"Offset %f - Date: %@", (double)value, date);
|
||||
|
||||
XCTAssertEqualWithAccuracy(value, timeStamp.timeIntervalSince1970, kTimeAccuracy,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
[timeStamp release];
|
||||
|
||||
// Test Mutation - date.
|
||||
timeStamp = [[GPBTimestamp alloc] init];
|
||||
timeStamp.date = date;
|
||||
|
||||
XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0, @"Offset %f - Date: %@", (double)value, date);
|
||||
XCTAssertLessThan(timeStamp.nanos, 1e9, @"Offset %f - Date: %@", (double)value, date);
|
||||
|
||||
XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970, kTimeAccuracy,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
[timeStamp release];
|
||||
|
||||
// Test Mutation - timeIntervalSince1970.
|
||||
timeStamp = [[GPBTimestamp alloc] init];
|
||||
timeStamp.timeIntervalSince1970 = value;
|
||||
|
||||
XCTAssertGreaterThanOrEqual(timeStamp.nanos, 0, @"Offset %f - Date: %@", (double)value, date);
|
||||
XCTAssertLessThan(timeStamp.nanos, 1e9, @"Offset %f - Date: %@", (double)value, date);
|
||||
|
||||
XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970, kTimeAccuracy,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
|
||||
[timeStamp release];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testDuration {
|
||||
// Test negative and positive values.
|
||||
NSTimeInterval values[] = {-1000.0001, -500.0, -0.5, 0, 0.75, 1000.0, 2000.0002};
|
||||
for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
|
||||
NSTimeInterval value = values[i];
|
||||
|
||||
// Test Creation.
|
||||
GPBDuration *duration = [[GPBDuration alloc] initWithTimeInterval:value];
|
||||
XCTAssertEqualWithAccuracy(value, duration.timeInterval, kTimeAccuracy, @"For interval %f",
|
||||
(double)value);
|
||||
if (value > 0) {
|
||||
XCTAssertGreaterThanOrEqual(duration.seconds, 0, @"For interval %f", (double)value);
|
||||
XCTAssertGreaterThanOrEqual(duration.nanos, 0, @"For interval %f", (double)value);
|
||||
} else {
|
||||
XCTAssertLessThanOrEqual(duration.seconds, 0, @"For interval %f", (double)value);
|
||||
XCTAssertLessThanOrEqual(duration.nanos, 0, @"For interval %f", (double)value);
|
||||
}
|
||||
[duration release];
|
||||
|
||||
// Test Mutation.
|
||||
duration = [[GPBDuration alloc] init];
|
||||
duration.timeInterval = value;
|
||||
XCTAssertEqualWithAccuracy(value, duration.timeInterval, kTimeAccuracy, @"For interval %f",
|
||||
(double)value);
|
||||
if (value > 0) {
|
||||
XCTAssertGreaterThanOrEqual(duration.seconds, 0, @"For interval %f", (double)value);
|
||||
XCTAssertGreaterThanOrEqual(duration.nanos, 0, @"For interval %f", (double)value);
|
||||
} else {
|
||||
XCTAssertLessThanOrEqual(duration.seconds, 0, @"For interval %f", (double)value);
|
||||
XCTAssertLessThanOrEqual(duration.nanos, 0, @"For interval %f", (double)value);
|
||||
}
|
||||
[duration release];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testAnyHelpers {
|
||||
// Set and extract covers most of the code.
|
||||
|
||||
AnyTestMessage *subMessage = [AnyTestMessage message];
|
||||
subMessage.int32Value = 12345;
|
||||
AnyTestMessage *message = [AnyTestMessage message];
|
||||
NSError *err = nil;
|
||||
message.anyValue = [GPBAny anyWithMessage:subMessage error:&err];
|
||||
XCTAssertNil(err);
|
||||
|
||||
NSData *data = message.data;
|
||||
XCTAssertNotNil(data);
|
||||
|
||||
AnyTestMessage *message2 = [AnyTestMessage parseFromData:data error:&err];
|
||||
XCTAssertNil(err);
|
||||
XCTAssertNotNil(message2);
|
||||
XCTAssertTrue(message2.hasAnyValue);
|
||||
|
||||
AnyTestMessage *subMessage2 =
|
||||
(AnyTestMessage *)[message.anyValue unpackMessageClass:[AnyTestMessage class] error:&err];
|
||||
XCTAssertNil(err);
|
||||
XCTAssertNotNil(subMessage2);
|
||||
XCTAssertEqual(subMessage2.int32Value, 12345);
|
||||
|
||||
// NULL errorPtr in the two calls.
|
||||
|
||||
message.anyValue = [GPBAny anyWithMessage:subMessage error:NULL];
|
||||
NSData *data2 = message.data;
|
||||
XCTAssertEqualObjects(data2, data);
|
||||
|
||||
AnyTestMessage *subMessage3 =
|
||||
(AnyTestMessage *)[message.anyValue unpackMessageClass:[AnyTestMessage class] error:NULL];
|
||||
XCTAssertNotNil(subMessage3);
|
||||
XCTAssertEqualObjects(subMessage2, subMessage3);
|
||||
|
||||
// Try to extract wrong type.
|
||||
|
||||
GPBTimestamp *wrongMessage =
|
||||
(GPBTimestamp *)[message.anyValue unpackMessageClass:[GPBTimestamp class] error:&err];
|
||||
XCTAssertNotNil(err);
|
||||
XCTAssertNil(wrongMessage);
|
||||
XCTAssertEqualObjects(err.domain, GPBWellKnownTypesErrorDomain);
|
||||
XCTAssertEqual(err.code, GPBWellKnownTypesErrorCodeTypeURLMismatch);
|
||||
|
||||
wrongMessage = (GPBTimestamp *)[message.anyValue unpackMessageClass:[GPBTimestamp class]
|
||||
error:NULL];
|
||||
XCTAssertNil(wrongMessage);
|
||||
}
|
||||
|
||||
@end
|
||||
238
objectivec/Tests/GPBWireFormatTests.m
Normal file
238
objectivec/Tests/GPBWireFormatTests.m
Normal file
@@ -0,0 +1,238 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import "GPBCodedInputStream.h"
|
||||
#import "GPBMessage_PackagePrivate.h"
|
||||
#import "GPBUnknownField_PackagePrivate.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestMset.pbobjc.h"
|
||||
|
||||
@interface WireFormatTests : GPBTestCase
|
||||
@end
|
||||
|
||||
@implementation WireFormatTests
|
||||
|
||||
- (void)testSerialization {
|
||||
TestAllTypes* message = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
|
||||
NSData* rawBytes = message.data;
|
||||
[self assertFieldsInOrder:rawBytes];
|
||||
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
|
||||
|
||||
TestAllTypes* message2 = [TestAllTypes parseFromData:rawBytes error:NULL];
|
||||
|
||||
[self assertAllFieldsSet:message2 repeatedCount:kGPBDefaultRepeatCount];
|
||||
}
|
||||
|
||||
- (void)testSerializationPacked {
|
||||
TestPackedTypes* message = [self packedSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
|
||||
NSData* rawBytes = message.data;
|
||||
[self assertFieldsInOrder:rawBytes];
|
||||
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
|
||||
|
||||
TestPackedTypes* message2 = [TestPackedTypes parseFromData:rawBytes error:NULL];
|
||||
|
||||
[self assertPackedFieldsSet:message2 repeatedCount:kGPBDefaultRepeatCount];
|
||||
}
|
||||
|
||||
- (void)testSerializeExtensions {
|
||||
// TestAllTypes and TestAllExtensions should have compatible wire formats,
|
||||
// so if we serealize a TestAllExtensions then parse it as TestAllTypes
|
||||
// it should work.
|
||||
|
||||
TestAllExtensions* message = [self allExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
NSData* rawBytes = message.data;
|
||||
[self assertFieldsInOrder:rawBytes];
|
||||
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
|
||||
|
||||
TestAllTypes* message2 = [TestAllTypes parseFromData:rawBytes error:NULL];
|
||||
|
||||
[self assertAllFieldsSet:message2 repeatedCount:kGPBDefaultRepeatCount];
|
||||
}
|
||||
|
||||
- (void)testSerializePackedExtensions {
|
||||
// TestPackedTypes and TestPackedExtensions should have compatible wire
|
||||
// formats; check that they serialize to the same string.
|
||||
TestPackedExtensions* message = [self packedExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
NSData* rawBytes = message.data;
|
||||
[self assertFieldsInOrder:rawBytes];
|
||||
|
||||
TestPackedTypes* message2 = [self packedSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
NSData* rawBytes2 = message2.data;
|
||||
|
||||
XCTAssertEqualObjects(rawBytes, rawBytes2);
|
||||
}
|
||||
|
||||
- (void)testParseExtensions {
|
||||
// TestAllTypes and TestAllExtensions should have compatible wire formats,
|
||||
// so if we serialize a TestAllTypes then parse it as TestAllExtensions
|
||||
// it should work.
|
||||
|
||||
TestAllTypes* message = [self allSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
NSData* rawBytes = message.data;
|
||||
[self assertFieldsInOrder:rawBytes];
|
||||
|
||||
GPBExtensionRegistry* registry = [self extensionRegistry];
|
||||
|
||||
TestAllExtensions* message2 = [TestAllExtensions parseFromData:rawBytes
|
||||
extensionRegistry:registry
|
||||
error:NULL];
|
||||
|
||||
[self assertAllExtensionsSet:message2 repeatedCount:kGPBDefaultRepeatCount];
|
||||
}
|
||||
|
||||
- (void)testExtensionsSerializedSize {
|
||||
size_t allSet = [self allSetRepeatedCount:kGPBDefaultRepeatCount].serializedSize;
|
||||
size_t extensionSet = [self allExtensionsSetRepeatedCount:kGPBDefaultRepeatCount].serializedSize;
|
||||
XCTAssertEqual(allSet, extensionSet);
|
||||
}
|
||||
|
||||
- (void)testParsePackedExtensions {
|
||||
// Ensure that packed extensions can be properly parsed.
|
||||
TestPackedExtensions* message = [self packedExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
NSData* rawBytes = message.data;
|
||||
[self assertFieldsInOrder:rawBytes];
|
||||
|
||||
GPBExtensionRegistry* registry = [self extensionRegistry];
|
||||
|
||||
TestPackedExtensions* message2 = [TestPackedExtensions parseFromData:rawBytes
|
||||
extensionRegistry:registry
|
||||
error:NULL];
|
||||
|
||||
[self assertPackedExtensionsSet:message2 repeatedCount:kGPBDefaultRepeatCount];
|
||||
}
|
||||
|
||||
const int kUnknownTypeId = 1550055;
|
||||
|
||||
- (void)testSerializeMessageSet {
|
||||
// Set up a MSetMessage with two known messages and an unknown one.
|
||||
MSetMessage* message_set = [MSetMessage message];
|
||||
[[message_set getExtension:[MSetMessageExtension1 messageSetExtension]] setI:123];
|
||||
[[message_set getExtension:[MSetMessageExtension2 messageSetExtension]] setStr:@"foo"];
|
||||
GPBUnknownField* unknownField =
|
||||
[[[GPBUnknownField alloc] initWithNumber:kUnknownTypeId] autorelease];
|
||||
[unknownField addLengthDelimited:[NSData dataWithBytes:"bar" length:3]];
|
||||
GPBUnknownFieldSet* unknownFieldSet = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
[unknownFieldSet addField:unknownField];
|
||||
[message_set setUnknownFields:unknownFieldSet];
|
||||
|
||||
NSData* data = [message_set data];
|
||||
|
||||
// Parse back using MSetRawMessageSet and check the contents.
|
||||
MSetRawMessageSet* raw = [MSetRawMessageSet parseFromData:data error:NULL];
|
||||
|
||||
XCTAssertEqual([raw.unknownFields countOfFields], (NSUInteger)0);
|
||||
|
||||
XCTAssertEqual(raw.itemArray.count, (NSUInteger)3);
|
||||
XCTAssertEqual((uint32_t)[raw.itemArray[0] typeId],
|
||||
[MSetMessageExtension1 messageSetExtension].fieldNumber);
|
||||
XCTAssertEqual((uint32_t)[raw.itemArray[1] typeId],
|
||||
[MSetMessageExtension2 messageSetExtension].fieldNumber);
|
||||
XCTAssertEqual([raw.itemArray[2] typeId], kUnknownTypeId);
|
||||
|
||||
MSetMessageExtension1* message1 =
|
||||
[MSetMessageExtension1 parseFromData:[((MSetRawMessageSet_Item*)raw.itemArray[0]) message]
|
||||
error:NULL];
|
||||
XCTAssertEqual(message1.i, 123);
|
||||
|
||||
MSetMessageExtension2* message2 =
|
||||
[MSetMessageExtension2 parseFromData:[((MSetRawMessageSet_Item*)raw.itemArray[1]) message]
|
||||
error:NULL];
|
||||
XCTAssertEqualObjects(message2.str, @"foo");
|
||||
|
||||
XCTAssertEqualObjects([raw.itemArray[2] message], [NSData dataWithBytes:"bar" length:3]);
|
||||
}
|
||||
|
||||
- (void)testParseMessageSet {
|
||||
// Set up a MSetRawMessageSet with two known messages and an unknown one.
|
||||
MSetRawMessageSet* raw = [MSetRawMessageSet message];
|
||||
|
||||
{
|
||||
MSetRawMessageSet_Item* item = [MSetRawMessageSet_Item message];
|
||||
item.typeId = [MSetMessageExtension1 messageSetExtension].fieldNumber;
|
||||
MSetMessageExtension1* message = [MSetMessageExtension1 message];
|
||||
message.i = 123;
|
||||
item.message = [message data];
|
||||
[raw.itemArray addObject:item];
|
||||
}
|
||||
|
||||
{
|
||||
MSetRawMessageSet_Item* item = [MSetRawMessageSet_Item message];
|
||||
item.typeId = [MSetMessageExtension2 messageSetExtension].fieldNumber;
|
||||
MSetMessageExtension2* message = [MSetMessageExtension2 message];
|
||||
message.str = @"foo";
|
||||
item.message = [message data];
|
||||
[raw.itemArray addObject:item];
|
||||
}
|
||||
|
||||
{
|
||||
MSetRawMessageSet_Item* item = [MSetRawMessageSet_Item message];
|
||||
item.typeId = kUnknownTypeId;
|
||||
item.message = [NSData dataWithBytes:"bar" length:3];
|
||||
[raw.itemArray addObject:item];
|
||||
}
|
||||
|
||||
NSData* data = [raw data];
|
||||
|
||||
// Parse as a MSetMessage and check the contents.
|
||||
MSetMessage* messageSet = [MSetMessage parseFromData:data
|
||||
extensionRegistry:[MSetUnittestMsetRoot extensionRegistry]
|
||||
error:NULL];
|
||||
|
||||
XCTAssertEqual([[messageSet getExtension:[MSetMessageExtension1 messageSetExtension]] i], 123);
|
||||
XCTAssertEqualObjects([[messageSet getExtension:[MSetMessageExtension2 messageSetExtension]] str],
|
||||
@"foo");
|
||||
|
||||
XCTAssertEqual([messageSet.unknownFields countOfFields], (NSUInteger)1);
|
||||
GPBUnknownField* unknownField = [messageSet.unknownFields getField:kUnknownTypeId];
|
||||
XCTAssertNotNil(unknownField);
|
||||
XCTAssertEqual(unknownField.lengthDelimitedList.count, (NSUInteger)1);
|
||||
XCTAssertEqualObjects(unknownField.lengthDelimitedList[0], [NSData dataWithBytes:"bar" length:3]);
|
||||
}
|
||||
|
||||
- (void)assertFieldsInOrder:(NSData*)data {
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
int32_t previousTag = 0;
|
||||
|
||||
while (YES) {
|
||||
int32_t tag = [input readTag];
|
||||
if (tag == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
XCTAssertGreaterThan(tag, previousTag);
|
||||
[input skipField:tag];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
7
objectivec/Tests/UnitTests-Bridging-Header.h
Normal file
7
objectivec/Tests/UnitTests-Bridging-Header.h
Normal file
@@ -0,0 +1,7 @@
|
||||
//
|
||||
// Use this file to import your target's public headers that you would like to
|
||||
// expose to Swift.
|
||||
//
|
||||
|
||||
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto3.pbobjc.h"
|
||||
20
objectivec/Tests/UnitTests-Info.plist
Normal file
20
objectivec/Tests/UnitTests-Info.plist
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
44
objectivec/Tests/any_test.proto
Normal file
44
objectivec/Tests/any_test.proto
Normal file
@@ -0,0 +1,44 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package objc.protobuf.tests.any;
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
|
||||
option objc_class_prefix = "Any";
|
||||
|
||||
message TestMessage {
|
||||
int32 int32_value = 1;
|
||||
google.protobuf.Any any_value = 2;
|
||||
repeated google.protobuf.Any repeated_any_value = 3;
|
||||
string text = 4;
|
||||
}
|
||||
12
objectivec/Tests/expected_prefixes.txt
Normal file
12
objectivec/Tests/expected_prefixes.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
objc.protobuf.tests = "" # Explicit empty prefix
|
||||
objc.protobuf.tests.any = Any
|
||||
objc.protobuf.tests.chain = Chain
|
||||
objc.protobuf.tests.cycle = Cycle
|
||||
objc.protobuf.tests.deprecated = Dep
|
||||
objc.protobuf.tests.deprecated_file = FileDep
|
||||
objc.protobuf.tests.import = Import
|
||||
objc.protobuf.tests.mset = MSet
|
||||
objc.protobuf.tests.options = GPBTEST
|
||||
objc.protobuf.tests.proto3_preserve_unknown_enum = UnknownEnums
|
||||
objc.protobuf.tests.public_import = PublicImport
|
||||
objc.protobuf.tests.startup = TestObjCStartup
|
||||
BIN
objectivec/Tests/golden_message
Normal file
BIN
objectivec/Tests/golden_message
Normal file
Binary file not shown.
BIN
objectivec/Tests/golden_packed_fields_message
Normal file
BIN
objectivec/Tests/golden_packed_fields_message
Normal file
Binary file not shown.
90
objectivec/Tests/map_proto2_unittest.proto
Normal file
90
objectivec/Tests/map_proto2_unittest.proto
Normal file
@@ -0,0 +1,90 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
import "objectivec/Tests/unittest_import.proto";
|
||||
|
||||
package objc.protobuf.tests;
|
||||
|
||||
// Explicit empty prefix, tests some validations code paths also.
|
||||
option objc_class_prefix = "";
|
||||
|
||||
enum Proto2MapEnum {
|
||||
PROTO2_MAP_ENUM_FOO = 0;
|
||||
PROTO2_MAP_ENUM_BAR = 1;
|
||||
PROTO2_MAP_ENUM_BAZ = 2;
|
||||
}
|
||||
|
||||
enum Proto2MapEnumPlusExtra {
|
||||
E_PROTO2_MAP_ENUM_FOO = 0;
|
||||
E_PROTO2_MAP_ENUM_BAR = 1;
|
||||
E_PROTO2_MAP_ENUM_BAZ = 2;
|
||||
E_PROTO2_MAP_ENUM_EXTRA = 3;
|
||||
}
|
||||
|
||||
message TestEnumMap {
|
||||
map<int32, Proto2MapEnum> known_map_field = 101;
|
||||
map<int32, Proto2MapEnum> unknown_map_field = 102;
|
||||
}
|
||||
|
||||
message TestEnumMapPlusExtra {
|
||||
map<int32, Proto2MapEnumPlusExtra> known_map_field = 101;
|
||||
map<int32, Proto2MapEnumPlusExtra> unknown_map_field = 102;
|
||||
}
|
||||
|
||||
message TestImportEnumMap {
|
||||
map<int32, objc.protobuf.tests.import.EnumForMap> import_enum_amp = 1;
|
||||
}
|
||||
|
||||
message TestIntIntMap {
|
||||
map<int32, int32> m = 1;
|
||||
}
|
||||
|
||||
// Test all key types: string, plus the non-floating-point scalars.
|
||||
message TestMaps {
|
||||
map<int32, TestIntIntMap> m_int32 = 1;
|
||||
map<int64, TestIntIntMap> m_int64 = 2;
|
||||
map<uint32, TestIntIntMap> m_uint32 = 3;
|
||||
map<uint64, TestIntIntMap> m_uint64 = 4;
|
||||
map<sint32, TestIntIntMap> m_sint32 = 5;
|
||||
map<sint64, TestIntIntMap> m_sint64 = 6;
|
||||
map<fixed32, TestIntIntMap> m_fixed32 = 7;
|
||||
map<fixed64, TestIntIntMap> m_fixed64 = 8;
|
||||
map<sfixed32, TestIntIntMap> m_sfixed32 = 9;
|
||||
map<sfixed64, TestIntIntMap> m_sfixed64 = 10;
|
||||
map<bool, TestIntIntMap> m_bool = 11;
|
||||
map<string, TestIntIntMap> m_string = 12;
|
||||
}
|
||||
|
||||
// Test maps in submessages.
|
||||
message TestSubmessageMaps {
|
||||
optional TestMaps m = 1;
|
||||
}
|
||||
123
objectivec/Tests/map_unittest.proto
Normal file
123
objectivec/Tests/map_unittest.proto
Normal file
@@ -0,0 +1,123 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
import "objectivec/Tests/unittest.proto";
|
||||
|
||||
package objc.protobuf.tests;
|
||||
|
||||
// Explicit empty prefix, tests some validations code paths also.
|
||||
option objc_class_prefix = "";
|
||||
|
||||
// Tests maps.
|
||||
message TestMap {
|
||||
map<int32, int32> map_int32_int32 = 1;
|
||||
map<int64, int64> map_int64_int64 = 2;
|
||||
map<uint32, uint32> map_uint32_uint32 = 3;
|
||||
map<uint64, uint64> map_uint64_uint64 = 4;
|
||||
map<sint32, sint32> map_sint32_sint32 = 5;
|
||||
map<sint64, sint64> map_sint64_sint64 = 6;
|
||||
map<fixed32, fixed32> map_fixed32_fixed32 = 7;
|
||||
map<fixed64, fixed64> map_fixed64_fixed64 = 8;
|
||||
map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
|
||||
map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
|
||||
map<int32, float> map_int32_float = 11;
|
||||
map<int32, double> map_int32_double = 12;
|
||||
map<bool, bool> map_bool_bool = 13;
|
||||
map<string, string> map_string_string = 14;
|
||||
map<int32, bytes> map_int32_bytes = 15;
|
||||
map<int32, MapEnum> map_int32_enum = 16;
|
||||
map<int32, ForeignMessage> map_int32_foreign_message = 17;
|
||||
map<string, ForeignMessage> map_string_foreign_message = 18;
|
||||
map<int32, TestAllTypes> map_int32_all_types = 19;
|
||||
}
|
||||
|
||||
message TestMapSubmessage {
|
||||
TestMap test_map = 1;
|
||||
}
|
||||
|
||||
message TestMessageMap {
|
||||
map<int32, TestAllTypes> map_int32_message = 1;
|
||||
}
|
||||
|
||||
// Two map fields share the same entry default instance.
|
||||
message TestSameTypeMap {
|
||||
map<int32, int32> map1 = 1;
|
||||
map<int32, int32> map2 = 2;
|
||||
}
|
||||
|
||||
|
||||
enum MapEnum {
|
||||
MAP_ENUM_FOO = 0;
|
||||
MAP_ENUM_BAR = 1;
|
||||
MAP_ENUM_BAZ = 2;
|
||||
}
|
||||
|
||||
// Test embedded message with required fields
|
||||
message TestRequiredMessageMap {
|
||||
map<int32, TestRequired> map_field = 1;
|
||||
}
|
||||
|
||||
message TestArenaMap {
|
||||
map<int32, int32> map_int32_int32 = 1;
|
||||
map<int64, int64> map_int64_int64 = 2;
|
||||
map<uint32, uint32> map_uint32_uint32 = 3;
|
||||
map<uint64, uint64> map_uint64_uint64 = 4;
|
||||
map<sint32, sint32> map_sint32_sint32 = 5;
|
||||
map<sint64, sint64> map_sint64_sint64 = 6;
|
||||
map<fixed32, fixed32> map_fixed32_fixed32 = 7;
|
||||
map<fixed64, fixed64> map_fixed64_fixed64 = 8;
|
||||
map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
|
||||
map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
|
||||
map<int32, float> map_int32_float = 11;
|
||||
map<int32, double> map_int32_double = 12;
|
||||
map<bool, bool> map_bool_bool = 13;
|
||||
map<string, string> map_string_string = 14;
|
||||
map<int32, bytes> map_int32_bytes = 15;
|
||||
map<int32, MapEnum> map_int32_enum = 16;
|
||||
map<int32, ForeignMessage> map_int32_foreign_message = 17;
|
||||
}
|
||||
|
||||
// Previously, message containing enum called Type cannot be used as value of
|
||||
// map field.
|
||||
message MessageContainingEnumCalledType {
|
||||
enum Type { TYPE_FOO = 0; }
|
||||
map<string, MessageContainingEnumCalledType> type = 1;
|
||||
}
|
||||
|
||||
// Previously, message cannot contain map field called "entry".
|
||||
message MessageContainingMapCalledEntry {
|
||||
map<int32, int32> entry = 1;
|
||||
}
|
||||
|
||||
message TestRecursiveMapMessage {
|
||||
map<string, TestRecursiveMapMessage> a = 1;
|
||||
}
|
||||
140
objectivec/Tests/text_format_extensions_unittest_data.txt
Normal file
140
objectivec/Tests/text_format_extensions_unittest_data.txt
Normal file
@@ -0,0 +1,140 @@
|
||||
1: 101 # [UnittestRoot_optionalInt32Extension]
|
||||
2: 102 # [UnittestRoot_optionalInt64Extension]
|
||||
3: 103 # [UnittestRoot_optionalUint32Extension]
|
||||
4: 104 # [UnittestRoot_optionalUint64Extension]
|
||||
5: 105 # [UnittestRoot_optionalSint32Extension]
|
||||
6: 106 # [UnittestRoot_optionalSint64Extension]
|
||||
7: 107 # [UnittestRoot_optionalFixed32Extension]
|
||||
8: 108 # [UnittestRoot_optionalFixed64Extension]
|
||||
9: 109 # [UnittestRoot_optionalSfixed32Extension]
|
||||
10: 110 # [UnittestRoot_optionalSfixed64Extension]
|
||||
11: 111 # [UnittestRoot_optionalFloatExtension]
|
||||
12: 112 # [UnittestRoot_optionalDoubleExtension]
|
||||
13: true # [UnittestRoot_optionalBoolExtension]
|
||||
14: "115" # [UnittestRoot_optionalStringExtension]
|
||||
15: "\001\000\002\003\000\005" # [UnittestRoot_optionalBytesExtension]
|
||||
16 { # [UnittestRoot_optionalGroupExtension]
|
||||
a: 117
|
||||
}
|
||||
18 { # [UnittestRoot_optionalNestedMessageExtension]
|
||||
bb: 118
|
||||
}
|
||||
19 { # [UnittestRoot_optionalForeignMessageExtension]
|
||||
c: 119
|
||||
}
|
||||
20 { # [UnittestRoot_optionalImportMessageExtension]
|
||||
d: 120
|
||||
}
|
||||
21: 3 # [UnittestRoot_optionalNestedEnumExtension]
|
||||
22: 6 # [UnittestRoot_optionalForeignEnumExtension]
|
||||
23: 9 # [UnittestRoot_optionalImportEnumExtension]
|
||||
24: "124" # [UnittestRoot_optionalStringPieceExtension]
|
||||
25: "125" # [UnittestRoot_optionalCordExtension]
|
||||
# [UnittestRoot_repeatedInt32Extension]
|
||||
31: 201
|
||||
31: 301
|
||||
# [UnittestRoot_repeatedInt64Extension]
|
||||
32: 202
|
||||
32: 302
|
||||
# [UnittestRoot_repeatedUint32Extension]
|
||||
33: 203
|
||||
33: 303
|
||||
# [UnittestRoot_repeatedUint64Extension]
|
||||
34: 204
|
||||
34: 304
|
||||
# [UnittestRoot_repeatedSint32Extension]
|
||||
35: 205
|
||||
35: 305
|
||||
# [UnittestRoot_repeatedSint64Extension]
|
||||
36: 206
|
||||
36: 306
|
||||
# [UnittestRoot_repeatedFixed32Extension]
|
||||
37: 207
|
||||
37: 307
|
||||
# [UnittestRoot_repeatedFixed64Extension]
|
||||
38: 208
|
||||
38: 308
|
||||
# [UnittestRoot_repeatedSfixed32Extension]
|
||||
39: 209
|
||||
39: 309
|
||||
# [UnittestRoot_repeatedSfixed64Extension]
|
||||
40: 210
|
||||
40: 310
|
||||
# [UnittestRoot_repeatedFloatExtension]
|
||||
41: 211
|
||||
41: 311
|
||||
# [UnittestRoot_repeatedDoubleExtension]
|
||||
42: 212
|
||||
42: 312
|
||||
# [UnittestRoot_repeatedBoolExtension]
|
||||
43: false
|
||||
43: true
|
||||
# [UnittestRoot_repeatedStringExtension]
|
||||
44: "215"
|
||||
44: "315"
|
||||
# [UnittestRoot_repeatedBytesExtension]
|
||||
45: "\330\000\000\000"
|
||||
45: "<\001\000\000"
|
||||
# [UnittestRoot_repeatedGroupExtension]
|
||||
46 {
|
||||
a: 217
|
||||
}
|
||||
46 {
|
||||
a: 317
|
||||
}
|
||||
# [UnittestRoot_repeatedNestedMessageExtension]
|
||||
48 {
|
||||
bb: 218
|
||||
}
|
||||
48 {
|
||||
bb: 318
|
||||
}
|
||||
# [UnittestRoot_repeatedForeignMessageExtension]
|
||||
49 {
|
||||
c: 219
|
||||
}
|
||||
49 {
|
||||
c: 319
|
||||
}
|
||||
# [UnittestRoot_repeatedImportMessageExtension]
|
||||
50 {
|
||||
d: 220
|
||||
}
|
||||
50 {
|
||||
d: 320
|
||||
}
|
||||
# [UnittestRoot_repeatedNestedEnumExtension]
|
||||
51: 3
|
||||
51: 2
|
||||
# [UnittestRoot_repeatedForeignEnumExtension]
|
||||
52: 6
|
||||
52: 5
|
||||
# [UnittestRoot_repeatedImportEnumExtension]
|
||||
53: 9
|
||||
53: 8
|
||||
# [UnittestRoot_repeatedStringPieceExtension]
|
||||
54: "224"
|
||||
54: "324"
|
||||
# [UnittestRoot_repeatedCordExtension]
|
||||
55: "225"
|
||||
55: "325"
|
||||
61: 401 # [UnittestRoot_defaultInt32Extension]
|
||||
62: 402 # [UnittestRoot_defaultInt64Extension]
|
||||
63: 403 # [UnittestRoot_defaultUint32Extension]
|
||||
64: 404 # [UnittestRoot_defaultUint64Extension]
|
||||
65: 405 # [UnittestRoot_defaultSint32Extension]
|
||||
66: 406 # [UnittestRoot_defaultSint64Extension]
|
||||
67: 407 # [UnittestRoot_defaultFixed32Extension]
|
||||
68: 408 # [UnittestRoot_defaultFixed64Extension]
|
||||
69: 409 # [UnittestRoot_defaultSfixed32Extension]
|
||||
70: 410 # [UnittestRoot_defaultSfixed64Extension]
|
||||
71: 411 # [UnittestRoot_defaultFloatExtension]
|
||||
72: 412 # [UnittestRoot_defaultDoubleExtension]
|
||||
73: false # [UnittestRoot_defaultBoolExtension]
|
||||
74: "415" # [UnittestRoot_defaultStringExtension]
|
||||
75: "\240\001\000\000" # [UnittestRoot_defaultBytesExtension]
|
||||
81: 1 # [UnittestRoot_defaultNestedEnumExtension]
|
||||
82: 4 # [UnittestRoot_defaultForeignEnumExtension]
|
||||
83: 7 # [UnittestRoot_defaultImportEnumExtension]
|
||||
84: "424" # [UnittestRoot_defaultStringPieceExtension]
|
||||
85: "425" # [UnittestRoot_defaultCordExtension]
|
||||
70
objectivec/Tests/text_format_map_unittest_data.txt
Normal file
70
objectivec/Tests/text_format_map_unittest_data.txt
Normal file
@@ -0,0 +1,70 @@
|
||||
map_int32_int32 {
|
||||
key: 100
|
||||
value: 1
|
||||
}
|
||||
map_int64_int64 {
|
||||
key: 101
|
||||
value: 1
|
||||
}
|
||||
map_uint32_uint32 {
|
||||
key: 102
|
||||
value: 1
|
||||
}
|
||||
map_uint64_uint64 {
|
||||
key: 103
|
||||
value: 1
|
||||
}
|
||||
map_sint32_sint32 {
|
||||
key: 104
|
||||
value: 1
|
||||
}
|
||||
map_sint64_sint64 {
|
||||
key: 105
|
||||
value: 1
|
||||
}
|
||||
map_fixed32_fixed32 {
|
||||
key: 106
|
||||
value: 1
|
||||
}
|
||||
map_fixed64_fixed64 {
|
||||
key: 107
|
||||
value: 1
|
||||
}
|
||||
map_sfixed32_sfixed32 {
|
||||
key: 108
|
||||
value: 1
|
||||
}
|
||||
map_sfixed64_sfixed64 {
|
||||
key: 109
|
||||
value: 1
|
||||
}
|
||||
map_int32_float {
|
||||
key: 110
|
||||
value: 1
|
||||
}
|
||||
map_int32_double {
|
||||
key: 111
|
||||
value: 1
|
||||
}
|
||||
map_bool_bool {
|
||||
key: true
|
||||
value: false
|
||||
}
|
||||
map_string_string {
|
||||
key: "112"
|
||||
value: "1"
|
||||
}
|
||||
map_int32_bytes {
|
||||
key: 113
|
||||
value: "\001\000\000\000"
|
||||
}
|
||||
map_int32_enum {
|
||||
key: 114
|
||||
value: MAP_ENUM_BAZ
|
||||
}
|
||||
map_int32_foreign_message {
|
||||
key: 115
|
||||
value {
|
||||
c: 1
|
||||
}
|
||||
}
|
||||
116
objectivec/Tests/text_format_unittest_data.txt
Normal file
116
objectivec/Tests/text_format_unittest_data.txt
Normal file
@@ -0,0 +1,116 @@
|
||||
optional_int32: 101
|
||||
optional_int64: 102
|
||||
optional_uint32: 103
|
||||
optional_uint64: 104
|
||||
optional_sint32: 105
|
||||
optional_sint64: 106
|
||||
optional_fixed32: 107
|
||||
optional_fixed64: 108
|
||||
optional_sfixed32: 109
|
||||
optional_sfixed64: 110
|
||||
optional_float: 111
|
||||
optional_double: 112
|
||||
optional_bool: true
|
||||
optional_string: "115"
|
||||
optional_bytes: "\001\000\002\003\000\005"
|
||||
OptionalGroup {
|
||||
a: 117
|
||||
}
|
||||
optional_nested_message {
|
||||
bb: 118
|
||||
}
|
||||
optional_foreign_message {
|
||||
c: 119
|
||||
}
|
||||
optional_import_message {
|
||||
d: 120
|
||||
}
|
||||
optional_nested_enum: BAZ
|
||||
optional_foreign_enum: FOREIGN_BAZ
|
||||
optional_import_enum: IMPORT_BAZ
|
||||
optional_string_piece: "124"
|
||||
optional_cord: "125"
|
||||
repeated_int32: 201
|
||||
repeated_int32: 301
|
||||
repeated_int64: 202
|
||||
repeated_int64: 302
|
||||
repeated_uint32: 203
|
||||
repeated_uint32: 303
|
||||
repeated_uint64: 204
|
||||
repeated_uint64: 304
|
||||
repeated_sint32: 205
|
||||
repeated_sint32: 305
|
||||
repeated_sint64: 206
|
||||
repeated_sint64: 306
|
||||
repeated_fixed32: 207
|
||||
repeated_fixed32: 307
|
||||
repeated_fixed64: 208
|
||||
repeated_fixed64: 308
|
||||
repeated_sfixed32: 209
|
||||
repeated_sfixed32: 309
|
||||
repeated_sfixed64: 210
|
||||
repeated_sfixed64: 310
|
||||
repeated_float: 211
|
||||
repeated_float: 311
|
||||
repeated_double: 212
|
||||
repeated_double: 312
|
||||
repeated_bool: false
|
||||
repeated_bool: true
|
||||
repeated_string: "215"
|
||||
repeated_string: "315"
|
||||
repeated_bytes: "\330\000\000\000"
|
||||
repeated_bytes: "<\001\000\000"
|
||||
RepeatedGroup {
|
||||
a: 217
|
||||
}
|
||||
RepeatedGroup {
|
||||
a: 317
|
||||
}
|
||||
repeated_nested_message {
|
||||
bb: 218
|
||||
}
|
||||
repeated_nested_message {
|
||||
bb: 318
|
||||
}
|
||||
repeated_foreign_message {
|
||||
c: 219
|
||||
}
|
||||
repeated_foreign_message {
|
||||
c: 319
|
||||
}
|
||||
repeated_import_message {
|
||||
d: 220
|
||||
}
|
||||
repeated_import_message {
|
||||
d: 320
|
||||
}
|
||||
repeated_nested_enum: BAZ
|
||||
repeated_nested_enum: BAR
|
||||
repeated_foreign_enum: FOREIGN_BAZ
|
||||
repeated_foreign_enum: FOREIGN_BAR
|
||||
repeated_import_enum: IMPORT_BAZ
|
||||
repeated_import_enum: IMPORT_BAR
|
||||
repeated_string_piece: "224"
|
||||
repeated_string_piece: "324"
|
||||
repeated_cord: "225"
|
||||
repeated_cord: "325"
|
||||
default_int32: 401
|
||||
default_int64: 402
|
||||
default_uint32: 403
|
||||
default_uint64: 404
|
||||
default_sint32: 405
|
||||
default_sint64: 406
|
||||
default_fixed32: 407
|
||||
default_fixed64: 408
|
||||
default_sfixed32: 409
|
||||
default_sfixed64: 410
|
||||
default_float: 411
|
||||
default_double: 412
|
||||
default_bool: false
|
||||
default_string: "415"
|
||||
default_bytes: "\240\001\000\000"
|
||||
default_nested_enum: FOO
|
||||
default_foreign_enum: FOREIGN_FOO
|
||||
default_import_enum: IMPORT_FOO
|
||||
default_string_piece: "424"
|
||||
default_cord: "425"
|
||||
1536
objectivec/Tests/unittest.proto
Normal file
1536
objectivec/Tests/unittest.proto
Normal file
File diff suppressed because it is too large
Load Diff
58
objectivec/Tests/unittest_cycle.proto
Normal file
58
objectivec/Tests/unittest_cycle.proto
Normal file
@@ -0,0 +1,58 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.cycle;
|
||||
|
||||
option objc_class_prefix = "Cycle";
|
||||
|
||||
// Cycles in the Message graph can cause problems for message class
|
||||
// initialization order.
|
||||
|
||||
// You can't make a object graph that spans files, so this can only be done
|
||||
// within a single proto file.
|
||||
|
||||
message Foo {
|
||||
optional Foo a_foo = 1;
|
||||
optional Bar a_bar = 2;
|
||||
optional Baz a_baz = 3;
|
||||
}
|
||||
|
||||
message Bar {
|
||||
optional Bar a_bar = 1;
|
||||
optional Baz a_baz = 2;
|
||||
optional Foo a_foo = 3;
|
||||
}
|
||||
|
||||
message Baz {
|
||||
optional Baz a_baz = 1;
|
||||
optional Foo a_foo = 2;
|
||||
optional Bar a_bar = 3;
|
||||
}
|
||||
95
objectivec/Tests/unittest_deprecated.proto
Normal file
95
objectivec/Tests/unittest_deprecated.proto
Normal file
@@ -0,0 +1,95 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2016 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.deprecated;
|
||||
option objc_class_prefix = "Dep";
|
||||
|
||||
//
|
||||
// This file is like unittest_deprecated_file.proto, but uses message, enum,
|
||||
// enum value, and field level deprecation.
|
||||
//
|
||||
// The source generated from this file needs to be inspect to confirm it has
|
||||
// all of the expected annotations. It also will be compiled into the unittest
|
||||
// and that compile should be clean without errors.
|
||||
//
|
||||
|
||||
// Mix of field types marked as deprecated.
|
||||
message Msg1 {
|
||||
extensions 100 to max;
|
||||
|
||||
optional string string_field = 1 [deprecated=true];
|
||||
required int32 int_field = 2 [deprecated=true];
|
||||
repeated fixed32 fixed_field = 3 [deprecated=true];
|
||||
optional Msg1 msg_field = 4 [deprecated=true];
|
||||
}
|
||||
|
||||
// Mix of extension field types marked as deprecated.
|
||||
extend Msg1 {
|
||||
optional string string_ext_field = 101 [deprecated=true];
|
||||
optional int32 int_ext_field = 102 [deprecated=true];
|
||||
repeated fixed32 fixed_ext_field = 103 [deprecated=true];
|
||||
optional Msg1 msg_ext_field = 104 [deprecated=true];
|
||||
}
|
||||
|
||||
// Mix of extension field types (scoped to a message) marked as deprecated.
|
||||
message Msg1A {
|
||||
extend Msg1 {
|
||||
optional string string_ext2_field = 201 [deprecated=true];
|
||||
optional int32 int_ext2_field = 202 [deprecated=true];
|
||||
repeated fixed32 fixed_ext2_field = 203 [deprecated=true];
|
||||
optional Msg1 msg_ext2_field = 204 [deprecated=true];
|
||||
}
|
||||
}
|
||||
|
||||
// Enum value marked as deprecated.
|
||||
enum Enum1 {
|
||||
ENUM1_ONE = 1;
|
||||
ENUM1_TWO = 2;
|
||||
ENUM1_THREE = 3 [deprecated=true];
|
||||
}
|
||||
|
||||
// Message marked as deprecated.
|
||||
message Msg2 {
|
||||
option deprecated = true;
|
||||
|
||||
optional string string_field = 1;
|
||||
required int32 int_field = 2;
|
||||
repeated fixed32 fixed_field = 3;
|
||||
}
|
||||
|
||||
// Enum marked as deprecated.
|
||||
enum Enum2 {
|
||||
option deprecated = true;
|
||||
|
||||
ENUM2_ONE = 1;
|
||||
ENUM2_TWO = 2;
|
||||
ENUM2_THREE = 3;
|
||||
}
|
||||
76
objectivec/Tests/unittest_deprecated_file.proto
Normal file
76
objectivec/Tests/unittest_deprecated_file.proto
Normal file
@@ -0,0 +1,76 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2016 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.deprecated_file;
|
||||
option objc_class_prefix = "FileDep";
|
||||
|
||||
//
|
||||
// This file is like unittest_deprecated.proto, but does NOT use message, enum,
|
||||
// enum value, or field level deprecation; instead it uses the file level option
|
||||
// to mark everything.
|
||||
//
|
||||
// The source generated from this file needs to be inspect to confirm it has
|
||||
// all of the expected annotations. It also will be compiled into the unittest
|
||||
// and that compile should be clean without errors.
|
||||
//
|
||||
option deprecated = true;
|
||||
|
||||
// Message to catch the deprecation.
|
||||
message Msg1 {
|
||||
extensions 100 to max;
|
||||
|
||||
optional string string_field = 1;
|
||||
}
|
||||
|
||||
// Mix of extension field types to catch the deprecation.
|
||||
extend Msg1 {
|
||||
optional string string_ext_field = 101;
|
||||
optional int32 int_ext_field = 102;
|
||||
repeated fixed32 fixed_ext_field = 103;
|
||||
optional Msg1 msg_ext_field = 104;
|
||||
}
|
||||
|
||||
// Mix of extension field types (scoped to a message) to catch the deprecation.
|
||||
message Msg1A {
|
||||
extend Msg1 {
|
||||
optional string string_ext2_field = 201;
|
||||
optional int32 int_ext2_field = 202;
|
||||
repeated fixed32 fixed_ext2_field = 203;
|
||||
optional Msg1 msg_ext2_field = 204;
|
||||
}
|
||||
}
|
||||
|
||||
// Enum to catch the deprecation.
|
||||
enum Enum1 {
|
||||
ENUM1_ONE = 1;
|
||||
ENUM1_TWO = 2;
|
||||
ENUM1_THREE = 3;
|
||||
}
|
||||
53
objectivec/Tests/unittest_extension_chain_a.proto
Normal file
53
objectivec/Tests/unittest_extension_chain_a.proto
Normal file
@@ -0,0 +1,53 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2016 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.chain;
|
||||
|
||||
import "objectivec/Tests/unittest.proto";
|
||||
|
||||
import "objectivec/Tests/unittest_extension_chain_b.proto";
|
||||
import "objectivec/Tests/unittest_extension_chain_c.proto";
|
||||
import "objectivec/Tests/unittest_extension_chain_d.proto";
|
||||
|
||||
option objc_class_prefix = "Chain";
|
||||
|
||||
// The Root for this file should end up adding the local extension and merging
|
||||
// in the extensions from D's Root (unittest and C will come via D's).
|
||||
|
||||
message AMessage {
|
||||
optional BMessage b = 1;
|
||||
optional CMessage c = 2;
|
||||
optional DMessage d = 3;
|
||||
}
|
||||
|
||||
extend objc.protobuf.tests.TestAllExtensions {
|
||||
optional int32 chain_a_extension = 10001;
|
||||
}
|
||||
49
objectivec/Tests/unittest_extension_chain_b.proto
Normal file
49
objectivec/Tests/unittest_extension_chain_b.proto
Normal file
@@ -0,0 +1,49 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2016 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.chain;
|
||||
|
||||
import "objectivec/Tests/unittest.proto";
|
||||
|
||||
import "objectivec/Tests/unittest_extension_chain_c.proto";
|
||||
|
||||
option objc_class_prefix = "Chain";
|
||||
|
||||
// The Root for this file should end up adding the local extension and merging
|
||||
// in the extensions from C's Root (unittest will come via C's).
|
||||
|
||||
message BMessage {
|
||||
optional CMessage c = 1;
|
||||
}
|
||||
|
||||
extend objc.protobuf.tests.TestAllExtensions {
|
||||
optional int32 chain_b_extension = 10002;
|
||||
}
|
||||
47
objectivec/Tests/unittest_extension_chain_c.proto
Normal file
47
objectivec/Tests/unittest_extension_chain_c.proto
Normal file
@@ -0,0 +1,47 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2016 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.chain;
|
||||
|
||||
import "objectivec/Tests/unittest.proto";
|
||||
|
||||
option objc_class_prefix = "Chain";
|
||||
|
||||
// The Root for this file should end up adding the local extension and merging
|
||||
// in the extensions from unittest.proto's Root.
|
||||
|
||||
message CMessage {
|
||||
optional int32 my_field = 1;
|
||||
}
|
||||
|
||||
extend objc.protobuf.tests.TestAllExtensions {
|
||||
optional int32 chain_c_extension = 10003;
|
||||
}
|
||||
51
objectivec/Tests/unittest_extension_chain_d.proto
Normal file
51
objectivec/Tests/unittest_extension_chain_d.proto
Normal file
@@ -0,0 +1,51 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2016 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.chain;
|
||||
|
||||
import "objectivec/Tests/unittest.proto";
|
||||
|
||||
import "objectivec/Tests/unittest_extension_chain_b.proto";
|
||||
import "objectivec/Tests/unittest_extension_chain_c.proto";
|
||||
|
||||
option objc_class_prefix = "Chain";
|
||||
|
||||
// The root should end up needing to merge B (C will be merged into B, so it
|
||||
// doesn't need to be directly merged).
|
||||
|
||||
message DMessage {
|
||||
optional BMessage b = 1;
|
||||
optional CMessage c = 2;
|
||||
}
|
||||
|
||||
extend objc.protobuf.tests.TestAllExtensions {
|
||||
optional int32 chain_d_extension = 10004;
|
||||
}
|
||||
42
objectivec/Tests/unittest_extension_chain_e.proto
Normal file
42
objectivec/Tests/unittest_extension_chain_e.proto
Normal file
@@ -0,0 +1,42 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2016 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.chain;
|
||||
|
||||
import "objectivec/Tests/unittest.proto";
|
||||
|
||||
option objc_class_prefix = "Chain";
|
||||
|
||||
// The Root for this file should end up just merging in unittest's Root.
|
||||
|
||||
message EMessage {
|
||||
optional TestAllTypes my_field = 1;
|
||||
}
|
||||
46
objectivec/Tests/unittest_extension_chain_f.proto
Normal file
46
objectivec/Tests/unittest_extension_chain_f.proto
Normal file
@@ -0,0 +1,46 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2016 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.chain;
|
||||
|
||||
import "objectivec/Tests/unittest_extension_chain_g.proto";
|
||||
|
||||
option objc_class_prefix = "Chain";
|
||||
|
||||
// The Root for this file should just be merging in the extensions from C's
|
||||
// Root (because G doesn't define anything itself).
|
||||
|
||||
// The generated source will also have to directly import C's .h file so it can
|
||||
// compile the reference to C's Root class.
|
||||
|
||||
message FMessage {
|
||||
optional GMessage g = 1;
|
||||
}
|
||||
43
objectivec/Tests/unittest_extension_chain_g.proto
Normal file
43
objectivec/Tests/unittest_extension_chain_g.proto
Normal file
@@ -0,0 +1,43 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2016 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.chain;
|
||||
|
||||
import "objectivec/Tests/unittest_extension_chain_c.proto";
|
||||
|
||||
option objc_class_prefix = "Chain";
|
||||
|
||||
// The Root for this file should just be merging in the extensions from C's
|
||||
// Root.
|
||||
|
||||
message GMessage {
|
||||
optional CMessage c = 1;
|
||||
}
|
||||
58
objectivec/Tests/unittest_import.proto
Normal file
58
objectivec/Tests/unittest_import.proto
Normal file
@@ -0,0 +1,58 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// A proto file which is imported by unittest.proto to test importing.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.import;
|
||||
|
||||
// Test public import
|
||||
import public "objectivec/Tests/unittest_import_public.proto";
|
||||
|
||||
option objc_class_prefix = "Import";
|
||||
|
||||
message Message {
|
||||
optional int32 d = 1;
|
||||
}
|
||||
|
||||
enum Enum {
|
||||
IMPORT_FOO = 7;
|
||||
IMPORT_BAR = 8;
|
||||
IMPORT_BAZ = 9;
|
||||
}
|
||||
|
||||
|
||||
// To use an enum in a map, it must has the first value as 0.
|
||||
enum EnumForMap {
|
||||
UNKNOWN = 0;
|
||||
FOO = 1;
|
||||
BAR = 2;
|
||||
}
|
||||
41
objectivec/Tests/unittest_import_public.proto
Normal file
41
objectivec/Tests/unittest_import_public.proto
Normal file
@@ -0,0 +1,41 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (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: liujisi@google.com (Pherl Liu)
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.public_import;
|
||||
|
||||
option objc_class_prefix = "PublicImport";
|
||||
|
||||
message Message {
|
||||
optional int32 e = 1;
|
||||
}
|
||||
65
objectivec/Tests/unittest_mset.proto
Normal file
65
objectivec/Tests/unittest_mset.proto
Normal file
@@ -0,0 +1,65 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.mset;
|
||||
|
||||
option objc_class_prefix = "MSet";
|
||||
|
||||
// A message with message_set_wire_format.
|
||||
message Message {
|
||||
option message_set_wire_format = true;
|
||||
extensions 4 to max;
|
||||
}
|
||||
|
||||
message MessageExtension1 {
|
||||
extend Message {
|
||||
optional MessageExtension1 message_set_extension = 1545008;
|
||||
}
|
||||
optional int32 i = 15;
|
||||
optional Message recursive = 16;
|
||||
optional string test_aliasing = 17 [ctype = STRING_PIECE];
|
||||
}
|
||||
|
||||
message MessageExtension2 {
|
||||
extend Message {
|
||||
optional MessageExtension2 message_set_extension = 1547769;
|
||||
}
|
||||
optional string str = 25;
|
||||
}
|
||||
|
||||
// MessageSet wire format is equivalent to this.
|
||||
message RawMessageSet {
|
||||
repeated group Item = 1 {
|
||||
required int32 type_id = 2;
|
||||
required bytes message = 3;
|
||||
}
|
||||
}
|
||||
886
objectivec/Tests/unittest_objc.proto
Normal file
886
objectivec/Tests/unittest_objc.proto
Normal file
@@ -0,0 +1,886 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
import "objectivec/Tests/unittest.proto";
|
||||
|
||||
package objc.protobuf.tests;
|
||||
|
||||
// Explicit empty prefix, tests some validations code paths also.
|
||||
option objc_class_prefix = "";
|
||||
|
||||
// Used to check that Headerdocs and appledoc work correctly. If these comments
|
||||
// are not handled correctly, Xcode will fail to build the tests.
|
||||
message TestGeneratedComments {
|
||||
// This is a string that could contain stuff like
|
||||
// mime types as image/* or */plain. Maybe twitter usernames
|
||||
// like @protobuf, @google or @something.
|
||||
optional string string_field = 1;
|
||||
}
|
||||
|
||||
// Using the messages in unittest.proto, setup for recursive cases for testing
|
||||
// extensions at various depths.
|
||||
extend TestAllExtensions {
|
||||
optional TestAllExtensions recursive_extension = 86;
|
||||
}
|
||||
|
||||
// Recursive message to for testing autocreators at different depths.
|
||||
message TestRecursiveMessageWithRepeatedField {
|
||||
optional TestRecursiveMessageWithRepeatedField a = 1;
|
||||
repeated int32 i = 2;
|
||||
repeated string str = 3;
|
||||
map<int32, int32> i_to_i = 4;
|
||||
map<string, string> str_to_str = 5;
|
||||
}
|
||||
|
||||
// Message with a few types of maps to cover the different custom flows
|
||||
// in the runtime.
|
||||
message TestMessageOfMaps {
|
||||
map<string, string> str_to_str = 1;
|
||||
|
||||
map<string, int32> str_to_int = 2;
|
||||
map<int32, string> int_to_str = 3;
|
||||
map<int32, int32> int_to_int = 4;
|
||||
|
||||
map<string, bool> str_to_bool = 5;
|
||||
map<bool, string> bool_to_str = 6;
|
||||
map<bool, bool> bool_to_bool = 7;
|
||||
|
||||
map<int32, bool> int_to_bool = 8;
|
||||
map<bool, int32> bool_to_int = 9;
|
||||
|
||||
map<string, TestAllTypes> str_to_msg = 10;
|
||||
map<int32, TestAllTypes> int_to_msg = 11;
|
||||
map<bool, TestAllTypes> bool_to_msg = 12;
|
||||
}
|
||||
|
||||
// Recursive message and extension to for testing autocreators at different
|
||||
// depths.
|
||||
message TestRecursiveExtension {
|
||||
optional TestRecursiveExtension recursive_sub_message = 1;
|
||||
repeated int32 repeated_value = 2;
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
extend TestRecursiveExtension {
|
||||
optional TestRecursiveExtension recursive_message_extension = 1000;
|
||||
}
|
||||
|
||||
message self {
|
||||
message super {
|
||||
optional int32 description = 1;
|
||||
}
|
||||
|
||||
enum autorelease {
|
||||
retain = 1;
|
||||
release = 2;
|
||||
retainCount = 3;
|
||||
}
|
||||
|
||||
// Singular
|
||||
// Objective C Keywords
|
||||
optional bool id = 1;
|
||||
optional bool _cmd = 2;
|
||||
// super is used as submessage above
|
||||
optional bool in = 4;
|
||||
optional bool out = 5;
|
||||
optional bool inout = 6;
|
||||
optional bool bycopy = 7;
|
||||
optional bool byref = 8;
|
||||
optional bool oneway = 9;
|
||||
optional bool self = 10;
|
||||
optional bool instancetype = 11;
|
||||
optional bool nullable = 12;
|
||||
optional bool nonnull = 13;
|
||||
optional bool nil = 14;
|
||||
// Nil and nil can't be in the same message
|
||||
optional bool YES = 16;
|
||||
optional bool NO = 17;
|
||||
optional bool weak = 18;
|
||||
|
||||
// Some C/C++ Keywords
|
||||
optional bool case = 30;
|
||||
optional bool if = 31;
|
||||
optional bool and_eq = 32;
|
||||
optional bool public = 33;
|
||||
optional bool private = 34;
|
||||
optional bool typename = 35;
|
||||
optional bool static_cast = 36;
|
||||
optional bool typeof = 37;
|
||||
optional bool restrict = 38;
|
||||
optional bool NULL = 39;
|
||||
|
||||
// Some NSObject Methods
|
||||
optional bool dealloc = 110;
|
||||
optional bool isProxy = 111;
|
||||
optional bool copy = 112;
|
||||
optional bool description = 113;
|
||||
optional bool zone = 114;
|
||||
optional bool className = 115;
|
||||
optional bool __retain_OA = 116;
|
||||
optional bool CAMLType = 117;
|
||||
optional bool isNSDictionary__ = 118;
|
||||
optional bool accessibilityLabel = 119;
|
||||
|
||||
// Some Objc "keywords" that we shouldn't
|
||||
// have to worry about because they
|
||||
// can only appear in specialized areas.
|
||||
optional bool assign = 200;
|
||||
optional bool getter = 201;
|
||||
optional bool setter = 202;
|
||||
optional bool atomic = 203;
|
||||
optional bool nonatomic = 204;
|
||||
optional bool strong = 205;
|
||||
optional bool null_resettable = 206;
|
||||
optional bool readonly = 207;
|
||||
|
||||
// Some GPBMessage methods
|
||||
optional bool clear = 300;
|
||||
optional bool data = 301;
|
||||
optional bool descriptor = 302;
|
||||
optional bool delimitedData = 303;
|
||||
|
||||
// Some MacTypes
|
||||
optional bool Fixed = 400;
|
||||
optional bool Point = 401;
|
||||
optional bool FixedPoint = 402;
|
||||
optional bool Style = 403;
|
||||
|
||||
// C/C++ reserved identifiers
|
||||
optional bool _Generic = 500;
|
||||
optional bool __block = 501;
|
||||
|
||||
// Try a keyword as a type
|
||||
optional autorelease SubEnum = 1000;
|
||||
|
||||
optional group New = 2000 {
|
||||
optional string copy = 1;
|
||||
}
|
||||
optional group MutableCopy = 2001 {
|
||||
optional int32 extensionRegistry = 1;
|
||||
}
|
||||
|
||||
extensions 3000 to 3999;
|
||||
|
||||
}
|
||||
|
||||
enum retain {
|
||||
count = 4;
|
||||
initialized = 5;
|
||||
serializedSize = 6;
|
||||
}
|
||||
|
||||
message ObjCPropertyNaming {
|
||||
// Test that the properties properly get things all caps.
|
||||
optional string url = 1;
|
||||
optional string thumbnail_url = 2;
|
||||
optional string url_foo = 3;
|
||||
optional string some_url_blah = 4;
|
||||
optional string http = 5;
|
||||
optional string https = 6;
|
||||
// This one doesn't.
|
||||
repeated string urls = 7;
|
||||
}
|
||||
|
||||
// EnumValueShortName: The short names shouldn't get suffixes/prefixes.
|
||||
enum Foo {
|
||||
SERIALIZED_SIZE = 1;
|
||||
SIZE = 2;
|
||||
OTHER = 3;
|
||||
}
|
||||
|
||||
// EnumValueShortName: The enum name gets a prefix.
|
||||
enum Category {
|
||||
RED = 1;
|
||||
BLUE = 2;
|
||||
}
|
||||
|
||||
// EnumValueShortName: Twist case, full name gets PB, but the short names
|
||||
// should still end up correct.
|
||||
enum Time {
|
||||
BASE = 1;
|
||||
RECORD = 2;
|
||||
SOMETHING_ELSE = 3;
|
||||
}
|
||||
|
||||
extend self {
|
||||
repeated int32 debugDescription = 3000 [packed = true];
|
||||
repeated int64 finalize = 3001 [packed = true];
|
||||
repeated uint32 hash = 3002 [packed = true];
|
||||
repeated uint64 classForCoder = 3003 [packed = true];
|
||||
repeated sint32 byref = 3004 [packed = true];
|
||||
}
|
||||
|
||||
// Test handing of fields that start with init*.
|
||||
message ObjCInitFoo {
|
||||
optional string init_val = 11;
|
||||
optional int32 init_size = 12;
|
||||
optional self init_self = 13;
|
||||
|
||||
repeated string init_vals = 21;
|
||||
repeated int32 init_sizes = 22;
|
||||
repeated self init_selfs = 23;
|
||||
}
|
||||
|
||||
// Test handling of fields that start with retained names.
|
||||
message ObjCRetainedFoo {
|
||||
optional string new_val_lower_complex = 11;
|
||||
optional string new_Val_upper_complex = 12;
|
||||
optional string newvalue_lower_no_underscore_complex = 13;
|
||||
optional string newValue_upper_no_underscore_complex = 14;
|
||||
|
||||
optional int32 new_val_lower_primitive = 15;
|
||||
optional int32 new_Val_upper_primitive = 16;
|
||||
optional int32 newvalue_lower_no_underscore_primitive = 17;
|
||||
optional int32 newValue_upper_no_underscore_primitive = 18;
|
||||
|
||||
optional self new_val_lower_message = 19;
|
||||
optional self new_Val_upper_message = 20;
|
||||
optional self newvalue_lower_no_underscore_message = 21;
|
||||
optional self newValue_upper_no_underscore_message = 22;
|
||||
|
||||
optional Foo new_val_lower_enum = 23;
|
||||
optional Foo new_Val_upper_enum = 24;
|
||||
optional Foo newvalue_lower_no_underscore_enum = 25;
|
||||
optional Foo newValue_upper_no_underscore_enum = 26;
|
||||
|
||||
repeated string new_val_lower_complex_repeated = 111;
|
||||
repeated string new_Val_upper_complex_repeated = 112;
|
||||
repeated string newvalue_lower_no_underscore_complex_repeated = 113;
|
||||
repeated string newValue_upper_no_underscore_complex_repeated = 114;
|
||||
|
||||
repeated int32 new_val_lower_primitive_repeated = 115;
|
||||
repeated int32 new_Val_upper_primitive_repeated = 116;
|
||||
repeated int32 newvalue_lower_no_underscore_primitive_repeated = 117;
|
||||
repeated int32 newValue_upper_no_underscore_primitive_repeated = 118;
|
||||
|
||||
repeated self new_val_lower_message_repeated = 119;
|
||||
repeated self new_Val_upper_message_repeated = 120;
|
||||
repeated self newvalue_lower_no_underscore_message_repeated = 121;
|
||||
repeated self newValue_upper_no_underscore_message_repeated = 122;
|
||||
|
||||
repeated Foo new_val_lower_enum_repeated = 123;
|
||||
repeated Foo new_Val_upper_enum_repeated = 124;
|
||||
repeated Foo newvalue_lower_no_underscore_enum_repeated = 125;
|
||||
repeated Foo newValue_upper_no_underscore_enum_repeated = 126;
|
||||
|
||||
optional string alloc_val_lower_complex = 211;
|
||||
optional string alloc_Val_upper_complex = 212;
|
||||
optional string allocvalue_lower_no_underscore_complex = 213;
|
||||
optional string allocValue_upper_no_underscore_complex = 214;
|
||||
|
||||
optional int32 alloc_val_lower_primitive = 215;
|
||||
optional int32 alloc_Val_upper_primitive = 216;
|
||||
optional int32 allocvalue_lower_no_underscore_primitive = 217;
|
||||
optional int32 allocValue_upper_no_underscore_primitive = 218;
|
||||
|
||||
optional self alloc_val_lower_message = 219;
|
||||
optional self alloc_Val_upper_message = 220;
|
||||
optional self allocvalue_lower_no_underscore_message = 221;
|
||||
optional self allocValue_upper_no_underscore_message = 222;
|
||||
|
||||
optional Foo alloc_val_lower_enum = 223;
|
||||
optional Foo alloc_Val_upper_enum = 224;
|
||||
optional Foo allocvalue_lower_no_underscore_enum = 225;
|
||||
optional Foo allocValue_upper_no_underscore_enum = 226;
|
||||
|
||||
repeated string alloc_val_lower_complex_repeated = 311;
|
||||
repeated string alloc_Val_upper_complex_repeated = 312;
|
||||
repeated string allocvalue_lower_no_underscore_complex_repeated = 313;
|
||||
repeated string allocValue_upper_no_underscore_complex_repeated = 314;
|
||||
|
||||
repeated int32 alloc_val_lower_primitive_repeated = 315;
|
||||
repeated int32 alloc_Val_upper_primitive_repeated = 316;
|
||||
repeated int32 allocvalue_lower_no_underscore_primitive_repeated = 317;
|
||||
repeated int32 allocValue_upper_no_underscore_primitive_repeated = 318;
|
||||
|
||||
repeated self alloc_val_lower_message_repeated = 319;
|
||||
repeated self alloc_Val_upper_message_repeated = 320;
|
||||
repeated self allocvalue_lower_no_underscore_message_repeated = 321;
|
||||
repeated self allocValue_upper_no_underscore_message_repeated = 322;
|
||||
|
||||
repeated Foo alloc_val_lower_enum_repeated = 323;
|
||||
repeated Foo alloc_Val_upper_enum_repeated = 324;
|
||||
repeated Foo allocvalue_lower_no_underscore_enum_repeated = 325;
|
||||
repeated Foo allocValue_upper_no_underscore_enum_repeated = 326;
|
||||
|
||||
optional string copy_val_lower_complex = 411;
|
||||
optional string copy_Val_upper_complex = 412;
|
||||
optional string copyvalue_lower_no_underscore_complex = 413;
|
||||
optional string copyValue_upper_no_underscore_complex = 414;
|
||||
|
||||
optional int32 copy_val_lower_primitive = 415;
|
||||
optional int32 copy_Val_upper_primitive = 416;
|
||||
optional int32 copyvalue_lower_no_underscore_primitive = 417;
|
||||
optional int32 copyValue_upper_no_underscore_primitive = 418;
|
||||
|
||||
optional self copy_val_lower_message = 419;
|
||||
optional self copy_Val_upper_message = 420;
|
||||
optional self copyvalue_lower_no_underscore_message = 421;
|
||||
optional self copyValue_upper_no_underscore_message = 422;
|
||||
|
||||
optional Foo copy_val_lower_enum = 423;
|
||||
optional Foo copy_Val_upper_enum = 424;
|
||||
optional Foo copyvalue_lower_no_underscore_enum = 425;
|
||||
optional Foo copyValue_upper_no_underscore_enum = 426;
|
||||
|
||||
repeated string copy_val_lower_complex_repeated = 511;
|
||||
repeated string copy_Val_upper_complex_repeated = 512;
|
||||
repeated string copyvalue_lower_no_underscore_complex_repeated = 513;
|
||||
repeated string copyValue_upper_no_underscore_complex_repeated = 514;
|
||||
|
||||
repeated int32 copy_val_lower_primitive_repeated = 515;
|
||||
repeated int32 copy_Val_upper_primitive_repeated = 516;
|
||||
repeated int32 copyvalue_lower_no_underscore_primitive_repeated = 517;
|
||||
repeated int32 copyValue_upper_no_underscore_primitive_repeated = 518;
|
||||
|
||||
repeated self copy_val_lower_message_repeated = 519;
|
||||
repeated self copy_Val_upper_message_repeated = 520;
|
||||
repeated self copyvalue_lower_no_underscore_message_repeated = 521;
|
||||
repeated self copyValue_upper_no_underscore_message_repeated = 522;
|
||||
|
||||
repeated Foo copy_val_lower_enum_repeated = 523;
|
||||
repeated Foo copy_Val_upper_enum_repeated = 524;
|
||||
repeated Foo copyvalue_lower_no_underscore_enum_repeated = 525;
|
||||
repeated Foo copyValue_upper_no_underscore_enum_repeated = 526;
|
||||
|
||||
optional string mutableCopy_val_lower_complex = 611;
|
||||
optional string mutableCopy_Val_upper_complex = 612;
|
||||
optional string mutableCopyvalue_lower_no_underscore_complex = 613;
|
||||
optional string mutableCopyValue_upper_no_underscore_complex = 614;
|
||||
|
||||
optional int32 mutableCopy_val_lower_primitive = 615;
|
||||
optional int32 mutableCopy_Val_upper_primitive = 616;
|
||||
optional int32 mutableCopyvalue_lower_no_underscore_primitive = 617;
|
||||
optional int32 mutableCopyValue_upper_no_underscore_primitive = 618;
|
||||
|
||||
optional self mutableCopy_val_lower_message = 619;
|
||||
optional self mutableCopy_Val_upper_message = 620;
|
||||
optional self mutableCopyvalue_lower_no_underscore_message = 621;
|
||||
optional self mutableCopyValue_upper_no_underscore_message = 622;
|
||||
|
||||
optional Foo mutableCopy_val_lower_enum = 623;
|
||||
optional Foo mutableCopy_Val_upper_enum = 624;
|
||||
optional Foo mutableCopyvalue_lower_no_underscore_enum = 625;
|
||||
optional Foo mutableCopyValue_upper_no_underscore_enum = 626;
|
||||
|
||||
repeated string mutableCopy_val_lower_complex_repeated = 711;
|
||||
repeated string mutableCopy_Val_upper_complex_repeated = 712;
|
||||
repeated string mutableCopyvalue_lower_no_underscore_complex_repeated = 713;
|
||||
repeated string mutableCopyValue_upper_no_underscore_complex_repeated = 714;
|
||||
|
||||
repeated int32 mutableCopy_val_lower_primitive_repeated = 715;
|
||||
repeated int32 mutableCopy_Val_upper_primitive_repeated = 716;
|
||||
repeated int32 mutableCopyvalue_lower_no_underscore_primitive_repeated = 717;
|
||||
repeated int32 mutableCopyValue_upper_no_underscore_primitive_repeated = 718;
|
||||
|
||||
repeated self mutableCopy_val_lower_message_repeated = 719;
|
||||
repeated self mutableCopy_Val_upper_message_repeated = 720;
|
||||
repeated self mutableCopyvalue_lower_no_underscore_message_repeated = 721;
|
||||
repeated self mutableCopyValue_upper_no_underscore_message_repeated = 722;
|
||||
|
||||
repeated Foo mutableCopy_val_lower_enum_repeated = 723;
|
||||
repeated Foo mutableCopy_Val_upper_enum_repeated = 724;
|
||||
repeated Foo mutableCopyvalue_lower_no_underscore_enum_repeated = 725;
|
||||
repeated Foo mutableCopyValue_upper_no_underscore_enum_repeated = 726;
|
||||
|
||||
extensions 1000 to 3999;
|
||||
}
|
||||
|
||||
// Extension fields with retained names.
|
||||
extend ObjCRetainedFoo {
|
||||
optional string new_val_lower_complex = 1011;
|
||||
optional string new_Val_upper_complex = 1012;
|
||||
optional string newvalue_lower_no_underscore_complex = 1013;
|
||||
optional string newValue_upper_no_underscore_complex = 1014;
|
||||
|
||||
optional int32 new_val_lower_primitive = 1015;
|
||||
optional int32 new_Val_upper_primitive = 1016;
|
||||
optional int32 newvalue_lower_no_underscore_primitive = 1017;
|
||||
optional int32 newValue_upper_no_underscore_primitive = 1018;
|
||||
|
||||
optional self new_val_lower_message = 1019;
|
||||
optional self new_Val_upper_message = 1020;
|
||||
optional self newvalue_lower_no_underscore_message = 1021;
|
||||
optional self newValue_upper_no_underscore_message = 1022;
|
||||
|
||||
optional Foo new_val_lower_enum = 1023;
|
||||
optional Foo new_Val_upper_enum = 1024;
|
||||
optional Foo newvalue_lower_no_underscore_enum = 1025;
|
||||
optional Foo newValue_upper_no_underscore_enum = 1026;
|
||||
|
||||
repeated string new_val_lower_complex_repeated = 1111;
|
||||
repeated string new_Val_upper_complex_repeated = 1112;
|
||||
repeated string newvalue_lower_no_underscore_complex_repeated = 1113;
|
||||
repeated string newValue_upper_no_underscore_complex_repeated = 1114;
|
||||
|
||||
repeated int32 new_val_lower_primitive_repeated = 1115;
|
||||
repeated int32 new_Val_upper_primitive_repeated = 1116;
|
||||
repeated int32 newvalue_lower_no_underscore_primitive_repeated = 1117;
|
||||
repeated int32 newValue_upper_no_underscore_primitive_repeated = 1118;
|
||||
|
||||
repeated self new_val_lower_message_repeated = 1119;
|
||||
repeated self new_Val_upper_message_repeated = 1120;
|
||||
repeated self newvalue_lower_no_underscore_message_repeated = 1121;
|
||||
repeated self newValue_upper_no_underscore_message_repeated = 1122;
|
||||
|
||||
repeated Foo new_val_lower_enum_repeated = 1123;
|
||||
repeated Foo new_Val_upper_enum_repeated = 1124;
|
||||
repeated Foo newvalue_lower_no_underscore_enum_repeated = 1125;
|
||||
repeated Foo newValue_upper_no_underscore_enum_repeated = 1126;
|
||||
|
||||
optional string alloc_val_lower_complex = 1211;
|
||||
optional string alloc_Val_upper_complex = 1212;
|
||||
optional string allocvalue_lower_no_underscore_complex = 1213;
|
||||
optional string allocValue_upper_no_underscore_complex = 1214;
|
||||
|
||||
optional int32 alloc_val_lower_primitive = 1215;
|
||||
optional int32 alloc_Val_upper_primitive = 1216;
|
||||
optional int32 allocvalue_lower_no_underscore_primitive = 1217;
|
||||
optional int32 allocValue_upper_no_underscore_primitive = 1218;
|
||||
|
||||
optional self alloc_val_lower_message = 1219;
|
||||
optional self alloc_Val_upper_message = 1220;
|
||||
optional self allocvalue_lower_no_underscore_message = 1221;
|
||||
optional self allocValue_upper_no_underscore_message = 1222;
|
||||
|
||||
optional Foo alloc_val_lower_enum = 1223;
|
||||
optional Foo alloc_Val_upper_enum = 1224;
|
||||
optional Foo allocvalue_lower_no_underscore_enum = 1225;
|
||||
optional Foo allocValue_upper_no_underscore_enum = 1226;
|
||||
|
||||
repeated string alloc_val_lower_complex_repeated = 1311;
|
||||
repeated string alloc_Val_upper_complex_repeated = 1312;
|
||||
repeated string allocvalue_lower_no_underscore_complex_repeated = 1313;
|
||||
repeated string allocValue_upper_no_underscore_complex_repeated = 1314;
|
||||
|
||||
repeated int32 alloc_val_lower_primitive_repeated = 1315;
|
||||
repeated int32 alloc_Val_upper_primitive_repeated = 1316;
|
||||
repeated int32 allocvalue_lower_no_underscore_primitive_repeated = 1317;
|
||||
repeated int32 allocValue_upper_no_underscore_primitive_repeated = 1318;
|
||||
|
||||
repeated self alloc_val_lower_message_repeated = 1319;
|
||||
repeated self alloc_Val_upper_message_repeated = 1320;
|
||||
repeated self allocvalue_lower_no_underscore_message_repeated = 1321;
|
||||
repeated self allocValue_upper_no_underscore_message_repeated = 1322;
|
||||
|
||||
repeated Foo alloc_val_lower_enum_repeated = 1323;
|
||||
repeated Foo alloc_Val_upper_enum_repeated = 1324;
|
||||
repeated Foo allocvalue_lower_no_underscore_enum_repeated = 1325;
|
||||
repeated Foo allocValue_upper_no_underscore_enum_repeated = 1326;
|
||||
|
||||
optional string copy_val_lower_complex = 1411;
|
||||
optional string copy_Val_upper_complex = 1412;
|
||||
optional string copyvalue_lower_no_underscore_complex = 1413;
|
||||
optional string copyValue_upper_no_underscore_complex = 1414;
|
||||
|
||||
optional int32 copy_val_lower_primitive = 1415;
|
||||
optional int32 copy_Val_upper_primitive = 1416;
|
||||
optional int32 copyvalue_lower_no_underscore_primitive = 1417;
|
||||
optional int32 copyValue_upper_no_underscore_primitive = 1418;
|
||||
|
||||
optional self copy_val_lower_message = 1419;
|
||||
optional self copy_Val_upper_message = 1420;
|
||||
optional self copyvalue_lower_no_underscore_message = 1421;
|
||||
optional self copyValue_upper_no_underscore_message = 1422;
|
||||
|
||||
optional Foo copy_val_lower_enum = 1423;
|
||||
optional Foo copy_Val_upper_enum = 1424;
|
||||
optional Foo copyvalue_lower_no_underscore_enum = 1425;
|
||||
optional Foo copyValue_upper_no_underscore_enum = 1426;
|
||||
|
||||
repeated string copy_val_lower_complex_repeated = 1511;
|
||||
repeated string copy_Val_upper_complex_repeated = 1512;
|
||||
repeated string copyvalue_lower_no_underscore_complex_repeated = 1513;
|
||||
repeated string copyValue_upper_no_underscore_complex_repeated = 1514;
|
||||
|
||||
repeated int32 copy_val_lower_primitive_repeated = 1515;
|
||||
repeated int32 copy_Val_upper_primitive_repeated = 1516;
|
||||
repeated int32 copyvalue_lower_no_underscore_primitive_repeated = 1517;
|
||||
repeated int32 copyValue_upper_no_underscore_primitive_repeated = 1518;
|
||||
|
||||
repeated self copy_val_lower_message_repeated = 1519;
|
||||
repeated self copy_Val_upper_message_repeated = 1520;
|
||||
repeated self copyvalue_lower_no_underscore_message_repeated = 1521;
|
||||
repeated self copyValue_upper_no_underscore_message_repeated = 1522;
|
||||
|
||||
repeated Foo copy_val_lower_enum_repeated = 1523;
|
||||
repeated Foo copy_Val_upper_enum_repeated = 1524;
|
||||
repeated Foo copyvalue_lower_no_underscore_enum_repeated = 1525;
|
||||
repeated Foo copyValue_upper_no_underscore_enum_repeated = 1526;
|
||||
|
||||
optional string mutableCopy_val_lower_complex = 1611;
|
||||
optional string mutableCopy_Val_upper_complex = 1612;
|
||||
optional string mutableCopyvalue_lower_no_underscore_complex = 1613;
|
||||
optional string mutableCopyValue_upper_no_underscore_complex = 1614;
|
||||
|
||||
optional int32 mutableCopy_val_lower_primitive = 1615;
|
||||
optional int32 mutableCopy_Val_upper_primitive = 1616;
|
||||
optional int32 mutableCopyvalue_lower_no_underscore_primitive = 1617;
|
||||
optional int32 mutableCopyValue_upper_no_underscore_primitive = 1618;
|
||||
|
||||
optional self mutableCopy_val_lower_message = 1619;
|
||||
optional self mutableCopy_Val_upper_message = 1620;
|
||||
optional self mutableCopyvalue_lower_no_underscore_message = 1621;
|
||||
optional self mutableCopyValue_upper_no_underscore_message = 1622;
|
||||
|
||||
optional Foo mutableCopy_val_lower_enum = 1623;
|
||||
optional Foo mutableCopy_Val_upper_enum = 1624;
|
||||
optional Foo mutableCopyvalue_lower_no_underscore_enum = 1625;
|
||||
optional Foo mutableCopyValue_upper_no_underscore_enum = 1626;
|
||||
|
||||
repeated string mutableCopy_val_lower_complex_repeated = 1711;
|
||||
repeated string mutableCopy_Val_upper_complex_repeated = 1712;
|
||||
repeated string mutableCopyvalue_lower_no_underscore_complex_repeated = 1713;
|
||||
repeated string mutableCopyValue_upper_no_underscore_complex_repeated = 1714;
|
||||
|
||||
repeated int32 mutableCopy_val_lower_primitive_repeated = 1715;
|
||||
repeated int32 mutableCopy_Val_upper_primitive_repeated = 1716;
|
||||
repeated int32 mutableCopyvalue_lower_no_underscore_primitive_repeated = 1717;
|
||||
repeated int32 mutableCopyValue_upper_no_underscore_primitive_repeated = 1718;
|
||||
|
||||
repeated self mutableCopy_val_lower_message_repeated = 1719;
|
||||
repeated self mutableCopy_Val_upper_message_repeated = 1720;
|
||||
repeated self mutableCopyvalue_lower_no_underscore_message_repeated = 1721;
|
||||
repeated self mutableCopyValue_upper_no_underscore_message_repeated = 1722;
|
||||
|
||||
repeated Foo mutableCopy_val_lower_enum_repeated = 1723;
|
||||
repeated Foo mutableCopy_Val_upper_enum_repeated = 1724;
|
||||
repeated Foo mutableCopyvalue_lower_no_underscore_enum_repeated = 1725;
|
||||
repeated Foo mutableCopyValue_upper_no_underscore_enum_repeated = 1726;
|
||||
}
|
||||
|
||||
message JustToScopeExtensions {
|
||||
extend ObjCRetainedFoo {
|
||||
optional string new_val_lower_complex = 2011;
|
||||
optional string new_Val_upper_complex = 2012;
|
||||
optional string newvalue_lower_no_underscore_complex = 2013;
|
||||
optional string newValue_upper_no_underscore_complex = 2014;
|
||||
|
||||
optional int32 new_val_lower_primitive = 2015;
|
||||
optional int32 new_Val_upper_primitive = 2016;
|
||||
optional int32 newvalue_lower_no_underscore_primitive = 2017;
|
||||
optional int32 newValue_upper_no_underscore_primitive = 2018;
|
||||
|
||||
optional self new_val_lower_message = 2019;
|
||||
optional self new_Val_upper_message = 2020;
|
||||
optional self newvalue_lower_no_underscore_message = 2021;
|
||||
optional self newValue_upper_no_underscore_message = 2022;
|
||||
|
||||
optional Foo new_val_lower_enum = 2023;
|
||||
optional Foo new_Val_upper_enum = 2024;
|
||||
optional Foo newvalue_lower_no_underscore_enum = 2025;
|
||||
optional Foo newValue_upper_no_underscore_enum = 2026;
|
||||
|
||||
repeated string new_val_lower_complex_repeated = 2111;
|
||||
repeated string new_Val_upper_complex_repeated = 2112;
|
||||
repeated string newvalue_lower_no_underscore_complex_repeated = 2113;
|
||||
repeated string newValue_upper_no_underscore_complex_repeated = 2114;
|
||||
|
||||
repeated int32 new_val_lower_primitive_repeated = 2115;
|
||||
repeated int32 new_Val_upper_primitive_repeated = 2116;
|
||||
repeated int32 newvalue_lower_no_underscore_primitive_repeated = 2117;
|
||||
repeated int32 newValue_upper_no_underscore_primitive_repeated = 2118;
|
||||
|
||||
repeated self new_val_lower_message_repeated = 2119;
|
||||
repeated self new_Val_upper_message_repeated = 2120;
|
||||
repeated self newvalue_lower_no_underscore_message_repeated = 2121;
|
||||
repeated self newValue_upper_no_underscore_message_repeated = 2122;
|
||||
|
||||
repeated Foo new_val_lower_enum_repeated = 2123;
|
||||
repeated Foo new_Val_upper_enum_repeated = 2124;
|
||||
repeated Foo newvalue_lower_no_underscore_enum_repeated = 2125;
|
||||
repeated Foo newValue_upper_no_underscore_enum_repeated = 2126;
|
||||
|
||||
optional string alloc_val_lower_complex = 2211;
|
||||
optional string alloc_Val_upper_complex = 2212;
|
||||
optional string allocvalue_lower_no_underscore_complex = 2213;
|
||||
optional string allocValue_upper_no_underscore_complex = 2214;
|
||||
|
||||
optional int32 alloc_val_lower_primitive = 2215;
|
||||
optional int32 alloc_Val_upper_primitive = 2216;
|
||||
optional int32 allocvalue_lower_no_underscore_primitive = 2217;
|
||||
optional int32 allocValue_upper_no_underscore_primitive = 2218;
|
||||
|
||||
optional self alloc_val_lower_message = 2219;
|
||||
optional self alloc_Val_upper_message = 2220;
|
||||
optional self allocvalue_lower_no_underscore_message = 2221;
|
||||
optional self allocValue_upper_no_underscore_message = 2222;
|
||||
|
||||
optional Foo alloc_val_lower_enum = 2223;
|
||||
optional Foo alloc_Val_upper_enum = 2224;
|
||||
optional Foo allocvalue_lower_no_underscore_enum = 2225;
|
||||
optional Foo allocValue_upper_no_underscore_enum = 2226;
|
||||
|
||||
repeated string alloc_val_lower_complex_repeated = 2311;
|
||||
repeated string alloc_Val_upper_complex_repeated = 2312;
|
||||
repeated string allocvalue_lower_no_underscore_complex_repeated = 2313;
|
||||
repeated string allocValue_upper_no_underscore_complex_repeated = 2314;
|
||||
|
||||
repeated int32 alloc_val_lower_primitive_repeated = 2315;
|
||||
repeated int32 alloc_Val_upper_primitive_repeated = 2316;
|
||||
repeated int32 allocvalue_lower_no_underscore_primitive_repeated = 2317;
|
||||
repeated int32 allocValue_upper_no_underscore_primitive_repeated = 2318;
|
||||
|
||||
repeated self alloc_val_lower_message_repeated = 2319;
|
||||
repeated self alloc_Val_upper_message_repeated = 2320;
|
||||
repeated self allocvalue_lower_no_underscore_message_repeated = 2321;
|
||||
repeated self allocValue_upper_no_underscore_message_repeated = 2322;
|
||||
|
||||
repeated Foo alloc_val_lower_enum_repeated = 2323;
|
||||
repeated Foo alloc_Val_upper_enum_repeated = 2324;
|
||||
repeated Foo allocvalue_lower_no_underscore_enum_repeated = 2325;
|
||||
repeated Foo allocValue_upper_no_underscore_enum_repeated = 2326;
|
||||
|
||||
optional string copy_val_lower_complex = 2411;
|
||||
optional string copy_Val_upper_complex = 2412;
|
||||
optional string copyvalue_lower_no_underscore_complex = 2413;
|
||||
optional string copyValue_upper_no_underscore_complex = 2414;
|
||||
|
||||
optional int32 copy_val_lower_primitive = 2415;
|
||||
optional int32 copy_Val_upper_primitive = 2416;
|
||||
optional int32 copyvalue_lower_no_underscore_primitive = 2417;
|
||||
optional int32 copyValue_upper_no_underscore_primitive = 2418;
|
||||
|
||||
optional self copy_val_lower_message = 2419;
|
||||
optional self copy_Val_upper_message = 2420;
|
||||
optional self copyvalue_lower_no_underscore_message = 2421;
|
||||
optional self copyValue_upper_no_underscore_message = 2422;
|
||||
|
||||
optional Foo copy_val_lower_enum = 2423;
|
||||
optional Foo copy_Val_upper_enum = 2424;
|
||||
optional Foo copyvalue_lower_no_underscore_enum = 2425;
|
||||
optional Foo copyValue_upper_no_underscore_enum = 2426;
|
||||
|
||||
repeated string copy_val_lower_complex_repeated = 2511;
|
||||
repeated string copy_Val_upper_complex_repeated = 2512;
|
||||
repeated string copyvalue_lower_no_underscore_complex_repeated = 2513;
|
||||
repeated string copyValue_upper_no_underscore_complex_repeated = 2514;
|
||||
|
||||
repeated int32 copy_val_lower_primitive_repeated = 2515;
|
||||
repeated int32 copy_Val_upper_primitive_repeated = 2516;
|
||||
repeated int32 copyvalue_lower_no_underscore_primitive_repeated = 2517;
|
||||
repeated int32 copyValue_upper_no_underscore_primitive_repeated = 2518;
|
||||
|
||||
repeated self copy_val_lower_message_repeated = 2519;
|
||||
repeated self copy_Val_upper_message_repeated = 2520;
|
||||
repeated self copyvalue_lower_no_underscore_message_repeated = 2521;
|
||||
repeated self copyValue_upper_no_underscore_message_repeated = 2522;
|
||||
|
||||
repeated Foo copy_val_lower_enum_repeated = 2523;
|
||||
repeated Foo copy_Val_upper_enum_repeated = 2524;
|
||||
repeated Foo copyvalue_lower_no_underscore_enum_repeated = 2525;
|
||||
repeated Foo copyValue_upper_no_underscore_enum_repeated = 2526;
|
||||
|
||||
optional string mutableCopy_val_lower_complex = 2611;
|
||||
optional string mutableCopy_Val_upper_complex = 2612;
|
||||
optional string mutableCopyvalue_lower_no_underscore_complex = 2613;
|
||||
optional string mutableCopyValue_upper_no_underscore_complex = 2614;
|
||||
|
||||
optional int32 mutableCopy_val_lower_primitive = 2615;
|
||||
optional int32 mutableCopy_Val_upper_primitive = 2616;
|
||||
optional int32 mutableCopyvalue_lower_no_underscore_primitive = 2617;
|
||||
optional int32 mutableCopyValue_upper_no_underscore_primitive = 2618;
|
||||
|
||||
optional self mutableCopy_val_lower_message = 2619;
|
||||
optional self mutableCopy_Val_upper_message = 2620;
|
||||
optional self mutableCopyvalue_lower_no_underscore_message = 2621;
|
||||
optional self mutableCopyValue_upper_no_underscore_message = 2622;
|
||||
|
||||
optional Foo mutableCopy_val_lower_enum = 2623;
|
||||
optional Foo mutableCopy_Val_upper_enum = 2624;
|
||||
optional Foo mutableCopyvalue_lower_no_underscore_enum = 2625;
|
||||
optional Foo mutableCopyValue_upper_no_underscore_enum = 2626;
|
||||
|
||||
repeated string mutableCopy_val_lower_complex_repeated = 2711;
|
||||
repeated string mutableCopy_Val_upper_complex_repeated = 2712;
|
||||
repeated string mutableCopyvalue_lower_no_underscore_complex_repeated = 2713;
|
||||
repeated string mutableCopyValue_upper_no_underscore_complex_repeated = 2714;
|
||||
|
||||
repeated int32 mutableCopy_val_lower_primitive_repeated = 2715;
|
||||
repeated int32 mutableCopy_Val_upper_primitive_repeated = 2716;
|
||||
repeated int32 mutableCopyvalue_lower_no_underscore_primitive_repeated = 2717;
|
||||
repeated int32 mutableCopyValue_upper_no_underscore_primitive_repeated = 2718;
|
||||
|
||||
repeated self mutableCopy_val_lower_message_repeated = 2719;
|
||||
repeated self mutableCopy_Val_upper_message_repeated = 2720;
|
||||
repeated self mutableCopyvalue_lower_no_underscore_message_repeated = 2721;
|
||||
repeated self mutableCopyValue_upper_no_underscore_message_repeated = 2722;
|
||||
|
||||
repeated Foo mutableCopy_val_lower_enum_repeated = 2723;
|
||||
repeated Foo mutableCopy_Val_upper_enum_repeated = 2724;
|
||||
repeated Foo mutableCopyvalue_lower_no_underscore_enum_repeated = 2725;
|
||||
repeated Foo mutableCopyValue_upper_no_underscore_enum_repeated = 2726;
|
||||
}
|
||||
}
|
||||
|
||||
// Test handling of fields that are the retained names.
|
||||
message ObjCRetainedComplex {
|
||||
optional string new = 1;
|
||||
optional string alloc = 2;
|
||||
optional string copy = 3;
|
||||
optional string mutableCopy = 4;
|
||||
}
|
||||
|
||||
message ObjCRetainedComplexRepeated {
|
||||
repeated string new = 1;
|
||||
repeated string alloc = 2;
|
||||
repeated string copy = 3;
|
||||
repeated string mutableCopy = 4;
|
||||
}
|
||||
|
||||
message ObjCRetainedPrimitive {
|
||||
optional int32 new = 1;
|
||||
optional int32 alloc = 2;
|
||||
optional int32 copy = 3;
|
||||
optional int32 mutableCopy = 4;
|
||||
}
|
||||
|
||||
message ObjCRetainedPrimitiveRepeated {
|
||||
repeated int32 new = 1;
|
||||
repeated int32 alloc = 2;
|
||||
repeated int32 copy = 3;
|
||||
repeated int32 mutableCopy = 4;
|
||||
}
|
||||
|
||||
message ObjCRetainedMessage {
|
||||
optional self new = 1;
|
||||
optional self alloc = 2;
|
||||
optional self copy = 3;
|
||||
optional self mutableCopy = 4;
|
||||
}
|
||||
|
||||
message ObjCRetainedMessageRepeated {
|
||||
repeated self new = 1;
|
||||
repeated self alloc = 2;
|
||||
repeated self copy = 3;
|
||||
repeated self mutableCopy = 4;
|
||||
}
|
||||
|
||||
// Test Handling some MacTypes
|
||||
message Point {
|
||||
message Rect {
|
||||
optional int32 TimeValue = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Test some weird defaults that we see in protos.
|
||||
message ObjcWeirdDefaults {
|
||||
// Set default values that match the protocol buffer defined defaults to
|
||||
// confirm hasDefault and the default values are set correctly.
|
||||
optional string foo = 1 [default = ""];
|
||||
optional bytes bar = 2 [default = ""];
|
||||
}
|
||||
|
||||
// Used to confirm negative enum values work as expected.
|
||||
message EnumTestMsg {
|
||||
enum MyEnum {
|
||||
ZERO = 0;
|
||||
ONE = 1;
|
||||
TWO = 2;
|
||||
NEG_ONE = -1;
|
||||
NEG_TWO = -2;
|
||||
}
|
||||
optional MyEnum foo = 1;
|
||||
optional MyEnum bar = 2 [default = ONE];
|
||||
optional MyEnum baz = 3 [default = NEG_ONE];
|
||||
|
||||
repeated MyEnum mumble = 4;
|
||||
}
|
||||
|
||||
// Test case for https://github.com/protocolbuffers/protobuf/issues/1453
|
||||
// Message with no explicit defaults, but a non zero default for an enum.
|
||||
message MessageWithOneBasedEnum {
|
||||
enum OneBasedEnum {
|
||||
ONE = 1;
|
||||
TWO = 2;
|
||||
}
|
||||
optional OneBasedEnum enum_field = 1;
|
||||
}
|
||||
|
||||
// Message with all bools for testing things related to bool storage.
|
||||
message BoolOnlyMessage {
|
||||
optional bool bool_field_1 = 1;
|
||||
optional bool bool_field_2 = 2;
|
||||
optional bool bool_field_3 = 3;
|
||||
optional bool bool_field_4 = 4;
|
||||
optional bool bool_field_5 = 5;
|
||||
optional bool bool_field_6 = 6;
|
||||
optional bool bool_field_7 = 7;
|
||||
optional bool bool_field_8 = 8;
|
||||
optional bool bool_field_9 = 9;
|
||||
optional bool bool_field_10 = 10;
|
||||
optional bool bool_field_11 = 11;
|
||||
optional bool bool_field_12 = 12;
|
||||
optional bool bool_field_13 = 13;
|
||||
optional bool bool_field_14 = 14;
|
||||
optional bool bool_field_15 = 15;
|
||||
optional bool bool_field_16 = 16;
|
||||
optional bool bool_field_17 = 17;
|
||||
optional bool bool_field_18 = 18;
|
||||
optional bool bool_field_19 = 19;
|
||||
optional bool bool_field_20 = 20;
|
||||
optional bool bool_field_21 = 21;
|
||||
optional bool bool_field_22 = 22;
|
||||
optional bool bool_field_23 = 23;
|
||||
optional bool bool_field_24 = 24;
|
||||
optional bool bool_field_25 = 25;
|
||||
optional bool bool_field_26 = 26;
|
||||
optional bool bool_field_27 = 27;
|
||||
optional bool bool_field_28 = 28;
|
||||
optional bool bool_field_29 = 29;
|
||||
optional bool bool_field_30 = 30;
|
||||
optional bool bool_field_31 = 31;
|
||||
optional bool bool_field_32 = 32;
|
||||
}
|
||||
|
||||
// Reference to a WKT to test (via generated code inspection), the handling
|
||||
// of #imports. Within the WKTs, references to each other are just path
|
||||
// based imports, but when reference from another proto file, they should be
|
||||
// conditional to support the framework import style.
|
||||
message WKTRefereceMessage {
|
||||
optional google.protobuf.Any an_any = 1;
|
||||
}
|
||||
|
||||
// This is in part a compile test, it ensures that when aliases end up with
|
||||
// the same ObjC name, we drop them to avoid the duplication names. There
|
||||
// is a test to ensure the descriptors are still generated to support
|
||||
// reflection and TextFormat.
|
||||
enum TestEnumObjCNameCollision {
|
||||
option allow_alias = true;
|
||||
|
||||
FOO = 1;
|
||||
foo = 1;
|
||||
|
||||
BAR = 2;
|
||||
mumble = 2;
|
||||
MUMBLE = 2;
|
||||
}
|
||||
68
objectivec/Tests/unittest_objc_options.proto
Normal file
68
objectivec/Tests/unittest_objc_options.proto
Normal file
@@ -0,0 +1,68 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.options;
|
||||
|
||||
option objc_class_prefix = "GPBTEST";
|
||||
|
||||
// Verify that enum types and values get the prefix.
|
||||
message TestObjcProtoPrefixMessage {
|
||||
}
|
||||
|
||||
// Verify that messages that don't already have the prefix get a prefix.
|
||||
enum TestObjcProtoPrefixEnum {
|
||||
value = 1;
|
||||
}
|
||||
|
||||
// Verify that messages that already have a prefix aren't prefixed twice.
|
||||
message GPBTESTTestHasAPrefixMessage {
|
||||
}
|
||||
|
||||
// Verify that enums that already have a prefix aren't prefixed twice.
|
||||
enum GPBTESTTestHasAPrefixEnum {
|
||||
valueB = 1;
|
||||
}
|
||||
|
||||
// Verify that classes that have the prefix followed by a lowercase
|
||||
// letter DO get the prefix.
|
||||
message GPBTESTshouldGetAPrefixMessage {
|
||||
}
|
||||
|
||||
// Verify that classes named the same as prefixes are prefixed.
|
||||
message GPBTEST {
|
||||
}
|
||||
|
||||
// Tests that lookup deals with prefix.
|
||||
message PrefixedParentMessage {
|
||||
message Child {
|
||||
}
|
||||
}
|
||||
50
objectivec/Tests/unittest_objc_startup.proto
Normal file
50
objectivec/Tests/unittest_objc_startup.proto
Normal file
@@ -0,0 +1,50 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.startup;
|
||||
option objc_class_prefix = "TestObjCStartup";
|
||||
|
||||
message Message {
|
||||
extensions 1 to max;
|
||||
}
|
||||
|
||||
extend Message {
|
||||
// Singular
|
||||
optional int32 optional_int32_extension = 1;
|
||||
repeated int32 repeated_int32_extension = 2;
|
||||
}
|
||||
|
||||
message Nested {
|
||||
extend Message {
|
||||
optional string nested_string_extension = 3;
|
||||
}
|
||||
}
|
||||
69
objectivec/Tests/unittest_preserve_unknown_enum.proto
Normal file
69
objectivec/Tests/unittest_preserve_unknown_enum.proto
Normal file
@@ -0,0 +1,69 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// 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
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package objc.protobuf.tests.proto3_preserve_unknown_enum;
|
||||
option objc_class_prefix = "UnknownEnums";
|
||||
|
||||
enum MyEnum {
|
||||
FOO = 0;
|
||||
BAR = 1;
|
||||
BAZ = 2;
|
||||
}
|
||||
|
||||
enum MyEnumPlusExtra {
|
||||
E_FOO = 0;
|
||||
E_BAR = 1;
|
||||
E_BAZ = 2;
|
||||
E_EXTRA = 3;
|
||||
}
|
||||
|
||||
message MyMessage {
|
||||
MyEnum e = 1;
|
||||
repeated MyEnum repeated_e = 2;
|
||||
repeated MyEnum repeated_packed_e = 3 [packed=true];
|
||||
repeated MyEnumPlusExtra repeated_packed_unexpected_e = 4; // not packed
|
||||
oneof o {
|
||||
MyEnum oneof_e_1 = 5;
|
||||
MyEnum oneof_e_2 = 6;
|
||||
}
|
||||
}
|
||||
|
||||
message MyMessagePlusExtra {
|
||||
MyEnumPlusExtra e = 1;
|
||||
repeated MyEnumPlusExtra repeated_e = 2;
|
||||
repeated MyEnumPlusExtra repeated_packed_e = 3 [packed=true];
|
||||
repeated MyEnumPlusExtra repeated_packed_unexpected_e = 4 [packed=true];
|
||||
oneof o {
|
||||
MyEnumPlusExtra oneof_e_1 = 5;
|
||||
MyEnumPlusExtra oneof_e_2 = 6;
|
||||
}
|
||||
}
|
||||
131
objectivec/Tests/unittest_runtime_proto2.proto
Normal file
131
objectivec/Tests/unittest_runtime_proto2.proto
Normal file
@@ -0,0 +1,131 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
// Explicit empty prefix, tests some validations code paths also.
|
||||
package objc.protobuf.tests;
|
||||
|
||||
option objc_class_prefix = "";
|
||||
|
||||
message Message2 {
|
||||
enum Enum {
|
||||
FOO = 0;
|
||||
BAR = 1;
|
||||
BAZ = 2;
|
||||
EXTRA_2 = 20;
|
||||
}
|
||||
|
||||
optional int32 optional_int32 = 1;
|
||||
optional int64 optional_int64 = 2;
|
||||
optional uint32 optional_uint32 = 3;
|
||||
optional uint64 optional_uint64 = 4;
|
||||
optional sint32 optional_sint32 = 5;
|
||||
optional sint64 optional_sint64 = 6;
|
||||
optional fixed32 optional_fixed32 = 7;
|
||||
optional fixed64 optional_fixed64 = 8;
|
||||
optional sfixed32 optional_sfixed32 = 9;
|
||||
optional sfixed64 optional_sfixed64 = 10;
|
||||
optional float optional_float = 11;
|
||||
optional double optional_double = 12;
|
||||
optional bool optional_bool = 13;
|
||||
optional string optional_string = 14;
|
||||
optional bytes optional_bytes = 15;
|
||||
optional group OptionalGroup = 16 {
|
||||
optional int32 a = 17;
|
||||
}
|
||||
optional Message2 optional_message = 18;
|
||||
optional Enum optional_enum = 19;
|
||||
|
||||
repeated int32 repeated_int32 = 31;
|
||||
repeated int64 repeated_int64 = 32;
|
||||
repeated uint32 repeated_uint32 = 33;
|
||||
repeated uint64 repeated_uint64 = 34;
|
||||
repeated sint32 repeated_sint32 = 35;
|
||||
repeated sint64 repeated_sint64 = 36;
|
||||
repeated fixed32 repeated_fixed32 = 37;
|
||||
repeated fixed64 repeated_fixed64 = 38;
|
||||
repeated sfixed32 repeated_sfixed32 = 39;
|
||||
repeated sfixed64 repeated_sfixed64 = 40;
|
||||
repeated float repeated_float = 41;
|
||||
repeated double repeated_double = 42;
|
||||
repeated bool repeated_bool = 43;
|
||||
repeated string repeated_string = 44;
|
||||
repeated bytes repeated_bytes = 45;
|
||||
repeated group RepeatedGroup = 46 {
|
||||
optional int32 a = 47;
|
||||
}
|
||||
repeated Message2 repeated_message = 48;
|
||||
repeated Enum repeated_enum = 49;
|
||||
|
||||
oneof o {
|
||||
int32 oneof_int32 = 51 [default = 100];
|
||||
int64 oneof_int64 = 52 [default = 101];
|
||||
uint32 oneof_uint32 = 53 [default = 102];
|
||||
uint64 oneof_uint64 = 54 [default = 103];
|
||||
sint32 oneof_sint32 = 55 [default = 104];
|
||||
sint64 oneof_sint64 = 56 [default = 105];
|
||||
fixed32 oneof_fixed32 = 57 [default = 106];
|
||||
fixed64 oneof_fixed64 = 58 [default = 107];
|
||||
sfixed32 oneof_sfixed32 = 59 [default = 108];
|
||||
sfixed64 oneof_sfixed64 = 60 [default = 109];
|
||||
float oneof_float = 61 [default = 110];
|
||||
double oneof_double = 62 [default = 111];
|
||||
bool oneof_bool = 63 [default = true];
|
||||
string oneof_string = 64 [default = "string"];
|
||||
bytes oneof_bytes = 65 [default = "data"];
|
||||
group OneofGroup = 66 {
|
||||
optional int32 a = 67;
|
||||
optional int32 b = 167;
|
||||
}
|
||||
Message2 oneof_message = 68;
|
||||
Enum oneof_enum = 69 [default = BAZ];
|
||||
}
|
||||
|
||||
// Some token map cases, too many combinations to list them all.
|
||||
map<int32 , int32 > map_int32_int32 = 70;
|
||||
map<int64 , int64 > map_int64_int64 = 71;
|
||||
map<uint32 , uint32 > map_uint32_uint32 = 72;
|
||||
map<uint64 , uint64 > map_uint64_uint64 = 73;
|
||||
map<sint32 , sint32 > map_sint32_sint32 = 74;
|
||||
map<sint64 , sint64 > map_sint64_sint64 = 75;
|
||||
map<fixed32 , fixed32 > map_fixed32_fixed32 = 76;
|
||||
map<fixed64 , fixed64 > map_fixed64_fixed64 = 77;
|
||||
map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 78;
|
||||
map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 79;
|
||||
map<int32 , float > map_int32_float = 80;
|
||||
map<int32 , double > map_int32_double = 81;
|
||||
map<bool , bool > map_bool_bool = 82;
|
||||
map<string , string > map_string_string = 83;
|
||||
map<string , bytes > map_string_bytes = 84;
|
||||
map<string , Message2> map_string_message = 85;
|
||||
map<int32 , bytes > map_int32_bytes = 86;
|
||||
map<int32 , Enum > map_int32_enum = 87;
|
||||
map<int32 , Message2> map_int32_message = 88;
|
||||
}
|
||||
152
objectivec/Tests/unittest_runtime_proto3.proto
Normal file
152
objectivec/Tests/unittest_runtime_proto3.proto
Normal file
@@ -0,0 +1,152 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
// Explicit empty prefix, tests some validations code paths also.
|
||||
package objc.protobuf.tests;
|
||||
|
||||
option objc_class_prefix = "";
|
||||
|
||||
message Message3 {
|
||||
enum Enum {
|
||||
FOO = 0;
|
||||
BAR = 1;
|
||||
BAZ = 2;
|
||||
EXTRA_3 = 30;
|
||||
}
|
||||
|
||||
int32 optional_int32 = 1;
|
||||
int64 optional_int64 = 2;
|
||||
uint32 optional_uint32 = 3;
|
||||
uint64 optional_uint64 = 4;
|
||||
sint32 optional_sint32 = 5;
|
||||
sint64 optional_sint64 = 6;
|
||||
fixed32 optional_fixed32 = 7;
|
||||
fixed64 optional_fixed64 = 8;
|
||||
sfixed32 optional_sfixed32 = 9;
|
||||
sfixed64 optional_sfixed64 = 10;
|
||||
float optional_float = 11;
|
||||
double optional_double = 12;
|
||||
bool optional_bool = 13;
|
||||
string optional_string = 14;
|
||||
bytes optional_bytes = 15;
|
||||
// No 'group' in proto3.
|
||||
Message3 optional_message = 18;
|
||||
Enum optional_enum = 19;
|
||||
|
||||
repeated int32 repeated_int32 = 31;
|
||||
repeated int64 repeated_int64 = 32;
|
||||
repeated uint32 repeated_uint32 = 33;
|
||||
repeated uint64 repeated_uint64 = 34;
|
||||
repeated sint32 repeated_sint32 = 35;
|
||||
repeated sint64 repeated_sint64 = 36;
|
||||
repeated fixed32 repeated_fixed32 = 37;
|
||||
repeated fixed64 repeated_fixed64 = 38;
|
||||
repeated sfixed32 repeated_sfixed32 = 39;
|
||||
repeated sfixed64 repeated_sfixed64 = 40;
|
||||
repeated float repeated_float = 41;
|
||||
repeated double repeated_double = 42;
|
||||
repeated bool repeated_bool = 43;
|
||||
repeated string repeated_string = 44;
|
||||
repeated bytes repeated_bytes = 45;
|
||||
// No 'group' in proto3.
|
||||
repeated Message3 repeated_message = 48;
|
||||
repeated Enum repeated_enum = 49;
|
||||
|
||||
oneof o {
|
||||
int32 oneof_int32 = 51;
|
||||
int64 oneof_int64 = 52;
|
||||
uint32 oneof_uint32 = 53;
|
||||
uint64 oneof_uint64 = 54;
|
||||
sint32 oneof_sint32 = 55;
|
||||
sint64 oneof_sint64 = 56;
|
||||
fixed32 oneof_fixed32 = 57;
|
||||
fixed64 oneof_fixed64 = 58;
|
||||
sfixed32 oneof_sfixed32 = 59;
|
||||
sfixed64 oneof_sfixed64 = 60;
|
||||
float oneof_float = 61;
|
||||
double oneof_double = 62;
|
||||
bool oneof_bool = 63;
|
||||
string oneof_string = 64;
|
||||
bytes oneof_bytes = 65;
|
||||
// No 'group' in proto3.
|
||||
Message3 oneof_message = 68;
|
||||
Enum oneof_enum = 69;
|
||||
}
|
||||
|
||||
// Some token map cases, too many combinations to list them all.
|
||||
map<int32 , int32 > map_int32_int32 = 70;
|
||||
map<int64 , int64 > map_int64_int64 = 71;
|
||||
map<uint32 , uint32 > map_uint32_uint32 = 72;
|
||||
map<uint64 , uint64 > map_uint64_uint64 = 73;
|
||||
map<sint32 , sint32 > map_sint32_sint32 = 74;
|
||||
map<sint64 , sint64 > map_sint64_sint64 = 75;
|
||||
map<fixed32 , fixed32 > map_fixed32_fixed32 = 76;
|
||||
map<fixed64 , fixed64 > map_fixed64_fixed64 = 77;
|
||||
map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 78;
|
||||
map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 79;
|
||||
map<int32 , float > map_int32_float = 80;
|
||||
map<int32 , double > map_int32_double = 81;
|
||||
map<bool , bool > map_bool_bool = 82;
|
||||
map<string , string > map_string_string = 83;
|
||||
map<string , bytes > map_string_bytes = 84;
|
||||
map<string , Message3> map_string_message = 85;
|
||||
map<int32 , bytes > map_int32_bytes = 86;
|
||||
map<int32 , Enum > map_int32_enum = 87;
|
||||
map<int32 , Message3> map_int32_message = 88;
|
||||
}
|
||||
|
||||
message Message3Optional {
|
||||
enum Enum {
|
||||
FOO = 0;
|
||||
BAR = 1;
|
||||
BAZ = 2;
|
||||
EXTRA_3 = 30;
|
||||
}
|
||||
|
||||
optional int32 optional_int32 = 1;
|
||||
optional int64 optional_int64 = 2;
|
||||
optional uint32 optional_uint32 = 3;
|
||||
optional uint64 optional_uint64 = 4;
|
||||
optional sint32 optional_sint32 = 5;
|
||||
optional sint64 optional_sint64 = 6;
|
||||
optional fixed32 optional_fixed32 = 7;
|
||||
optional fixed64 optional_fixed64 = 8;
|
||||
optional sfixed32 optional_sfixed32 = 9;
|
||||
optional sfixed64 optional_sfixed64 = 10;
|
||||
optional float optional_float = 11;
|
||||
optional double optional_double = 12;
|
||||
optional bool optional_bool = 13;
|
||||
optional string optional_string = 14;
|
||||
optional bytes optional_bytes = 15;
|
||||
// No 'group' in proto3.
|
||||
optional Message3 optional_message = 18;
|
||||
optional Enum optional_enum = 19;
|
||||
}
|
||||
Reference in New Issue
Block a user