ADD: added new version of protobuf
This commit is contained in:
@@ -34,16 +34,30 @@
|
||||
|
||||
// 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"
|
||||
// The unittest_custom_options.proto extends the messages in descriptor.proto
|
||||
// so we build it in to test extending in general. The library doesn't provide
|
||||
// a descriptor as it doesn't use the classes/enums.
|
||||
#import "google/protobuf/Descriptor.pbobjc.h"
|
||||
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/UnittestCustomOptions.pbobjc.h"
|
||||
#import "google/protobuf/UnittestCycle.pbobjc.h"
|
||||
#import "google/protobuf/UnittestDeprecated.pbobjc.h"
|
||||
#import "google/protobuf/UnittestDeprecatedFile.pbobjc.h"
|
||||
#import "google/protobuf/UnittestDropUnknownFields.pbobjc.h"
|
||||
#import "google/protobuf/UnittestEmbedOptimizeFor.pbobjc.h"
|
||||
#import "google/protobuf/UnittestEmpty.pbobjc.h"
|
||||
#import "google/protobuf/UnittestEnormousDescriptor.pbobjc.h"
|
||||
#import "google/protobuf/UnittestImport.pbobjc.h"
|
||||
#import "google/protobuf/UnittestImportLite.pbobjc.h"
|
||||
#import "google/protobuf/UnittestImportPublic.pbobjc.h"
|
||||
#import "google/protobuf/UnittestImportPublicLite.pbobjc.h"
|
||||
#import "google/protobuf/UnittestLite.pbobjc.h"
|
||||
#import "google/protobuf/UnittestMset.pbobjc.h"
|
||||
#import "google/protobuf/UnittestNoGenericServices.pbobjc.h"
|
||||
#import "google/protobuf/UnittestObjc.pbobjc.h"
|
||||
#import "google/protobuf/UnittestObjcStartup.pbobjc.h"
|
||||
#import "google/protobuf/UnittestOptimizeFor.pbobjc.h"
|
||||
#import "google/protobuf/UnittestPreserveUnknownEnum.pbobjc.h"
|
||||
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
|
||||
#import "google/protobuf/UnittestRuntimeProto3.pbobjc.h"
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
@interface GPBEnumArray (TestingTweak)
|
||||
+ (instancetype)arrayWithValue:(int32_t)value;
|
||||
+ (instancetype)arrayWithCapacity:(NSUInteger)count;
|
||||
- (instancetype)initWithValues:(const int32_t[])values count:(NSUInteger)count;
|
||||
- (instancetype)initWithValues:(const int32_t [])values
|
||||
count:(NSUInteger)count;
|
||||
@end
|
||||
|
||||
static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
@@ -76,16 +77,16 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
return [[[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
capacity:count] autorelease];
|
||||
}
|
||||
- (instancetype)initWithValues:(const int32_t[])values count:(NSUInteger)count {
|
||||
return [self initWithValidationFunction:TestingEnum_IsValidValue rawValues:values count:count];
|
||||
- (instancetype)initWithValues:(const int32_t [])values
|
||||
count:(NSUInteger)count {
|
||||
return [self initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:values
|
||||
count:count];
|
||||
}
|
||||
@end
|
||||
|
||||
#pragma mark - PDDM Macros
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-DEFINE ARRAY_TESTS(NAME, TYPE, VAL1, VAL2, VAL3, VAL4)
|
||||
//%ARRAY_TESTS2(NAME, TYPE, VAL1, VAL2, VAL3, VAL4, )
|
||||
//%PDDM-DEFINE ARRAY_TESTS2(NAME, TYPE, VAL1, VAL2, VAL3, VAL4, HELPER)
|
||||
@@ -101,11 +102,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
//% XCTAssertNotNil(array);
|
||||
//% XCTAssertEqual(array.count, 0U);
|
||||
//% XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
|
||||
//% [array enumerateValuesWithBlock:^(__unused TYPE value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
//% [array enumerateValuesWithBlock:^(TYPE value, NSUInteger idx, BOOL *stop) {
|
||||
//% #pragma unused(value, idx, stop)
|
||||
//% XCTFail(@"Shouldn't get here!");
|
||||
//% }];
|
||||
//% [array enumerateValuesWithOptions:NSEnumerationReverse
|
||||
//% usingBlock:^(__unused TYPE value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
//% usingBlock:^(TYPE value, NSUInteger idx, BOOL *stop) {
|
||||
//% #pragma unused(value, idx, stop)
|
||||
//% XCTFail(@"Shouldn't get here!");
|
||||
//% }];
|
||||
//% [array release];
|
||||
@@ -430,6 +433,7 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
//%
|
||||
//%PDDM-EXPAND ARRAY_TESTS(Int32, int32_t, 1, 2, 3, 4)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - Int32
|
||||
|
||||
@@ -443,11 +447,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
XCTAssertNotNil(array);
|
||||
XCTAssertEqual(array.count, 0U);
|
||||
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
|
||||
[array enumerateValuesWithBlock:^(__unused int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
[array enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array enumerateValuesWithOptions:NSEnumerationReverse
|
||||
usingBlock:^(__unused int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
usingBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array release];
|
||||
@@ -770,8 +776,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND ARRAY_TESTS(UInt32, uint32_t, 11U, 12U, 13U, 14U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - UInt32
|
||||
|
||||
@@ -785,11 +793,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
XCTAssertNotNil(array);
|
||||
XCTAssertEqual(array.count, 0U);
|
||||
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
|
||||
[array enumerateValuesWithBlock:^(__unused uint32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
[array enumerateValuesWithBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array enumerateValuesWithOptions:NSEnumerationReverse
|
||||
usingBlock:^(__unused uint32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
usingBlock:^(uint32_t value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array release];
|
||||
@@ -1112,8 +1122,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND ARRAY_TESTS(Int64, int64_t, 31LL, 32LL, 33LL, 34LL)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - Int64
|
||||
|
||||
@@ -1127,11 +1139,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
XCTAssertNotNil(array);
|
||||
XCTAssertEqual(array.count, 0U);
|
||||
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
|
||||
[array enumerateValuesWithBlock:^(__unused int64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
[array enumerateValuesWithBlock:^(int64_t value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array enumerateValuesWithOptions:NSEnumerationReverse
|
||||
usingBlock:^(__unused int64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
usingBlock:^(int64_t value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array release];
|
||||
@@ -1454,8 +1468,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND ARRAY_TESTS(UInt64, uint64_t, 41ULL, 42ULL, 43ULL, 44ULL)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - UInt64
|
||||
|
||||
@@ -1469,11 +1485,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
XCTAssertNotNil(array);
|
||||
XCTAssertEqual(array.count, 0U);
|
||||
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
|
||||
[array enumerateValuesWithBlock:^(__unused uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
[array enumerateValuesWithBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array enumerateValuesWithOptions:NSEnumerationReverse
|
||||
usingBlock:^(__unused uint64_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
usingBlock:^(uint64_t value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array release];
|
||||
@@ -1796,8 +1814,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND ARRAY_TESTS(Float, float, 51.f, 52.f, 53.f, 54.f)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - Float
|
||||
|
||||
@@ -1811,11 +1831,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
XCTAssertNotNil(array);
|
||||
XCTAssertEqual(array.count, 0U);
|
||||
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
|
||||
[array enumerateValuesWithBlock:^(__unused float value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
[array enumerateValuesWithBlock:^(float value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array enumerateValuesWithOptions:NSEnumerationReverse
|
||||
usingBlock:^(__unused float value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
usingBlock:^(float value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array release];
|
||||
@@ -2138,8 +2160,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND ARRAY_TESTS(Double, double, 61., 62., 63., 64.)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - Double
|
||||
|
||||
@@ -2153,11 +2177,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
XCTAssertNotNil(array);
|
||||
XCTAssertEqual(array.count, 0U);
|
||||
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
|
||||
[array enumerateValuesWithBlock:^(__unused double value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
[array enumerateValuesWithBlock:^(double value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array enumerateValuesWithOptions:NSEnumerationReverse
|
||||
usingBlock:^(__unused double value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
usingBlock:^(double value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array release];
|
||||
@@ -2480,8 +2506,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND ARRAY_TESTS(Bool, BOOL, TRUE, TRUE, FALSE, FALSE)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - Bool
|
||||
|
||||
@@ -2495,11 +2523,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
XCTAssertNotNil(array);
|
||||
XCTAssertEqual(array.count, 0U);
|
||||
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
|
||||
[array enumerateValuesWithBlock:^(__unused BOOL value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
[array enumerateValuesWithBlock:^(BOOL value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array enumerateValuesWithOptions:NSEnumerationReverse
|
||||
usingBlock:^(__unused BOOL value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
usingBlock:^(BOOL value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array release];
|
||||
@@ -2822,8 +2852,10 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND ARRAY_TESTS2(Enum, int32_t, 71, 72, 73, 74, Raw)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - Enum
|
||||
|
||||
@@ -2837,11 +2869,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
XCTAssertNotNil(array);
|
||||
XCTAssertEqual(array.count, 0U);
|
||||
XCTAssertThrowsSpecificNamed([array valueAtIndex:0], NSException, NSRangeException);
|
||||
[array enumerateValuesWithBlock:^(__unused int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
[array enumerateValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array enumerateValuesWithOptions:NSEnumerationReverse
|
||||
usingBlock:^(__unused int32_t value, __unused NSUInteger idx, __unused BOOL *stop) {
|
||||
usingBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
|
||||
#pragma unused(value, idx, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[array release];
|
||||
@@ -3164,9 +3198,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
|
||||
@end
|
||||
|
||||
//%PDDM-EXPAND-END (8 expansions)
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END (8 expansions)
|
||||
|
||||
#pragma mark - Non macro-based Enum tests
|
||||
|
||||
@@ -3178,13 +3211,15 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
@implementation GPBEnumArrayCustomTests
|
||||
|
||||
- (void)testRawBasics {
|
||||
static const int32_t kValues[] = {71, 272, 73, 374};
|
||||
static const int32_t kValuesFiltered[] = {71, kGPBUnrecognizedEnumeratorValue, 73,
|
||||
kGPBUnrecognizedEnumeratorValue};
|
||||
static const int32_t kValues[] = { 71, 272, 73, 374 };
|
||||
static const int32_t kValuesFiltered[] = {
|
||||
71, kGPBUnrecognizedEnumeratorValue, 73, kGPBUnrecognizedEnumeratorValue
|
||||
};
|
||||
XCTAssertEqual(GPBARRAYSIZE(kValues), GPBARRAYSIZE(kValuesFiltered));
|
||||
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:kValues
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
GPBEnumArray *array =
|
||||
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:kValues
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
XCTAssertNotNil(array);
|
||||
XCTAssertEqual(array.count, 4U);
|
||||
GPBEnumValidationFunc func = TestingEnum_IsValidValue;
|
||||
@@ -3213,19 +3248,19 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
idx2 = 0;
|
||||
[array enumerateRawValuesWithOptions:NSEnumerationReverse
|
||||
usingBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
|
||||
XCTAssertEqual(idx, (3 - idx2));
|
||||
XCTAssertEqual(value, kValues[idx]);
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
++idx2;
|
||||
}];
|
||||
XCTAssertEqual(idx, (3 - idx2));
|
||||
XCTAssertEqual(value, kValues[idx]);
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
++idx2;
|
||||
}];
|
||||
idx2 = 0;
|
||||
[array enumerateValuesWithOptions:NSEnumerationReverse
|
||||
usingBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
|
||||
XCTAssertEqual(idx, (3 - idx2));
|
||||
XCTAssertEqual(value, kValuesFiltered[idx]);
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
++idx2;
|
||||
}];
|
||||
XCTAssertEqual(idx, (3 - idx2));
|
||||
XCTAssertEqual(value, kValuesFiltered[idx]);
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
++idx2;
|
||||
}];
|
||||
// Stopping the enumeration.
|
||||
idx2 = 0;
|
||||
[array enumerateRawValuesWithBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
|
||||
@@ -3240,35 +3275,38 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
idx2 = 0;
|
||||
[array enumerateRawValuesWithOptions:NSEnumerationReverse
|
||||
usingBlock:^(int32_t value, NSUInteger idx, BOOL *stop) {
|
||||
XCTAssertEqual(idx, (3 - idx2));
|
||||
XCTAssertEqual(value, kValues[idx]);
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
if (idx2 == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 1U);
|
||||
XCTAssertNotEqual(idx, 0U);
|
||||
++idx2;
|
||||
}];
|
||||
XCTAssertEqual(idx, (3 - idx2));
|
||||
XCTAssertEqual(value, kValues[idx]);
|
||||
XCTAssertNotEqual(stop, NULL);
|
||||
if (idx2 == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 1U);
|
||||
XCTAssertNotEqual(idx, 0U);
|
||||
++idx2;
|
||||
}];
|
||||
[array release];
|
||||
}
|
||||
|
||||
- (void)testEquality {
|
||||
const int32_t kValues1[] = {71, 72, 173}; // With unknown value
|
||||
const int32_t kValues2[] = {71, 74, 173}; // With unknown value
|
||||
const int32_t kValues3[] = {71, 72, 173, 74}; // With unknown value
|
||||
GPBEnumArray *array1 = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:kValues1
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
const int32_t kValues1[] = { 71, 72, 173 }; // With unknown value
|
||||
const int32_t kValues2[] = { 71, 74, 173 }; // With unknown value
|
||||
const int32_t kValues3[] = { 71, 72, 173, 74 }; // With unknown value
|
||||
GPBEnumArray *array1 =
|
||||
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:kValues1
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
XCTAssertNotNil(array1);
|
||||
GPBEnumArray *array1prime =
|
||||
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue2
|
||||
rawValues:kValues1
|
||||
count:GPBARRAYSIZE(kValues1)];
|
||||
XCTAssertNotNil(array1prime);
|
||||
GPBEnumArray *array2 = [[GPBEnumArray alloc] initWithValues:kValues2
|
||||
count:GPBARRAYSIZE(kValues2)];
|
||||
GPBEnumArray *array2 =
|
||||
[[GPBEnumArray alloc] initWithValues:kValues2
|
||||
count:GPBARRAYSIZE(kValues2)];
|
||||
XCTAssertNotNil(array2);
|
||||
GPBEnumArray *array3 = [[GPBEnumArray alloc] initWithValues:kValues3
|
||||
count:GPBARRAYSIZE(kValues3)];
|
||||
GPBEnumArray *array3 =
|
||||
[[GPBEnumArray alloc] initWithValues:kValues3
|
||||
count:GPBARRAYSIZE(kValues3)];
|
||||
XCTAssertNotNil(array3);
|
||||
|
||||
// 1/1Prime should be different objects, but equal.
|
||||
@@ -3291,11 +3329,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
}
|
||||
|
||||
- (void)testCopy {
|
||||
const int32_t kValues[] = {71, 72};
|
||||
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValues:kValues count:GPBARRAYSIZE(kValues)];
|
||||
const int32_t kValues[] = { 71, 72 };
|
||||
GPBEnumArray *array =
|
||||
[[GPBEnumArray alloc] initWithValues:kValues
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
XCTAssertNotNil(array);
|
||||
|
||||
[array addRawValue:1000]; // Unknown
|
||||
[array addRawValue:1000]; // Unknown
|
||||
XCTAssertEqual(array.count, 3U);
|
||||
XCTAssertEqual([array rawValueAtIndex:0], 71);
|
||||
XCTAssertEqual([array rawValueAtIndex:1], 72);
|
||||
@@ -3320,10 +3360,11 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
}
|
||||
|
||||
- (void)testArrayFromArray {
|
||||
const int32_t kValues[] = {71, 172, 173, 74}; // Unknowns
|
||||
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:kValues
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
const int32_t kValues[] = { 71, 172, 173, 74 }; // Unknowns
|
||||
GPBEnumArray *array =
|
||||
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:kValues
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
XCTAssertNotNil(array);
|
||||
|
||||
GPBEnumArray *array2 = [GPBEnumArray arrayWithValueArray:array];
|
||||
@@ -3337,34 +3378,38 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
}
|
||||
|
||||
- (void)testUnknownAdds {
|
||||
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue];
|
||||
GPBEnumArray *array =
|
||||
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue];
|
||||
XCTAssertNotNil(array);
|
||||
|
||||
XCTAssertThrowsSpecificNamed([array addValue:172], NSException, NSInvalidArgumentException);
|
||||
XCTAssertThrowsSpecificNamed([array addValue:172],
|
||||
NSException, NSInvalidArgumentException);
|
||||
XCTAssertEqual(array.count, 0U);
|
||||
|
||||
const int32_t kValues1[] = {172, 173}; // Unknown
|
||||
XCTAssertThrowsSpecificNamed([array addValues:kValues1 count:GPBARRAYSIZE(kValues1)], NSException,
|
||||
NSInvalidArgumentException);
|
||||
const int32_t kValues1[] = { 172, 173 }; // Unknown
|
||||
XCTAssertThrowsSpecificNamed([array addValues:kValues1 count:GPBARRAYSIZE(kValues1)],
|
||||
NSException, NSInvalidArgumentException);
|
||||
XCTAssertEqual(array.count, 0U);
|
||||
[array release];
|
||||
}
|
||||
|
||||
- (void)testRawAdds {
|
||||
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue];
|
||||
GPBEnumArray *array =
|
||||
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue];
|
||||
XCTAssertNotNil(array);
|
||||
|
||||
XCTAssertEqual(array.count, 0U);
|
||||
[array addRawValue:71]; // Valid
|
||||
XCTAssertEqual(array.count, 1U);
|
||||
|
||||
const int32_t kValues1[] = {172, 173}; // Unknown
|
||||
const int32_t kValues1[] = { 172, 173 }; // Unknown
|
||||
[array addRawValues:kValues1 count:GPBARRAYSIZE(kValues1)];
|
||||
XCTAssertEqual(array.count, 3U);
|
||||
|
||||
const int32_t kValues2[] = {74, 71};
|
||||
GPBEnumArray *array2 = [[GPBEnumArray alloc] initWithValues:kValues2
|
||||
count:GPBARRAYSIZE(kValues2)];
|
||||
const int32_t kValues2[] = { 74, 71 };
|
||||
GPBEnumArray *array2 =
|
||||
[[GPBEnumArray alloc] initWithValues:kValues2
|
||||
count:GPBARRAYSIZE(kValues2)];
|
||||
XCTAssertNotNil(array2);
|
||||
[array addRawValuesFromArray:array2];
|
||||
XCTAssertEqual(array.count, 5U);
|
||||
@@ -3380,35 +3425,37 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
}
|
||||
|
||||
- (void)testUnknownInserts {
|
||||
const int32_t kValues[] = {71, 72, 73};
|
||||
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:kValues
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
const int32_t kValues[] = { 71, 72, 73 };
|
||||
GPBEnumArray *array =
|
||||
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:kValues
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
XCTAssertNotNil(array);
|
||||
XCTAssertEqual(array.count, 3U);
|
||||
|
||||
// First
|
||||
XCTAssertThrowsSpecificNamed([array insertValue:174 atIndex:0], NSException,
|
||||
NSInvalidArgumentException);
|
||||
XCTAssertThrowsSpecificNamed([array insertValue:174 atIndex:0],
|
||||
NSException, NSInvalidArgumentException);
|
||||
XCTAssertEqual(array.count, 3U);
|
||||
|
||||
// Middle
|
||||
XCTAssertThrowsSpecificNamed([array insertValue:274 atIndex:1], NSException,
|
||||
NSInvalidArgumentException);
|
||||
XCTAssertThrowsSpecificNamed([array insertValue:274 atIndex:1],
|
||||
NSException, NSInvalidArgumentException);
|
||||
XCTAssertEqual(array.count, 3U);
|
||||
|
||||
// End
|
||||
XCTAssertThrowsSpecificNamed([array insertValue:374 atIndex:3], NSException,
|
||||
NSInvalidArgumentException);
|
||||
XCTAssertThrowsSpecificNamed([array insertValue:374 atIndex:3],
|
||||
NSException, NSInvalidArgumentException);
|
||||
XCTAssertEqual(array.count, 3U);
|
||||
[array release];
|
||||
}
|
||||
|
||||
- (void)testRawInsert {
|
||||
const int32_t kValues[] = {71, 72, 73};
|
||||
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:kValues
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
const int32_t kValues[] = { 71, 72, 73 };
|
||||
GPBEnumArray *array =
|
||||
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:kValues
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
XCTAssertNotNil(array);
|
||||
XCTAssertEqual(array.count, 3U);
|
||||
|
||||
@@ -3425,7 +3472,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
XCTAssertEqual(array.count, 6U);
|
||||
|
||||
// Too far.
|
||||
XCTAssertThrowsSpecificNamed([array insertRawValue:74 atIndex:7], NSException, NSRangeException);
|
||||
XCTAssertThrowsSpecificNamed([array insertRawValue:74 atIndex:7],
|
||||
NSException, NSRangeException);
|
||||
|
||||
XCTAssertEqual([array rawValueAtIndex:0], 174);
|
||||
XCTAssertEqual([array valueAtIndex:0], kGPBUnrecognizedEnumeratorValue);
|
||||
@@ -3440,16 +3488,17 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
}
|
||||
|
||||
- (void)testUnknownInplaceMutation {
|
||||
const int32_t kValues[] = {71, 72, 73, 74};
|
||||
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:kValues
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
const int32_t kValues[] = { 71, 72, 73, 74 };
|
||||
GPBEnumArray *array =
|
||||
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:kValues
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
XCTAssertNotNil(array);
|
||||
|
||||
XCTAssertThrowsSpecificNamed([array replaceValueAtIndex:1 withValue:172], NSException,
|
||||
NSInvalidArgumentException);
|
||||
XCTAssertThrowsSpecificNamed([array replaceValueAtIndex:3 withValue:274], NSException,
|
||||
NSInvalidArgumentException);
|
||||
XCTAssertThrowsSpecificNamed([array replaceValueAtIndex:1 withValue:172],
|
||||
NSException, NSInvalidArgumentException);
|
||||
XCTAssertThrowsSpecificNamed([array replaceValueAtIndex:3 withValue:274],
|
||||
NSException, NSInvalidArgumentException);
|
||||
XCTAssertEqual(array.count, 4U);
|
||||
XCTAssertEqual([array valueAtIndex:0], 71);
|
||||
XCTAssertEqual([array valueAtIndex:1], 72);
|
||||
@@ -3458,11 +3507,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
[array release];
|
||||
}
|
||||
|
||||
|
||||
- (void)testRawInplaceMutation {
|
||||
const int32_t kValues[] = {71, 72, 73, 74};
|
||||
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:kValues
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
const int32_t kValues[] = { 71, 72, 73, 74 };
|
||||
GPBEnumArray *array =
|
||||
[[GPBEnumArray alloc] initWithValidationFunction:TestingEnum_IsValidValue
|
||||
rawValues:kValues
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
XCTAssertNotNil(array);
|
||||
|
||||
[array replaceValueAtIndex:1 withRawValue:172]; // Unknown
|
||||
@@ -3475,14 +3526,16 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
XCTAssertEqual([array rawValueAtIndex:3], 274);
|
||||
XCTAssertEqual([array valueAtIndex:3], kGPBUnrecognizedEnumeratorValue);
|
||||
|
||||
XCTAssertThrowsSpecificNamed([array replaceValueAtIndex:4 withRawValue:74], NSException,
|
||||
NSRangeException);
|
||||
XCTAssertThrowsSpecificNamed([array replaceValueAtIndex:4 withRawValue:74],
|
||||
NSException, NSRangeException);
|
||||
[array release];
|
||||
}
|
||||
|
||||
- (void)testRawInternalResizing {
|
||||
const int32_t kValues[] = {71, 172, 173, 74}; // Unknown
|
||||
GPBEnumArray *array = [[GPBEnumArray alloc] initWithValues:kValues count:GPBARRAYSIZE(kValues)];
|
||||
const int32_t kValues[] = { 71, 172, 173, 74 }; // Unknown
|
||||
GPBEnumArray *array =
|
||||
[[GPBEnumArray alloc] initWithValues:kValues
|
||||
count:GPBARRAYSIZE(kValues)];
|
||||
XCTAssertNotNil(array);
|
||||
|
||||
// Add/remove to trigger the intneral buffer to grow/shrink.
|
||||
@@ -3558,13 +3611,13 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
|
||||
|
||||
NSArray *cpy = [array copy];
|
||||
XCTAssertTrue(cpy != array); // Ptr compare
|
||||
XCTAssertTrue(cpy != array); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)0);
|
||||
|
||||
NSArray *cpy2 = [array copy];
|
||||
XCTAssertTrue(cpy2 != array); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != array); // Ptr compare
|
||||
// Can't compare cpy and cpy2 because NSArray has a singleton empty
|
||||
// array it uses, so the ptrs are the same.
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
|
||||
@@ -3580,14 +3633,14 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
GPBAutocreatedArray *array = [[GPBAutocreatedArray alloc] init];
|
||||
|
||||
NSMutableArray *cpy = [array mutableCopy];
|
||||
XCTAssertTrue(cpy != array); // Ptr compare
|
||||
XCTAssertTrue(cpy != array); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSMutableArray class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)0);
|
||||
|
||||
NSMutableArray *cpy2 = [array mutableCopy];
|
||||
XCTAssertTrue(cpy2 != array); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != array); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSMutableArray class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)0);
|
||||
@@ -3603,7 +3656,7 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
[array addObject:@"bar"];
|
||||
|
||||
NSArray *cpy = [array copy];
|
||||
XCTAssertTrue(cpy != array); // Ptr compare
|
||||
XCTAssertTrue(cpy != array); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)2);
|
||||
@@ -3611,8 +3664,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
XCTAssertEqualObjects(cpy[1], @"bar");
|
||||
|
||||
NSArray *cpy2 = [array copy];
|
||||
XCTAssertTrue(cpy2 != array); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != array); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)2);
|
||||
@@ -3630,7 +3683,7 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
[array addObject:@"bar"];
|
||||
|
||||
NSMutableArray *cpy = [array mutableCopy];
|
||||
XCTAssertTrue(cpy != array); // Ptr compare
|
||||
XCTAssertTrue(cpy != array); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSArray class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)2);
|
||||
@@ -3638,8 +3691,8 @@ static BOOL TestingEnum_IsValidValue2(int32_t value) {
|
||||
XCTAssertEqualObjects(cpy[1], @"bar");
|
||||
|
||||
NSMutableArray *cpy2 = [array mutableCopy];
|
||||
XCTAssertTrue(cpy2 != array); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != array); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSArray class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)2);
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#import "GPBCodedOutputStream.h"
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
#import "GPBUtilities_PackagePrivate.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
|
||||
@interface CodedInputStreamTests : GPBTestCase
|
||||
@end
|
||||
@@ -82,10 +82,8 @@
|
||||
[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];
|
||||
[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 {
|
||||
@@ -203,25 +201,30 @@
|
||||
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)];
|
||||
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)];
|
||||
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)];
|
||||
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)];
|
||||
[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, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||
0x80, 0x80, 0x80, 0x00)];
|
||||
[self assertReadVarintFailure:bytes(0x80)];
|
||||
}
|
||||
|
||||
@@ -265,12 +268,16 @@
|
||||
}
|
||||
|
||||
- (void)testReadLittleEndian {
|
||||
[self assertReadLittleEndian32:bytes(0x78, 0x56, 0x34, 0x12) value:0x12345678];
|
||||
[self assertReadLittleEndian32:bytes(0xf0, 0xde, 0xbc, 0x9a) value:0x9abcdef0];
|
||||
[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)
|
||||
[self assertReadLittleEndian64:bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34,
|
||||
0x12)
|
||||
value:0x123456789abcdef0LL];
|
||||
[self assertReadLittleEndian64:bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a)
|
||||
[self assertReadLittleEndian64:bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc,
|
||||
0x9a)
|
||||
value:0x9abcdef012345678LL];
|
||||
}
|
||||
|
||||
@@ -280,7 +287,8 @@
|
||||
NSData* rawBytes = message.data;
|
||||
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
|
||||
|
||||
TestAllTypes* message2 = [TestAllTypes parseFromData:rawBytes extensionRegistry:nil error:NULL];
|
||||
TestAllTypes* message2 =
|
||||
[TestAllTypes parseFromData:rawBytes extensionRegistry:nil error:NULL];
|
||||
[self assertAllFieldsSet:message2 repeatedCount:kGPBDefaultRepeatCount];
|
||||
}
|
||||
|
||||
@@ -292,7 +300,8 @@
|
||||
// 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];
|
||||
GPBUnknownFieldSet* unknownFields =
|
||||
[[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
|
||||
while (YES) {
|
||||
int32_t tag = [input1 readTag];
|
||||
@@ -320,9 +329,10 @@
|
||||
// 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;
|
||||
NSData *messageData = message.data;
|
||||
XCTAssertNotNil(messageData);
|
||||
GPBCodedInputStream* stream = [GPBCodedInputStream streamWithData:messageData];
|
||||
GPBCodedInputStream* stream =
|
||||
[GPBCodedInputStream streamWithData:messageData];
|
||||
TestAllTypes* message2 = [TestAllTypes parseFromCodedInputStream:stream
|
||||
extensionRegistry:nil
|
||||
error:NULL];
|
||||
@@ -340,7 +350,8 @@
|
||||
|
||||
- (void)testReadMaliciouslyLargeBlob {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
GPBCodedOutputStream* output =
|
||||
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
|
||||
int32_t tag = GPBWireFormatMakeTag(1, GPBWireFormatLengthDelimited);
|
||||
[output writeRawVarint32:tag];
|
||||
@@ -349,7 +360,8 @@
|
||||
[output writeRawData:[NSData dataWithBytes:bytes length:32]];
|
||||
[output flush];
|
||||
|
||||
NSData* data = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
NSData* data =
|
||||
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
GPBCodedInputStream* input =
|
||||
[GPBCodedInputStream streamWithData:[NSMutableData dataWithData:data]];
|
||||
XCTAssertEqual(tag, [input readTag]);
|
||||
@@ -358,21 +370,23 @@
|
||||
}
|
||||
|
||||
- (void)testReadEmptyString {
|
||||
NSData* data = bytes(0x00);
|
||||
NSData *data = bytes(0x00);
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertEqualObjects(@"", [input readString]);
|
||||
}
|
||||
|
||||
- (void)testInvalidGroupEndTagThrows {
|
||||
NSData* data = bytes(0x0B, 0x1A, 0x02, 0x4B, 0x50, 0x14);
|
||||
NSData *data = bytes(0x0B, 0x1A, 0x02, 0x4B, 0x50, 0x14);
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertThrowsSpecificNamed([input skipMessage], NSException, GPBCodedInputStreamException,
|
||||
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];
|
||||
NSData *data = bytes(0xFF, 0xFF, 0xFF, 0xFF, 0x0F);
|
||||
GPBCodedInputStream *input = [GPBCodedInputStream streamWithData:data];
|
||||
XCTAssertNil([input readBytes]);
|
||||
}
|
||||
|
||||
@@ -382,10 +396,11 @@
|
||||
// again, it will help validate that class' handing of bad utf8.
|
||||
- (void)testReadMalformedString {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
GPBCodedOutputStream* output =
|
||||
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
|
||||
int32_t tag =
|
||||
GPBWireFormatMakeTag(TestAllTypes_FieldNumber_DefaultString, GPBWireFormatLengthDelimited);
|
||||
int32_t tag = GPBWireFormatMakeTag(TestAllTypes_FieldNumber_DefaultString,
|
||||
GPBWireFormatLengthDelimited);
|
||||
[output writeRawVarint32:tag];
|
||||
[output writeRawVarint32:5];
|
||||
// Create an invalid utf-8 byte array.
|
||||
@@ -393,9 +408,10 @@
|
||||
[output writeRawData:[NSData dataWithBytes:bytes length:sizeof(bytes)]];
|
||||
[output flush];
|
||||
|
||||
NSData* data = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
NSData *data =
|
||||
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
NSError* error = nil;
|
||||
NSError *error = nil;
|
||||
TestAllTypes* message = [TestAllTypes parseFromCodedInputStream:input
|
||||
extensionRegistry:nil
|
||||
error:&error];
|
||||
@@ -409,25 +425,27 @@
|
||||
// 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",
|
||||
"\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];
|
||||
GPBCodedOutputStream* output =
|
||||
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
|
||||
int32_t tag =
|
||||
GPBWireFormatMakeTag(TestAllTypes_FieldNumber_DefaultString, GPBWireFormatLengthDelimited);
|
||||
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];
|
||||
NSData* data =
|
||||
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
GPBCodedInputStream* input = [GPBCodedInputStream streamWithData:data];
|
||||
TestAllTypes* message = [TestAllTypes parseFromCodedInputStream:input
|
||||
extensionRegistry:nil
|
||||
|
||||
@@ -30,23 +30,26 @@
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import "GPBCodedInputStream.h"
|
||||
#import "GPBCodedOutputStream_PackagePrivate.h"
|
||||
#import "GPBCodedInputStream.h"
|
||||
#import "GPBUtilities_PackagePrivate.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
|
||||
@interface GPBCodedOutputStream (InternalMethods)
|
||||
// Declared in the .m file, expose for testing.
|
||||
- (instancetype)initWithOutputStream:(NSOutputStream*)output data:(NSMutableData*)data;
|
||||
- (instancetype)initWithOutputStream:(NSOutputStream *)output
|
||||
data:(NSMutableData *)data;
|
||||
@end
|
||||
|
||||
@interface GPBCodedOutputStream (Helper)
|
||||
+ (instancetype)streamWithOutputStream:(NSOutputStream*)output bufferSize:(size_t)bufferSize;
|
||||
+ (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];
|
||||
+ (instancetype)streamWithOutputStream:(NSOutputStream *)output
|
||||
bufferSize:(size_t)bufferSize {
|
||||
NSMutableData *data = [NSMutableData dataWithLength:bufferSize];
|
||||
return [[[self alloc] initWithOutputStream:output data:data] autorelease];
|
||||
}
|
||||
@end
|
||||
@@ -78,17 +81,20 @@
|
||||
|
||||
- (void)assertWriteLittleEndian32:(NSData*)data value:(int32_t)value {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
GPBCodedOutputStream* output =
|
||||
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
[output writeRawLittleEndian32:(int32_t)value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
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 = [GPBCodedOutputStream streamWithOutputStream:rawOutput
|
||||
bufferSize:blockSize];
|
||||
[output writeRawLittleEndian32:(int32_t)value];
|
||||
[output flush];
|
||||
|
||||
@@ -99,17 +105,20 @@
|
||||
|
||||
- (void)assertWriteLittleEndian64:(NSData*)data value:(int64_t)value {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
GPBCodedOutputStream* output =
|
||||
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
[output writeRawLittleEndian64:value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
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 = [GPBCodedOutputStream streamWithOutputStream:rawOutput
|
||||
bufferSize:blockSize];
|
||||
[output writeRawLittleEndian64:value];
|
||||
[output flush];
|
||||
|
||||
@@ -122,24 +131,29 @@
|
||||
// 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];
|
||||
GPBCodedOutputStream* output =
|
||||
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
[output writeRawVarint32:(int32_t)value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
NSData* actual =
|
||||
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
|
||||
// Also try computing size.
|
||||
XCTAssertEqual(GPBComputeRawVarint32Size((int32_t)value), (size_t)data.length);
|
||||
XCTAssertEqual(GPBComputeRawVarint32Size((int32_t)value),
|
||||
(size_t)data.length);
|
||||
}
|
||||
|
||||
{
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
GPBCodedOutputStream* output =
|
||||
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
[output writeRawVarint64:value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
NSData* actual =
|
||||
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
|
||||
// Also try computing size.
|
||||
@@ -151,45 +165,52 @@
|
||||
// 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];
|
||||
GPBCodedOutputStream* output =
|
||||
[GPBCodedOutputStream streamWithOutputStream:rawOutput
|
||||
bufferSize:blockSize];
|
||||
|
||||
[output writeRawVarint32:(int32_t)value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
NSData* actual =
|
||||
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
}
|
||||
|
||||
{
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput
|
||||
bufferSize:blockSize];
|
||||
GPBCodedOutputStream* output =
|
||||
[GPBCodedOutputStream streamWithOutputStream:rawOutput
|
||||
bufferSize:blockSize];
|
||||
|
||||
[output writeRawVarint64:value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
NSData* actual =
|
||||
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(data, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)assertWriteStringNoTag:(NSData*)data
|
||||
value:(NSString*)value
|
||||
context:(NSString*)contextMessage {
|
||||
value:(NSString *)value
|
||||
context:(NSString *)contextMessage {
|
||||
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* output = [GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
GPBCodedOutputStream* output =
|
||||
[GPBCodedOutputStream streamWithOutputStream:rawOutput];
|
||||
[output writeStringNoTag:value];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
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 = [GPBCodedOutputStream streamWithOutputStream:rawOutput
|
||||
bufferSize:blockSize];
|
||||
[output writeStringNoTag:value];
|
||||
[output flush];
|
||||
|
||||
@@ -222,41 +243,51 @@
|
||||
|
||||
// 1887747006 (no sign bit)
|
||||
[self assertWriteVarint:bytes(0xbe, 0xf7, 0x92, 0x84, 0x07)
|
||||
value:(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) | (0x07LL << 28)];
|
||||
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)];
|
||||
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)];
|
||||
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)];
|
||||
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) |
|
||||
[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 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)
|
||||
[self assertWriteLittleEndian64:bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56,
|
||||
0x34, 0x12)
|
||||
value:0x123456789abcdef0LL];
|
||||
[self assertWriteLittleEndian64:bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a)
|
||||
[self assertWriteLittleEndian64:bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde,
|
||||
0xbc, 0x9a)
|
||||
value:0x9abcdef012345678LL];
|
||||
}
|
||||
|
||||
@@ -274,12 +305,18 @@
|
||||
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));
|
||||
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.
|
||||
@@ -295,8 +332,10 @@
|
||||
XCTAssertEqual(14927ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(14927)));
|
||||
XCTAssertEqual(-3612ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(-3612)));
|
||||
|
||||
XCTAssertEqual(856912304801416ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(856912304801416LL)));
|
||||
XCTAssertEqual(-75123905439571256ULL, GPBEncodeZigZag64(GPBDecodeZigZag64(-75123905439571256LL)));
|
||||
XCTAssertEqual(856912304801416ULL,
|
||||
GPBEncodeZigZag64(GPBDecodeZigZag64(856912304801416LL)));
|
||||
XCTAssertEqual(-75123905439571256ULL,
|
||||
GPBEncodeZigZag64(GPBDecodeZigZag64(-75123905439571256LL)));
|
||||
}
|
||||
|
||||
- (void)testWriteWholeMessage {
|
||||
@@ -305,18 +344,21 @@
|
||||
TestAllTypes* message = [self allSetRepeatedCount:2];
|
||||
|
||||
NSData* rawBytes = message.data;
|
||||
NSData* goldenData = [self getDataFileNamed:@"golden_message" dataToWrite:rawBytes];
|
||||
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];
|
||||
GPBCodedOutputStream* output =
|
||||
[GPBCodedOutputStream streamWithOutputStream:rawOutput
|
||||
bufferSize:blockSize];
|
||||
[message writeToCodedOutputStream:output];
|
||||
[output flush];
|
||||
|
||||
NSData* actual = [rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
NSData* actual =
|
||||
[rawOutput propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
|
||||
XCTAssertEqualObjects(rawBytes, actual);
|
||||
}
|
||||
|
||||
@@ -324,7 +366,8 @@
|
||||
// that was generated with 2.
|
||||
TestAllExtensions* extensions = [self allExtensionsSetRepeatedCount:2];
|
||||
rawBytes = extensions.data;
|
||||
goldenData = [self getDataFileNamed:@"golden_packed_fields_message" dataToWrite:rawBytes];
|
||||
goldenData = [self getDataFileNamed:@"golden_packed_fields_message"
|
||||
dataToWrite:rawBytes];
|
||||
XCTAssertEqualObjects(rawBytes, goldenData);
|
||||
}
|
||||
|
||||
@@ -337,10 +380,11 @@
|
||||
|
||||
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
|
||||
NSString *asNSString = [[NSString alloc] initWithBytes:zeroTest
|
||||
length:sizeof(zeroTest)
|
||||
encoding:NSUTF8StringEncoding];
|
||||
const char* cString = CFStringGetCStringPtr((CFStringRef)asNSString, kCFStringEncodingUTF8);
|
||||
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
|
||||
@@ -348,7 +392,8 @@
|
||||
// a different code path); but the optimizations for when
|
||||
// CFStringGetCStringPtr does work could possibly go away.
|
||||
|
||||
XCTAssertEqual(sizeof(zeroTest), [asNSString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertEqual(sizeof(zeroTest),
|
||||
[asNSString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertTrue(0 == memcmp(cString, zeroTest, sizeof(zeroTest)));
|
||||
[asNSString release];
|
||||
}
|
||||
@@ -360,25 +405,25 @@
|
||||
// strings built via the NSString apis. So this round trips them to ensure
|
||||
// they are acting as expected.
|
||||
|
||||
NSArray<NSString*>* strs = @[
|
||||
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];
|
||||
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];
|
||||
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];
|
||||
NSString *str2 = [NSString stringWithFormat:@"%@", str];
|
||||
context = [NSString stringWithFormat:@"Loop %d - Built", i];
|
||||
[self assertWriteStringNoTag:expected value:str2 context:context];
|
||||
|
||||
@@ -387,11 +432,11 @@
|
||||
}
|
||||
|
||||
- (void)testThatItThrowsWhenWriteRawPtrFails {
|
||||
NSOutputStream* output = [NSOutputStream outputStreamToMemory];
|
||||
GPBCodedOutputStream* codedOutput =
|
||||
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";
|
||||
const char *cString = "raw";
|
||||
XCTAssertThrowsSpecificNamed([codedOutput writeRawPtr:cString offset:0 length:strlen(cString)],
|
||||
NSException, GPBCodedOutputStreamException_WriteFailed);
|
||||
}
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
// (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;
|
||||
|
||||
@@ -28,31 +28,15 @@
|
||||
// (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";
|
||||
// This is a test including a single header to ensure things build. This
|
||||
// is NOT a public header of the library, but uses a file that defines
|
||||
// proto2 syntax messages that are extendable, so it can need more things
|
||||
// that the proto3 syntax WKTs bundled with the library.
|
||||
|
||||
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;
|
||||
}
|
||||
#import "google/protobuf/Descriptor.pbobjc.h"
|
||||
|
||||
|
||||
// To use an enum in a map, it must has the first value as 0.
|
||||
enum EnumForMap {
|
||||
UNKNOWN = 0;
|
||||
FOO = 1;
|
||||
BAR = 2;
|
||||
}
|
||||
// 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_24 = 0;
|
||||
@@ -28,17 +28,15 @@
|
||||
// (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;
|
||||
// This is a test including a single header to ensure things build. This
|
||||
// is NOT a public header of the library, but uses a file that defines
|
||||
// extensions to proto2 syntax messages, so it can need more things
|
||||
// that the proto3 syntax WKTs bundled with the library.
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
#import "google/protobuf/UnittestCustomOptions.pbobjc.h"
|
||||
|
||||
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;
|
||||
}
|
||||
// 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_25 = 0;
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjc.pbobjc.h"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/UnittestObjc.pbobjc.h"
|
||||
|
||||
static const int kNumThreads = 100;
|
||||
static const int kNumMessages = 100;
|
||||
@@ -49,7 +49,8 @@ static const int kNumMessages = 100;
|
||||
- (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];
|
||||
NSThread *thread =
|
||||
[[NSThread alloc] initWithTarget:self selector:selector object:object];
|
||||
[array addObject:thread];
|
||||
[thread release];
|
||||
}
|
||||
@@ -87,8 +88,9 @@ static const int kNumMessages = 100;
|
||||
|
||||
- (void)testConcurrentReadOfUnsetMessageField {
|
||||
NSArray *messages = [self createMessagesWithType:[TestAllTypes class]];
|
||||
NSArray *threads = [self createThreadsWithSelector:@selector(readForeignMessage:)
|
||||
object:messages];
|
||||
NSArray *threads =
|
||||
[self createThreadsWithSelector:@selector(readForeignMessage:)
|
||||
object:messages];
|
||||
[self startThreads:threads];
|
||||
[self joinThreads:threads];
|
||||
for (TestAllTypes *message in messages) {
|
||||
@@ -106,7 +108,9 @@ static const int kNumMessages = 100;
|
||||
|
||||
- (void)testConcurrentReadOfUnsetRepeatedIntField {
|
||||
NSArray *messages = [self createMessagesWithType:[TestAllTypes class]];
|
||||
NSArray *threads = [self createThreadsWithSelector:@selector(readRepeatedInt32:) object:messages];
|
||||
NSArray *threads =
|
||||
[self createThreadsWithSelector:@selector(readRepeatedInt32:)
|
||||
object:messages];
|
||||
[self startThreads:threads];
|
||||
[self joinThreads:threads];
|
||||
for (TestAllTypes *message in messages) {
|
||||
@@ -124,8 +128,9 @@ static const int kNumMessages = 100;
|
||||
|
||||
- (void)testConcurrentReadOfUnsetRepeatedStringField {
|
||||
NSArray *messages = [self createMessagesWithType:[TestAllTypes class]];
|
||||
NSArray *threads = [self createThreadsWithSelector:@selector(readRepeatedString:)
|
||||
object:messages];
|
||||
NSArray *threads =
|
||||
[self createThreadsWithSelector:@selector(readRepeatedString:)
|
||||
object:messages];
|
||||
[self startThreads:threads];
|
||||
[self joinThreads:threads];
|
||||
for (TestAllTypes *message in messages) {
|
||||
@@ -142,8 +147,11 @@ static const int kNumMessages = 100;
|
||||
}
|
||||
|
||||
- (void)testConcurrentReadOfUnsetInt32Int32MapField {
|
||||
NSArray *messages = [self createMessagesWithType:[TestRecursiveMessageWithRepeatedField class]];
|
||||
NSArray *threads = [self createThreadsWithSelector:@selector(readInt32Int32Map:) object:messages];
|
||||
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) {
|
||||
@@ -160,9 +168,11 @@ static const int kNumMessages = 100;
|
||||
}
|
||||
|
||||
- (void)testConcurrentReadOfUnsetStringStringMapField {
|
||||
NSArray *messages = [self createMessagesWithType:[TestRecursiveMessageWithRepeatedField class]];
|
||||
NSArray *threads = [self createThreadsWithSelector:@selector(readStringStringMap:)
|
||||
object:messages];
|
||||
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) {
|
||||
@@ -186,7 +196,8 @@ static const int kNumMessages = 100;
|
||||
NSArray *threads = [self createThreadsWithSelector:sel object:messages];
|
||||
[self startThreads:threads];
|
||||
[self joinThreads:threads];
|
||||
GPBExtensionDescriptor *extension = [UnittestRoot optionalForeignMessageExtension];
|
||||
GPBExtensionDescriptor *extension =
|
||||
[UnittestRoot optionalForeignMessageExtension];
|
||||
for (TestAllExtensions *message in messages) {
|
||||
XCTAssertFalse([message hasExtension:extension]);
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@
|
||||
#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"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/UnittestObjc.pbobjc.h"
|
||||
#import "google/protobuf/Descriptor.pbobjc.h"
|
||||
|
||||
@interface DescriptorTests : GPBTestCase
|
||||
@end
|
||||
@@ -52,36 +52,37 @@
|
||||
|
||||
- (void)testDescriptor_fullName {
|
||||
GPBDescriptor *testAllTypesDesc = [TestAllTypes descriptor];
|
||||
XCTAssertEqualObjects(testAllTypesDesc.fullName, @"objc.protobuf.tests.TestAllTypes");
|
||||
XCTAssertEqualObjects(testAllTypesDesc.fullName, @"protobuf_unittest.TestAllTypes");
|
||||
GPBDescriptor *nestedMessageDesc = [TestAllTypes_NestedMessage descriptor];
|
||||
XCTAssertEqualObjects(nestedMessageDesc.fullName,
|
||||
@"objc.protobuf.tests.TestAllTypes.NestedMessage");
|
||||
XCTAssertEqualObjects(nestedMessageDesc.fullName, @"protobuf_unittest.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");
|
||||
GPBDescriptor *descDesc = [GPBDescriptorProto descriptor];
|
||||
XCTAssertEqualObjects(descDesc.fullName, @"google.protobuf.DescriptorProto");
|
||||
GPBDescriptor *descExtRngDesc = [GPBDescriptorProto_ExtensionRange descriptor];
|
||||
XCTAssertEqualObjects(descExtRngDesc.fullName, @"google.protobuf.DescriptorProto.ExtensionRange");
|
||||
|
||||
// Things that get "_Class" added.
|
||||
GPBDescriptor *pointDesc = [Point_Class descriptor];
|
||||
XCTAssertEqualObjects(pointDesc.fullName, @"objc.protobuf.tests.Point");
|
||||
XCTAssertEqualObjects(pointDesc.fullName, @"protobuf_unittest.Point");
|
||||
GPBDescriptor *pointRectDesc = [Point_Rect descriptor];
|
||||
XCTAssertEqualObjects(pointRectDesc.fullName, @"objc.protobuf.tests.Point.Rect");
|
||||
XCTAssertEqualObjects(pointRectDesc.fullName, @"protobuf_unittest.Point.Rect");
|
||||
}
|
||||
|
||||
- (void)testFieldDescriptor {
|
||||
GPBDescriptor *descriptor = [TestAllTypes descriptor];
|
||||
|
||||
// Nested Enum
|
||||
GPBFieldDescriptor *fieldDescriptorWithName = [descriptor fieldWithName:@"optionalNestedEnum"];
|
||||
GPBFieldDescriptor *fieldDescriptorWithName =
|
||||
[descriptor fieldWithName:@"optionalNestedEnum"];
|
||||
XCTAssertNotNil(fieldDescriptorWithName);
|
||||
GPBFieldDescriptor *fieldDescriptorWithNumber = [descriptor fieldWithNumber:21];
|
||||
GPBFieldDescriptor *fieldDescriptorWithNumber =
|
||||
[descriptor fieldWithNumber:21];
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber);
|
||||
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
|
||||
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name, @"TestAllTypes_NestedEnum");
|
||||
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
|
||||
@"TestAllTypes_NestedEnum");
|
||||
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
|
||||
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
|
||||
|
||||
@@ -92,7 +93,8 @@
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber);
|
||||
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
|
||||
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name, @"ForeignEnum");
|
||||
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
|
||||
@"ForeignEnum");
|
||||
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
|
||||
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
|
||||
|
||||
@@ -103,7 +105,8 @@
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber);
|
||||
XCTAssertEqual(fieldDescriptorWithName, fieldDescriptorWithNumber);
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber.enumDescriptor);
|
||||
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name, @"ImportEnum");
|
||||
XCTAssertEqualObjects(fieldDescriptorWithNumber.enumDescriptor.name,
|
||||
@"ImportEnum");
|
||||
XCTAssertEqual(fieldDescriptorWithName.number, fieldDescriptorWithNumber.number);
|
||||
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeEnum);
|
||||
|
||||
@@ -118,7 +121,8 @@
|
||||
XCTAssertEqual(fieldDescriptorWithName.dataType, GPBDataTypeMessage);
|
||||
|
||||
// Foreign Message
|
||||
fieldDescriptorWithName = [descriptor fieldWithName:@"optionalForeignMessage"];
|
||||
fieldDescriptorWithName =
|
||||
[descriptor fieldWithName:@"optionalForeignMessage"];
|
||||
XCTAssertNotNil(fieldDescriptorWithName);
|
||||
fieldDescriptorWithNumber = [descriptor fieldWithNumber:19];
|
||||
XCTAssertNotNil(fieldDescriptorWithNumber);
|
||||
@@ -148,18 +152,22 @@
|
||||
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"]);
|
||||
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"]);
|
||||
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"]);
|
||||
XCTAssertTrue(
|
||||
[descriptor getValue:&value forEnumName:@"TestAllTypes_NestedEnum_Baz"]);
|
||||
XCTAssertEqual(value, TestAllTypes_NestedEnum_Baz);
|
||||
|
||||
// TextFormat
|
||||
@@ -174,8 +182,10 @@
|
||||
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:&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"]);
|
||||
}
|
||||
@@ -184,13 +194,17 @@
|
||||
GPBEnumDescriptor *descriptor = TestAllTypes_NestedEnum_EnumDescriptor();
|
||||
|
||||
XCTAssertEqual(descriptor.enumNameCount, 4U);
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:0], @"TestAllTypes_NestedEnum_Foo");
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:0],
|
||||
@"TestAllTypes_NestedEnum_Foo");
|
||||
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:0], @"FOO");
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:1], @"TestAllTypes_NestedEnum_Bar");
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:1],
|
||||
@"TestAllTypes_NestedEnum_Bar");
|
||||
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:1], @"BAR");
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:2], @"TestAllTypes_NestedEnum_Baz");
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:2],
|
||||
@"TestAllTypes_NestedEnum_Baz");
|
||||
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:2], @"BAZ");
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:3], @"TestAllTypes_NestedEnum_Neg");
|
||||
XCTAssertEqualObjects([descriptor getEnumNameForIndex:3],
|
||||
@"TestAllTypes_NestedEnum_Neg");
|
||||
XCTAssertEqualObjects([descriptor getEnumTextFormatNameForIndex:3], @"NEG");
|
||||
}
|
||||
|
||||
@@ -272,7 +286,8 @@
|
||||
|
||||
- (void)testEnumValueValidator {
|
||||
GPBDescriptor *descriptor = [TestAllTypes descriptor];
|
||||
GPBFieldDescriptor *fieldDescriptor = [descriptor fieldWithName:@"optionalNestedEnum"];
|
||||
GPBFieldDescriptor *fieldDescriptor =
|
||||
[descriptor fieldWithName:@"optionalNestedEnum"];
|
||||
|
||||
// Valid values
|
||||
XCTAssertTrue([fieldDescriptor isValidEnumValue:1]);
|
||||
@@ -310,10 +325,12 @@
|
||||
|
||||
// Pointer comparisons against lookups from message.
|
||||
|
||||
XCTAssertEqual([oneofFoo fieldWithNumber:TestOneof2_FieldNumber_FooString], fooStringField);
|
||||
XCTAssertEqual([oneofFoo fieldWithNumber:TestOneof2_FieldNumber_FooString],
|
||||
fooStringField);
|
||||
XCTAssertEqual([oneofFoo fieldWithName:@"fooString"], fooStringField);
|
||||
|
||||
XCTAssertEqual([oneofBar fieldWithNumber:TestOneof2_FieldNumber_BarString], barStringField);
|
||||
XCTAssertEqual([oneofBar fieldWithNumber:TestOneof2_FieldNumber_BarString],
|
||||
barStringField);
|
||||
XCTAssertEqual([oneofBar fieldWithName:@"barString"], barStringField);
|
||||
|
||||
// Unknown oneof not found.
|
||||
@@ -337,7 +354,8 @@
|
||||
// (pointer comparisons)
|
||||
XCTAssertEqual(fooStringField.containingOneof, oneofFoo);
|
||||
XCTAssertEqual(barStringField.containingOneof, oneofBar);
|
||||
GPBFieldDescriptor *bazString = [descriptor fieldWithNumber:TestOneof2_FieldNumber_BazString];
|
||||
GPBFieldDescriptor *bazString =
|
||||
[descriptor fieldWithNumber:TestOneof2_FieldNumber_BazString];
|
||||
XCTAssertNotNil(bazString);
|
||||
XCTAssertNil(bazString.containingOneof);
|
||||
}
|
||||
|
||||
@@ -34,10 +34,7 @@
|
||||
#import "GPBDictionary.h"
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
|
||||
|
||||
// Pull in the macros (using an external file because expanding all tests
|
||||
// in a single file makes a file that is failing to work with within Xcode.
|
||||
@@ -45,6 +42,7 @@
|
||||
|
||||
//%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(UInt32, uint32_t, 100U, 101U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - Bool -> UInt32
|
||||
|
||||
@@ -58,7 +56,8 @@
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getUInt32:NULL forKey:YES]);
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused BOOL aKey, __unused uint32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -124,7 +123,8 @@
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused BOOL aKey, __unused uint32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(BOOL aKey, uint32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 0) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -346,8 +346,10 @@
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Int32, int32_t, 200, 201)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - Bool -> Int32
|
||||
|
||||
@@ -361,7 +363,8 @@
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getInt32:NULL forKey:YES]);
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(__unused BOOL aKey, __unused int32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -427,7 +430,8 @@
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(__unused BOOL aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(BOOL aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 0) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -649,8 +653,10 @@
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(UInt64, uint64_t, 300U, 301U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - Bool -> UInt64
|
||||
|
||||
@@ -664,7 +670,8 @@
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getUInt64:NULL forKey:YES]);
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused BOOL aKey, __unused uint64_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -730,7 +737,8 @@
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused BOOL aKey, __unused uint64_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(BOOL aKey, uint64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 0) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -952,8 +960,10 @@
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Int64, int64_t, 400, 401)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - Bool -> Int64
|
||||
|
||||
@@ -967,7 +977,8 @@
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getInt64:NULL forKey:YES]);
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(__unused BOOL aKey, __unused int64_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1033,7 +1044,8 @@
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(__unused BOOL aKey, __unused int64_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(BOOL aKey, int64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 0) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1255,8 +1267,10 @@
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Bool, BOOL, NO, YES)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - Bool -> Bool
|
||||
|
||||
@@ -1270,7 +1284,8 @@
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getBool:NULL forKey:YES]);
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(__unused BOOL aKey, __unused BOOL aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1336,7 +1351,8 @@
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(__unused BOOL aKey, __unused BOOL aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(BOOL aKey, BOOL aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 0) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1558,8 +1574,10 @@
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Float, float, 500.f, 501.f)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - Bool -> Float
|
||||
|
||||
@@ -1573,7 +1591,8 @@
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getFloat:NULL forKey:YES]);
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(__unused BOOL aKey, __unused float aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1639,7 +1658,8 @@
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(__unused BOOL aKey, __unused float aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(BOOL aKey, float aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 0) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1861,8 +1881,10 @@
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND BOOL_TESTS_FOR_POD_VALUE(Double, double, 600., 601.)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - Bool -> Double
|
||||
|
||||
@@ -1876,7 +1898,8 @@
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getDouble:NULL forKey:YES]);
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(__unused BOOL aKey, __unused double aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1942,7 +1965,8 @@
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(__unused BOOL aKey, __unused double aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(BOOL aKey, double aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 0) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -2164,8 +2188,10 @@
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND TESTS_FOR_BOOL_KEY_OBJECT_VALUE(Object, NSString*, @"abc", @"def")
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
#pragma mark - Bool -> Object
|
||||
|
||||
@@ -2179,7 +2205,8 @@
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict objectForKey:YES]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(__unused BOOL aKey, __unused NSString* aObject, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, NSString* aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -2237,7 +2264,8 @@
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(__unused BOOL aKey, __unused NSString* aObject, BOOL *stop) {
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, NSString* aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject)
|
||||
if (idx == 0) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -2432,6 +2460,7 @@
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END (8 expansions)
|
||||
|
||||
|
||||
|
||||
@@ -34,10 +34,7 @@
|
||||
#import "GPBDictionary.h"
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
|
||||
|
||||
// Pull in the macros (using an external file because expanding all tests
|
||||
// in a single file makes a file that is failing to work with within Xcode.
|
||||
@@ -45,6 +42,7 @@
|
||||
|
||||
//%PDDM-EXPAND TEST_FOR_POD_KEY(Int32, int32_t, 11, 12, 13, 14)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
// To let the testing macros work, add some extra methods to simplify things.
|
||||
@interface GPBInt32EnumDictionary (TestingTweak)
|
||||
@@ -89,7 +87,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getUInt32:NULL forKey:11]);
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused int32_t aKey, __unused uint32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -159,7 +158,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused int32_t aKey, __unused uint32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(int32_t aKey, uint32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -448,7 +448,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getInt32:NULL forKey:11]);
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(__unused int32_t aKey, __unused int32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -518,7 +519,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(__unused int32_t aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -807,7 +809,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getUInt64:NULL forKey:11]);
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused int32_t aKey, __unused uint64_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -877,7 +880,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused int32_t aKey, __unused uint64_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(int32_t aKey, uint64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1166,7 +1170,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getInt64:NULL forKey:11]);
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(__unused int32_t aKey, __unused int64_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1236,7 +1241,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(__unused int32_t aKey, __unused int64_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(int32_t aKey, int64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1525,7 +1531,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getBool:NULL forKey:11]);
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(__unused int32_t aKey, __unused BOOL aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1595,7 +1602,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(__unused int32_t aKey, __unused BOOL aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(int32_t aKey, BOOL aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1884,7 +1892,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getFloat:NULL forKey:11]);
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(__unused int32_t aKey, __unused float aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1954,7 +1963,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(__unused int32_t aKey, __unused float aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(int32_t aKey, float aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -2243,7 +2253,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getDouble:NULL forKey:11]);
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(__unused int32_t aKey, __unused double aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -2313,7 +2324,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(__unused int32_t aKey, __unused double aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(int32_t aKey, double aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -2602,7 +2614,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getEnum:NULL forKey:11]);
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(__unused int32_t aKey, __unused int32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -2672,7 +2685,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(__unused int32_t aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -3029,7 +3043,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndRawValuesUsingBlock:^(__unused int32_t aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndRawValuesUsingBlock:^(int32_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -3378,7 +3393,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict objectForKey:11]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(__unused int32_t aKey, __unused NSString* aObject, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, NSString* aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -3438,7 +3454,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(__unused int32_t aKey, __unused NSString* aObject, BOOL *stop) {
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, NSString* aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -3656,5 +3673,6 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END TEST_FOR_POD_KEY(Int32, int32_t, 11, 12, 13, 14)
|
||||
|
||||
|
||||
@@ -34,10 +34,7 @@
|
||||
#import "GPBDictionary.h"
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
|
||||
|
||||
// Pull in the macros (using an external file because expanding all tests
|
||||
// in a single file makes a file that is failing to work with within Xcode.
|
||||
@@ -45,6 +42,7 @@
|
||||
|
||||
//%PDDM-EXPAND TEST_FOR_POD_KEY(Int64, int64_t, 21LL, 22LL, 23LL, 24LL)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
// To let the testing macros work, add some extra methods to simplify things.
|
||||
@interface GPBInt64EnumDictionary (TestingTweak)
|
||||
@@ -89,7 +87,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getUInt32:NULL forKey:21LL]);
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused int64_t aKey, __unused uint32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -159,7 +158,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused int64_t aKey, __unused uint32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(int64_t aKey, uint32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -448,7 +448,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getInt32:NULL forKey:21LL]);
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(__unused int64_t aKey, __unused int32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -518,7 +519,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(__unused int64_t aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -807,7 +809,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getUInt64:NULL forKey:21LL]);
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused int64_t aKey, __unused uint64_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -877,7 +880,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused int64_t aKey, __unused uint64_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(int64_t aKey, uint64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1166,7 +1170,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getInt64:NULL forKey:21LL]);
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(__unused int64_t aKey, __unused int64_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1236,7 +1241,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(__unused int64_t aKey, __unused int64_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(int64_t aKey, int64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1525,7 +1531,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getBool:NULL forKey:21LL]);
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(__unused int64_t aKey, __unused BOOL aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1595,7 +1602,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(__unused int64_t aKey, __unused BOOL aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(int64_t aKey, BOOL aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1884,7 +1892,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getFloat:NULL forKey:21LL]);
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(__unused int64_t aKey, __unused float aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1954,7 +1963,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(__unused int64_t aKey, __unused float aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(int64_t aKey, float aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -2243,7 +2253,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getDouble:NULL forKey:21LL]);
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(__unused int64_t aKey, __unused double aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -2313,7 +2324,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(__unused int64_t aKey, __unused double aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(int64_t aKey, double aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -2602,7 +2614,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getEnum:NULL forKey:21LL]);
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(__unused int64_t aKey, __unused int32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -2672,7 +2685,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(__unused int64_t aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -3029,7 +3043,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndRawValuesUsingBlock:^(__unused int64_t aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndRawValuesUsingBlock:^(int64_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -3378,7 +3393,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict objectForKey:21LL]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(__unused int64_t aKey, __unused NSString* aObject, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, NSString* aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -3438,7 +3454,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(__unused int64_t aKey, __unused NSString* aObject, BOOL *stop) {
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, NSString* aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -3656,5 +3673,6 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END TEST_FOR_POD_KEY(Int64, int64_t, 21LL, 22LL, 23LL, 24LL)
|
||||
|
||||
|
||||
@@ -34,17 +34,15 @@
|
||||
#import "GPBDictionary.h"
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
|
||||
|
||||
// Pull in the macros (using an external file because expanding all tests
|
||||
// in a single file makes a file that is failing to work with within Xcode.
|
||||
//%PDDM-IMPORT-DEFINES GPBDictionaryTests.pddm
|
||||
|
||||
//%PDDM-EXPAND TESTS_FOR_POD_VALUES(String,NSString,*,Objects,@"foo",@"bar",@"baz",@"mumble")
|
||||
//%PDDM-EXPAND TESTS_FOR_POD_VALUES(String, NSString, *, Objects, @"foo", @"bar", @"baz", @"mumble")
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
// To let the testing macros work, add some extra methods to simplify things.
|
||||
@interface GPBStringEnumDictionary (TestingTweak)
|
||||
@@ -89,7 +87,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getUInt32:NULL forKey:@"foo"]);
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused NSString *aKey, __unused uint32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -159,7 +158,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused NSString *aKey, __unused uint32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(NSString *aKey, uint32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -448,7 +448,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getInt32:NULL forKey:@"foo"]);
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(__unused NSString *aKey, __unused int32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -518,7 +519,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(__unused NSString *aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -807,7 +809,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getUInt64:NULL forKey:@"foo"]);
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused NSString *aKey, __unused uint64_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -877,7 +880,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused NSString *aKey, __unused uint64_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(NSString *aKey, uint64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1166,7 +1170,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getInt64:NULL forKey:@"foo"]);
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(__unused NSString *aKey, __unused int64_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1236,7 +1241,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(__unused NSString *aKey, __unused int64_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(NSString *aKey, int64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1525,7 +1531,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getBool:NULL forKey:@"foo"]);
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(__unused NSString *aKey, __unused BOOL aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1595,7 +1602,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(__unused NSString *aKey, __unused BOOL aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(NSString *aKey, BOOL aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1884,7 +1892,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getFloat:NULL forKey:@"foo"]);
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(__unused NSString *aKey, __unused float aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1954,7 +1963,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(__unused NSString *aKey, __unused float aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(NSString *aKey, float aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -2243,7 +2253,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getDouble:NULL forKey:@"foo"]);
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(__unused NSString *aKey, __unused double aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -2313,7 +2324,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(__unused NSString *aKey, __unused double aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(NSString *aKey, double aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -2602,7 +2614,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getEnum:NULL forKey:@"foo"]);
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(__unused NSString *aKey, __unused int32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -2672,7 +2685,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(__unused NSString *aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -3029,7 +3043,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndRawValuesUsingBlock:^(__unused NSString *aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndRawValuesUsingBlock:^(NSString *aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -3366,4 +3381,6 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
@end
|
||||
|
||||
//%PDDM-EXPAND-END TESTS_FOR_POD_VALUES(String,NSString,*,Objects,@"foo",@"bar",@"baz",@"mumble")
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END TESTS_FOR_POD_VALUES(String, NSString, *, Objects, @"foo", @"bar", @"baz", @"mumble")
|
||||
|
||||
|
||||
@@ -34,10 +34,7 @@
|
||||
#import "GPBDictionary.h"
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
|
||||
|
||||
// Pull in the macros (using an external file because expanding all tests
|
||||
// in a single file makes a file that is failing to work with within Xcode.
|
||||
@@ -45,6 +42,7 @@
|
||||
|
||||
//%PDDM-EXPAND TEST_FOR_POD_KEY(UInt32, uint32_t, 1U, 2U, 3U, 4U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
// To let the testing macros work, add some extra methods to simplify things.
|
||||
@interface GPBUInt32EnumDictionary (TestingTweak)
|
||||
@@ -89,7 +87,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getUInt32:NULL forKey:1U]);
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused uint32_t aKey, __unused uint32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -159,7 +158,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused uint32_t aKey, __unused uint32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(uint32_t aKey, uint32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -448,7 +448,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getInt32:NULL forKey:1U]);
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(__unused uint32_t aKey, __unused int32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -518,7 +519,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(__unused uint32_t aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -807,7 +809,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getUInt64:NULL forKey:1U]);
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused uint32_t aKey, __unused uint64_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -877,7 +880,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused uint32_t aKey, __unused uint64_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(uint32_t aKey, uint64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1166,7 +1170,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getInt64:NULL forKey:1U]);
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(__unused uint32_t aKey, __unused int64_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1236,7 +1241,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(__unused uint32_t aKey, __unused int64_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(uint32_t aKey, int64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1525,7 +1531,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getBool:NULL forKey:1U]);
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(__unused uint32_t aKey, __unused BOOL aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1595,7 +1602,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(__unused uint32_t aKey, __unused BOOL aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(uint32_t aKey, BOOL aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1884,7 +1892,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getFloat:NULL forKey:1U]);
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(__unused uint32_t aKey, __unused float aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1954,7 +1963,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(__unused uint32_t aKey, __unused float aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(uint32_t aKey, float aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -2243,7 +2253,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getDouble:NULL forKey:1U]);
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(__unused uint32_t aKey, __unused double aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -2313,7 +2324,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(__unused uint32_t aKey, __unused double aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(uint32_t aKey, double aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -2602,7 +2614,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getEnum:NULL forKey:1U]);
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(__unused uint32_t aKey, __unused int32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -2672,7 +2685,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(__unused uint32_t aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -3029,7 +3043,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndRawValuesUsingBlock:^(__unused uint32_t aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndRawValuesUsingBlock:^(uint32_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -3378,7 +3393,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict objectForKey:1U]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(__unused uint32_t aKey, __unused NSString* aObject, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, NSString* aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -3438,7 +3454,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(__unused uint32_t aKey, __unused NSString* aObject, BOOL *stop) {
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, NSString* aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -3656,5 +3673,6 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END TEST_FOR_POD_KEY(UInt32, uint32_t, 1U, 2U, 3U, 4U)
|
||||
|
||||
|
||||
@@ -34,10 +34,7 @@
|
||||
#import "GPBDictionary.h"
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
|
||||
|
||||
// Pull in the macros (using an external file because expanding all tests
|
||||
// in a single file makes a file that is failing to work with within Xcode.
|
||||
@@ -45,6 +42,7 @@
|
||||
|
||||
//%PDDM-EXPAND TEST_FOR_POD_KEY(UInt64, uint64_t, 31ULL, 32ULL, 33ULL, 34ULL)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
// To let the testing macros work, add some extra methods to simplify things.
|
||||
@interface GPBUInt64EnumDictionary (TestingTweak)
|
||||
@@ -89,7 +87,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getUInt32:NULL forKey:31ULL]);
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused uint64_t aKey, __unused uint32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -159,7 +158,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(__unused uint64_t aKey, __unused uint32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt32sUsingBlock:^(uint64_t aKey, uint32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -448,7 +448,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getInt32:NULL forKey:31ULL]);
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(__unused uint64_t aKey, __unused int32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -518,7 +519,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(__unused uint64_t aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndInt32sUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -807,7 +809,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getUInt64:NULL forKey:31ULL]);
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused uint64_t aKey, __unused uint64_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -877,7 +880,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(__unused uint64_t aKey, __unused uint64_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndUInt64sUsingBlock:^(uint64_t aKey, uint64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1166,7 +1170,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getInt64:NULL forKey:31ULL]);
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(__unused uint64_t aKey, __unused int64_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1236,7 +1241,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(__unused uint64_t aKey, __unused int64_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndInt64sUsingBlock:^(uint64_t aKey, int64_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1525,7 +1531,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getBool:NULL forKey:31ULL]);
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(__unused uint64_t aKey, __unused BOOL aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1595,7 +1602,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(__unused uint64_t aKey, __unused BOOL aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndBoolsUsingBlock:^(uint64_t aKey, BOOL aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -1884,7 +1892,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getFloat:NULL forKey:31ULL]);
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(__unused uint64_t aKey, __unused float aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -1954,7 +1963,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(__unused uint64_t aKey, __unused float aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndFloatsUsingBlock:^(uint64_t aKey, float aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -2243,7 +2253,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getDouble:NULL forKey:31ULL]);
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(__unused uint64_t aKey, __unused double aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -2313,7 +2324,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(__unused uint64_t aKey, __unused double aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndDoublesUsingBlock:^(uint64_t aKey, double aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -2602,7 +2614,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertFalse([dict getEnum:NULL forKey:31ULL]);
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(__unused uint64_t aKey, __unused int32_t aValue, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -2672,7 +2685,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(__unused uint64_t aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndEnumsUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -3029,7 +3043,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndRawValuesUsingBlock:^(__unused uint64_t aKey, __unused int32_t aValue, BOOL *stop) {
|
||||
[dict enumerateKeysAndRawValuesUsingBlock:^(uint64_t aKey, int32_t aValue, BOOL *stop) {
|
||||
#pragma unused(aKey, aValue)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -3378,7 +3393,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
XCTAssertNotNil(dict);
|
||||
XCTAssertEqual(dict.count, 0U);
|
||||
XCTAssertNil([dict objectForKey:31ULL]);
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(__unused uint64_t aKey, __unused NSString* aObject, __unused BOOL *stop) {
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, NSString* aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject, stop)
|
||||
XCTFail(@"Shouldn't get here!");
|
||||
}];
|
||||
[dict release];
|
||||
@@ -3438,7 +3454,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
// Stopping the enumeration.
|
||||
idx = 0;
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(__unused uint64_t aKey, __unused NSString* aObject, BOOL *stop) {
|
||||
[dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, NSString* aObject, BOOL *stop) {
|
||||
#pragma unused(aKey, aObject)
|
||||
if (idx == 1) *stop = YES;
|
||||
XCTAssertNotEqual(idx, 2U);
|
||||
++idx;
|
||||
@@ -3656,4 +3673,5 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
|
||||
|
||||
@end
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END TEST_FOR_POD_KEY(UInt64, uint64_t, 31ULL, 32ULL, 33ULL, 34ULL)
|
||||
|
||||
@@ -56,17 +56,17 @@
|
||||
XCTAssertTrue([dict isEqual:@{}]);
|
||||
XCTAssertTrue([dict isEqualToDictionary:@{}]);
|
||||
|
||||
XCTAssertFalse([dict isEqual:@{@"foo" : @"bar"}]);
|
||||
XCTAssertFalse([dict isEqualToDictionary:@{@"foo" : @"bar"}]);
|
||||
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"}]);
|
||||
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];
|
||||
|
||||
@@ -90,14 +90,14 @@
|
||||
GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
|
||||
|
||||
NSDictionary *cpy = [dict copy];
|
||||
XCTAssertTrue(cpy != dict); // Ptr compare
|
||||
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 != dict); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSDictionary class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)0);
|
||||
@@ -111,14 +111,14 @@
|
||||
GPBAutocreatedDictionary *dict = [[GPBAutocreatedDictionary alloc] init];
|
||||
|
||||
NSMutableDictionary *cpy = [dict mutableCopy];
|
||||
XCTAssertTrue(cpy != dict); // Ptr compare
|
||||
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 != dict); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
XCTAssertTrue([cpy2 isKindOfClass:[NSMutableDictionary class]]);
|
||||
XCTAssertFalse([cpy2 isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy2.count, (NSUInteger)0);
|
||||
@@ -134,7 +134,7 @@
|
||||
dict[@"baz"] = @"mumble";
|
||||
|
||||
NSDictionary *cpy = [dict copy];
|
||||
XCTAssertTrue(cpy != dict); // Ptr compare
|
||||
XCTAssertTrue(cpy != dict); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSDictionary class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)2);
|
||||
@@ -142,8 +142,8 @@
|
||||
XCTAssertEqualObjects(cpy[@"baz"], @"mumble");
|
||||
|
||||
NSDictionary *cpy2 = [dict copy];
|
||||
XCTAssertTrue(cpy2 != dict); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
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);
|
||||
@@ -161,7 +161,7 @@
|
||||
dict[@"baz"] = @"mumble";
|
||||
|
||||
NSMutableDictionary *cpy = [dict mutableCopy];
|
||||
XCTAssertTrue(cpy != dict); // Ptr compare
|
||||
XCTAssertTrue(cpy != dict); // Ptr compare
|
||||
XCTAssertTrue([cpy isKindOfClass:[NSMutableDictionary class]]);
|
||||
XCTAssertFalse([cpy isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(cpy.count, (NSUInteger)2);
|
||||
@@ -169,8 +169,8 @@
|
||||
XCTAssertEqualObjects(cpy[@"baz"], @"mumble");
|
||||
|
||||
NSMutableDictionary *cpy2 = [dict mutableCopy];
|
||||
XCTAssertTrue(cpy2 != dict); // Ptr compare
|
||||
XCTAssertTrue(cpy2 != cpy); // Ptr compare
|
||||
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);
|
||||
|
||||
@@ -70,7 +70,8 @@
|
||||
//% XCTAssertNotNil(dict);
|
||||
//% XCTAssertEqual(dict.count, 0U);
|
||||
//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY1)
|
||||
//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(__unused KEY_TYPE KisP##aKey, __unused VALUE_TYPE a##VNAME$u, __unused BOOL *stop) {
|
||||
//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
|
||||
//% #pragma unused(aKey, a##VNAME$u, stop)
|
||||
//% XCTFail(@"Shouldn't get here!");
|
||||
//% }];
|
||||
//% [dict release];
|
||||
@@ -130,7 +131,8 @@
|
||||
//%
|
||||
//% // Stopping the enumeration.
|
||||
//% idx = 0;
|
||||
//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(__unused KEY_TYPE KisP##aKey, __unused VALUE_TYPE a##VNAME$u, BOOL *stop) {
|
||||
//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) {
|
||||
//% #pragma unused(aKey, a##VNAME$u)
|
||||
//% if (idx == 1) *stop = YES;
|
||||
//% XCTAssertNotEqual(idx, 2U);
|
||||
//% ++idx;
|
||||
@@ -423,7 +425,8 @@
|
||||
//%
|
||||
//% // Stopping the enumeration.
|
||||
//% idx = 0;
|
||||
//% [dict enumerateKeysAndRawValuesUsingBlock:^(__unused KEY_TYPE KisP##aKey, __unused VALUE_TYPE aValue, BOOL *stop) {
|
||||
//% [dict enumerateKeysAndRawValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) {
|
||||
//% #pragma unused(aKey, aValue)
|
||||
//% if (idx == 1) *stop = YES;
|
||||
//% XCTAssertNotEqual(idx, 2U);
|
||||
//% ++idx;
|
||||
@@ -787,7 +790,8 @@
|
||||
//% XCTAssertNotNil(dict);
|
||||
//% XCTAssertEqual(dict.count, 0U);
|
||||
//%VALUE_NOT_FOUND##VHELPER(VALUE_NAME, dict, KEY1)
|
||||
//% [dict enumerateKeysAnd##VALUE_NAME##sUsingBlock:^(__unused KEY_TYPE KisP##aKey, __unused VALUE_TYPE a##VNAME$u##, __unused BOOL *stop) {
|
||||
//% [dict enumerateKeysAnd##VALUE_NAME##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) {
|
||||
//% #pragma unused(aKey, a##VNAME$u##, stop)
|
||||
//% XCTFail(@"Shouldn't get here!");
|
||||
//% }];
|
||||
//% [dict release];
|
||||
@@ -845,7 +849,8 @@
|
||||
//%
|
||||
//% // Stopping the enumeration.
|
||||
//% idx = 0;
|
||||
//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(__unused KEY_TYPE KisP##aKey, __unused VALUE_TYPE a##VNAME$u##, BOOL *stop) {
|
||||
//% [dict enumerateKeysAnd##VALUE_NAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) {
|
||||
//% #pragma unused(aKey, a##VNAME$u)
|
||||
//% if (idx == 0) *stop = YES;
|
||||
//% XCTAssertNotEqual(idx, 2U);
|
||||
//% ++idx;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import "GPBExtensionRegistry.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
|
||||
@interface GPBExtensionRegistryTest : GPBTestCase
|
||||
@end
|
||||
@@ -42,17 +42,20 @@
|
||||
GPBExtensionRegistry *reg = [[[GPBExtensionRegistry alloc] init] autorelease];
|
||||
XCTAssertNotNil(reg);
|
||||
|
||||
XCTAssertNil([reg extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1]);
|
||||
XCTAssertNil([reg extensionForDescriptor:[TestAllTypes descriptor] fieldNumber:1]);
|
||||
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]);
|
||||
[UnittestRoot optionalInt32Extension]); // ptr equality
|
||||
XCTAssertNil([reg extensionForDescriptor:[TestAllTypes descriptor]
|
||||
fieldNumber:1]);
|
||||
XCTAssertTrue([reg extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] ==
|
||||
[UnittestRoot packedInt64Extension]); // ptr equality
|
||||
[UnittestRoot packedInt64Extension]); // ptr equality
|
||||
}
|
||||
|
||||
- (void)testCopy {
|
||||
@@ -63,9 +66,9 @@
|
||||
XCTAssertNotNil(reg2);
|
||||
|
||||
XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
|
||||
[UnittestRoot optionalInt32Extension]); // ptr equality
|
||||
[UnittestRoot optionalInt32Extension]); // ptr equality
|
||||
XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
|
||||
[UnittestRoot optionalInt32Extension]); // ptr equality
|
||||
[UnittestRoot optionalInt32Extension]); // ptr equality
|
||||
|
||||
// Message class that had registered extension(s) at the -copy time.
|
||||
|
||||
@@ -73,11 +76,11 @@
|
||||
[reg2 addExtension:[UnittestRoot optionalStringExtension]];
|
||||
|
||||
XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13] ==
|
||||
[UnittestRoot optionalBoolExtension]); // ptr equality
|
||||
[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
|
||||
[UnittestRoot optionalStringExtension]); // ptr equality
|
||||
|
||||
// Message class that did not have any registered extensions at the -copy time.
|
||||
|
||||
@@ -85,11 +88,12 @@
|
||||
[reg2 addExtension:[UnittestRoot packedSint32Extension]];
|
||||
|
||||
XCTAssertTrue([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] ==
|
||||
[UnittestRoot packedInt64Extension]); // ptr equality
|
||||
[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
|
||||
[UnittestRoot packedSint32Extension]); // ptr equality
|
||||
|
||||
}
|
||||
|
||||
- (void)testAddExtensions {
|
||||
@@ -98,12 +102,13 @@
|
||||
|
||||
GPBExtensionRegistry *reg2 = [[[GPBExtensionRegistry alloc] init] autorelease];
|
||||
|
||||
XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1]);
|
||||
XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor]
|
||||
fieldNumber:1]);
|
||||
|
||||
[reg2 addExtensions:reg1];
|
||||
|
||||
XCTAssertTrue([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:1] ==
|
||||
[UnittestRoot optionalInt32Extension]); // ptr equality
|
||||
[UnittestRoot optionalInt32Extension]); // ptr equality
|
||||
|
||||
// Confirm adding to the first doesn't add to the second.
|
||||
|
||||
@@ -111,9 +116,9 @@
|
||||
[reg1 addExtension:[UnittestRoot packedInt64Extension]];
|
||||
|
||||
XCTAssertTrue([reg1 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13] ==
|
||||
[UnittestRoot optionalBoolExtension]); // ptr equality
|
||||
[UnittestRoot optionalBoolExtension]); // ptr equality
|
||||
XCTAssertTrue([reg1 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91] ==
|
||||
[UnittestRoot packedInt64Extension]); // ptr equality
|
||||
[UnittestRoot packedInt64Extension]); // ptr equality
|
||||
XCTAssertNil([reg2 extensionForDescriptor:[TestAllExtensions descriptor] fieldNumber:13]);
|
||||
XCTAssertNil([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:91]);
|
||||
|
||||
@@ -125,9 +130,9 @@
|
||||
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
|
||||
[UnittestRoot optionalStringExtension]); // ptr equality
|
||||
XCTAssertTrue([reg2 extensionForDescriptor:[TestPackedExtensions descriptor] fieldNumber:94] ==
|
||||
[UnittestRoot packedSint32Extension]); // ptr equality
|
||||
[UnittestRoot packedSint32Extension]); // ptr equality
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -62,15 +62,15 @@ typedef struct MessageLackingClazz_storage_ {
|
||||
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,
|
||||
},
|
||||
{
|
||||
.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"
|
||||
@@ -78,14 +78,14 @@ typedef struct MessageLackingClazz_storage_ {
|
||||
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 =
|
||||
[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;
|
||||
@@ -94,24 +94,24 @@ typedef struct MessageLackingClazz_storage_ {
|
||||
|
||||
@implementation MessageLackingClazzRoot
|
||||
|
||||
+ (GPBExtensionRegistry *)extensionRegistry {
|
||||
+ (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;
|
||||
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,
|
||||
},
|
||||
{
|
||||
.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 `
|
||||
|
||||
@@ -34,11 +34,11 @@
|
||||
|
||||
#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"
|
||||
#import "google/protobuf/MapUnittest.pbobjc.h"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/UnittestPreserveUnknownEnum.pbobjc.h"
|
||||
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
|
||||
#import "google/protobuf/UnittestRuntimeProto3.pbobjc.h"
|
||||
|
||||
@interface MessageMergeTests : GPBTestCase
|
||||
@end
|
||||
@@ -197,8 +197,9 @@
|
||||
// Known value.
|
||||
|
||||
src.e = UnknownEnumsMyEnum_Bar;
|
||||
src.repeatedEArray = [GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:UnknownEnumsMyEnum_Bar];
|
||||
src.repeatedEArray =
|
||||
[GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:UnknownEnumsMyEnum_Bar];
|
||||
src.repeatedPackedEArray =
|
||||
[GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:UnknownEnumsMyEnum_Bar];
|
||||
@@ -210,7 +211,8 @@
|
||||
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.repeatedPackedEArray valueAtIndex:0],
|
||||
UnknownEnumsMyEnum_Bar);
|
||||
XCTAssertEqual(dst.oneofE1, UnknownEnumsMyEnum_Bar);
|
||||
|
||||
// Unknown value.
|
||||
@@ -218,8 +220,9 @@
|
||||
const int32_t kUnknownValue = 666;
|
||||
|
||||
SetUnknownEnumsMyMessage_E_RawValue(src, kUnknownValue);
|
||||
src.repeatedEArray = [GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:kUnknownValue];
|
||||
src.repeatedEArray =
|
||||
[GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:kUnknownValue];
|
||||
src.repeatedPackedEArray =
|
||||
[GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:kUnknownValue];
|
||||
@@ -235,11 +238,13 @@
|
||||
UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual([dst.repeatedEArray rawValueAtIndex:1], kUnknownValue);
|
||||
XCTAssertEqual(dst.repeatedPackedEArray.count, 2U);
|
||||
XCTAssertEqual([dst.repeatedPackedEArray valueAtIndex:0], UnknownEnumsMyEnum_Bar);
|
||||
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(dst.oneofE1,
|
||||
UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual(UnknownEnumsMyMessage_OneofE1_RawValue(dst), kUnknownValue);
|
||||
}
|
||||
|
||||
@@ -253,9 +258,6 @@
|
||||
|
||||
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];
|
||||
@@ -265,6 +267,7 @@
|
||||
//%
|
||||
//%PDDM-EXPAND MERGE2_TEST(Int32, 10, Enum, Message2_Enum_Baz)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofInt32 = 10;
|
||||
[dst mergeFrom:src];
|
||||
@@ -272,8 +275,10 @@
|
||||
XCTAssertEqual(dst.oneofInt32, 10);
|
||||
XCTAssertEqual(dst.oneofEnum, Message2_Enum_Baz);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Int64, 11, Int32, 100)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofInt64 = 11;
|
||||
[dst mergeFrom:src];
|
||||
@@ -281,8 +286,10 @@
|
||||
XCTAssertEqual(dst.oneofInt64, 11);
|
||||
XCTAssertEqual(dst.oneofInt32, 100);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Uint32, 12U, Int64, 101)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofUint32 = 12U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -290,8 +297,10 @@
|
||||
XCTAssertEqual(dst.oneofUint32, 12U);
|
||||
XCTAssertEqual(dst.oneofInt64, 101);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Uint64, 13U, Uint32, 102U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofUint64 = 13U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -299,8 +308,10 @@
|
||||
XCTAssertEqual(dst.oneofUint64, 13U);
|
||||
XCTAssertEqual(dst.oneofUint32, 102U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Sint32, 14, Uint64, 103U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSint32 = 14;
|
||||
[dst mergeFrom:src];
|
||||
@@ -308,8 +319,10 @@
|
||||
XCTAssertEqual(dst.oneofSint32, 14);
|
||||
XCTAssertEqual(dst.oneofUint64, 103U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Sint64, 15, Sint32, 104)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSint64 = 15;
|
||||
[dst mergeFrom:src];
|
||||
@@ -317,8 +330,10 @@
|
||||
XCTAssertEqual(dst.oneofSint64, 15);
|
||||
XCTAssertEqual(dst.oneofSint32, 104);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Fixed32, 16U, Sint64, 105)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofFixed32 = 16U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -326,8 +341,10 @@
|
||||
XCTAssertEqual(dst.oneofFixed32, 16U);
|
||||
XCTAssertEqual(dst.oneofSint64, 105);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Fixed64, 17U, Fixed32, 106U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofFixed64 = 17U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -335,8 +352,10 @@
|
||||
XCTAssertEqual(dst.oneofFixed64, 17U);
|
||||
XCTAssertEqual(dst.oneofFixed32, 106U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Sfixed32, 18, Fixed64, 107U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSfixed32 = 18;
|
||||
[dst mergeFrom:src];
|
||||
@@ -344,8 +363,10 @@
|
||||
XCTAssertEqual(dst.oneofSfixed32, 18);
|
||||
XCTAssertEqual(dst.oneofFixed64, 107U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Sfixed64, 19, Sfixed32, 108)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSfixed64 = 19;
|
||||
[dst mergeFrom:src];
|
||||
@@ -353,8 +374,10 @@
|
||||
XCTAssertEqual(dst.oneofSfixed64, 19);
|
||||
XCTAssertEqual(dst.oneofSfixed32, 108);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Float, 20.0f, Sfixed64, 109)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofFloat = 20.0f;
|
||||
[dst mergeFrom:src];
|
||||
@@ -362,8 +385,10 @@
|
||||
XCTAssertEqual(dst.oneofFloat, 20.0f);
|
||||
XCTAssertEqual(dst.oneofSfixed64, 109);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Double, 21.0, Float, 110.0f)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofDouble = 21.0;
|
||||
[dst mergeFrom:src];
|
||||
@@ -371,8 +396,10 @@
|
||||
XCTAssertEqual(dst.oneofDouble, 21.0);
|
||||
XCTAssertEqual(dst.oneofFloat, 110.0f);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Bool, NO, Double, 111.0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofBool = NO;
|
||||
[dst mergeFrom:src];
|
||||
@@ -380,8 +407,10 @@
|
||||
XCTAssertEqual(dst.oneofBool, NO);
|
||||
XCTAssertEqual(dst.oneofDouble, 111.0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Enum, Message2_Enum_Bar, Bool, YES)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofEnum = Message2_Enum_Bar;
|
||||
[dst mergeFrom:src];
|
||||
@@ -389,10 +418,9 @@
|
||||
XCTAssertEqual(dst.oneofEnum, Message2_Enum_Bar);
|
||||
XCTAssertEqual(dst.oneofBool, YES);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END (14 expansions)
|
||||
|
||||
// clang-format on
|
||||
|
||||
NSString *oneofStringDefault = @"string";
|
||||
NSData *oneofBytesDefault = [@"data" dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
@@ -405,7 +433,8 @@
|
||||
src.oneofBytes = [@"bar" dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofBytes);
|
||||
XCTAssertEqualObjects(dst.oneofBytes, [@"bar" dataUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertEqualObjects(dst.oneofBytes,
|
||||
[@"bar" dataUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertEqualObjects(dst.oneofString, oneofStringDefault);
|
||||
|
||||
Message2_OneofGroup *group = [Message2_OneofGroup message];
|
||||
@@ -477,9 +506,6 @@
|
||||
|
||||
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];
|
||||
@@ -489,6 +515,7 @@
|
||||
//%
|
||||
//%PDDM-EXPAND MERGE3_TEST(Int32, 10, Enum, Message3_Enum_Foo)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofInt32 = 10;
|
||||
[dst mergeFrom:src];
|
||||
@@ -496,8 +523,10 @@
|
||||
XCTAssertEqual(dst.oneofInt32, 10);
|
||||
XCTAssertEqual(dst.oneofEnum, Message3_Enum_Foo);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Int64, 11, Int32, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofInt64 = 11;
|
||||
[dst mergeFrom:src];
|
||||
@@ -505,8 +534,10 @@
|
||||
XCTAssertEqual(dst.oneofInt64, 11);
|
||||
XCTAssertEqual(dst.oneofInt32, 0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Uint32, 12U, Int64, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofUint32 = 12U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -514,8 +545,10 @@
|
||||
XCTAssertEqual(dst.oneofUint32, 12U);
|
||||
XCTAssertEqual(dst.oneofInt64, 0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Uint64, 13U, Uint32, 0U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofUint64 = 13U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -523,8 +556,10 @@
|
||||
XCTAssertEqual(dst.oneofUint64, 13U);
|
||||
XCTAssertEqual(dst.oneofUint32, 0U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Sint32, 14, Uint64, 0U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSint32 = 14;
|
||||
[dst mergeFrom:src];
|
||||
@@ -532,8 +567,10 @@
|
||||
XCTAssertEqual(dst.oneofSint32, 14);
|
||||
XCTAssertEqual(dst.oneofUint64, 0U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Sint64, 15, Sint32, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSint64 = 15;
|
||||
[dst mergeFrom:src];
|
||||
@@ -541,8 +578,10 @@
|
||||
XCTAssertEqual(dst.oneofSint64, 15);
|
||||
XCTAssertEqual(dst.oneofSint32, 0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Fixed32, 16U, Sint64, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofFixed32 = 16U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -550,8 +589,10 @@
|
||||
XCTAssertEqual(dst.oneofFixed32, 16U);
|
||||
XCTAssertEqual(dst.oneofSint64, 0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Fixed64, 17U, Fixed32, 0U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofFixed64 = 17U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -559,8 +600,10 @@
|
||||
XCTAssertEqual(dst.oneofFixed64, 17U);
|
||||
XCTAssertEqual(dst.oneofFixed32, 0U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Sfixed32, 18, Fixed64, 0U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSfixed32 = 18;
|
||||
[dst mergeFrom:src];
|
||||
@@ -568,8 +611,10 @@
|
||||
XCTAssertEqual(dst.oneofSfixed32, 18);
|
||||
XCTAssertEqual(dst.oneofFixed64, 0U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Sfixed64, 19, Sfixed32, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSfixed64 = 19;
|
||||
[dst mergeFrom:src];
|
||||
@@ -577,8 +622,10 @@
|
||||
XCTAssertEqual(dst.oneofSfixed64, 19);
|
||||
XCTAssertEqual(dst.oneofSfixed32, 0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Float, 20.0f, Sfixed64, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofFloat = 20.0f;
|
||||
[dst mergeFrom:src];
|
||||
@@ -586,8 +633,10 @@
|
||||
XCTAssertEqual(dst.oneofFloat, 20.0f);
|
||||
XCTAssertEqual(dst.oneofSfixed64, 0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Double, 21.0, Float, 0.0f)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofDouble = 21.0;
|
||||
[dst mergeFrom:src];
|
||||
@@ -595,8 +644,10 @@
|
||||
XCTAssertEqual(dst.oneofDouble, 21.0);
|
||||
XCTAssertEqual(dst.oneofFloat, 0.0f);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Bool, YES, Double, 0.0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofBool = YES;
|
||||
[dst mergeFrom:src];
|
||||
@@ -604,8 +655,10 @@
|
||||
XCTAssertEqual(dst.oneofBool, YES);
|
||||
XCTAssertEqual(dst.oneofDouble, 0.0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Enum, Message3_Enum_Bar, Bool, NO)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofEnum = Message3_Enum_Bar;
|
||||
[dst mergeFrom:src];
|
||||
@@ -613,10 +666,9 @@
|
||||
XCTAssertEqual(dst.oneofEnum, Message3_Enum_Bar);
|
||||
XCTAssertEqual(dst.oneofBool, NO);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END (14 expansions)
|
||||
|
||||
// clang-format on
|
||||
|
||||
NSString *oneofStringDefault = @"";
|
||||
NSData *oneofBytesDefault = [NSData data];
|
||||
|
||||
@@ -629,9 +681,11 @@
|
||||
src.oneofBytes = [@"bar" dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofBytes);
|
||||
XCTAssertEqualObjects(dst.oneofBytes, [@"bar" dataUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertEqualObjects(dst.oneofBytes,
|
||||
[@"bar" dataUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertEqualObjects(dst.oneofString, oneofStringDefault);
|
||||
|
||||
|
||||
Message3 *subMessage = [Message3 message];
|
||||
subMessage.optionalInt32 = 777;
|
||||
src.oneofMessage = subMessage;
|
||||
|
||||
@@ -34,12 +34,12 @@
|
||||
|
||||
#import "GPBMessage.h"
|
||||
|
||||
#import "objectivec/Tests/MapUnittest.pbobjc.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestCycle.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjcStartup.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto3.pbobjc.h"
|
||||
#import "google/protobuf/MapUnittest.pbobjc.h"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/UnittestCycle.pbobjc.h"
|
||||
#import "google/protobuf/UnittestObjcStartup.pbobjc.h"
|
||||
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
|
||||
#import "google/protobuf/UnittestRuntimeProto3.pbobjc.h"
|
||||
|
||||
@interface MessageRuntimeTests : GPBTestCase
|
||||
@end
|
||||
@@ -98,10 +98,14 @@
|
||||
|
||||
for (NSString *name in names) {
|
||||
// build the selector, i.e. - hasOptionalInt32/setHasOptionalInt32:
|
||||
SEL hasSel = NSSelectorFromString([NSString stringWithFormat:@"hasOptional%@", name]);
|
||||
SEL setHasSel = NSSelectorFromString([NSString stringWithFormat:@"setHasOptional%@:", name]);
|
||||
XCTAssertTrue([Message2 instancesRespondToSelector:hasSel], @"field: %@", name);
|
||||
XCTAssertTrue([Message2 instancesRespondToSelector:setHasSel], @"field: %@", name);
|
||||
SEL hasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"hasOptional%@", name]);
|
||||
SEL setHasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"setHasOptional%@:", name]);
|
||||
XCTAssertTrue([Message2 instancesRespondToSelector:hasSel], @"field: %@",
|
||||
name);
|
||||
XCTAssertTrue([Message2 instancesRespondToSelector:setHasSel], @"field: %@",
|
||||
name);
|
||||
}
|
||||
|
||||
// Repeated fields
|
||||
@@ -110,24 +114,33 @@
|
||||
|
||||
for (NSString *name in names) {
|
||||
// build the selector, i.e. - hasRepeatedInt32Array/setHasRepeatedInt32Array:
|
||||
SEL hasSel = NSSelectorFromString([NSString stringWithFormat:@"hasRepeated%@Array", name]);
|
||||
SEL setHasSel =
|
||||
NSSelectorFromString([NSString stringWithFormat:@"setHasRepeated%@Array:", name]);
|
||||
XCTAssertFalse([Message2 instancesRespondToSelector:hasSel], @"field: %@", name);
|
||||
XCTAssertFalse([Message2 instancesRespondToSelector:setHasSel], @"field: %@", name);
|
||||
SEL hasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"hasRepeated%@Array", name]);
|
||||
SEL setHasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"setHasRepeated%@Array:", name]);
|
||||
XCTAssertFalse([Message2 instancesRespondToSelector:hasSel], @"field: %@",
|
||||
name);
|
||||
XCTAssertFalse([Message2 instancesRespondToSelector:setHasSel],
|
||||
@"field: %@", name);
|
||||
// build the selector, i.e. - repeatedInt32Array_Count
|
||||
SEL countSel = NSSelectorFromString([NSString stringWithFormat:@"repeated%@Array_Count", name]);
|
||||
XCTAssertTrue([Message2 instancesRespondToSelector:countSel], @"field: %@", name);
|
||||
SEL countSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"repeated%@Array_Count", name]);
|
||||
XCTAssertTrue([Message2 instancesRespondToSelector:countSel], @"field: %@",
|
||||
name);
|
||||
}
|
||||
|
||||
// OneOf fields - no has*/setHas*
|
||||
|
||||
for (NSString *name in names) {
|
||||
// build the selector, i.e. - hasOneofInt32/setHasOneofInt32:
|
||||
SEL hasSel = NSSelectorFromString([NSString stringWithFormat:@"hasOneof%@", name]);
|
||||
SEL setHasSel = NSSelectorFromString([NSString stringWithFormat:@"setHasOneof%@:", name]);
|
||||
XCTAssertFalse([Message2 instancesRespondToSelector:hasSel], @"field: %@", name);
|
||||
XCTAssertFalse([Message2 instancesRespondToSelector:setHasSel], @"field: %@", name);
|
||||
SEL hasSel =
|
||||
NSSelectorFromString([NSString stringWithFormat:@"hasOneof%@", name]);
|
||||
SEL setHasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"setHasOneof%@:", name]);
|
||||
XCTAssertFalse([Message2 instancesRespondToSelector:hasSel], @"field: %@",
|
||||
name);
|
||||
XCTAssertFalse([Message2 instancesRespondToSelector:setHasSel],
|
||||
@"field: %@", name);
|
||||
}
|
||||
|
||||
// map<> fields
|
||||
@@ -135,23 +148,44 @@
|
||||
// - *Count
|
||||
|
||||
NSArray *mapNames = @[
|
||||
@"Int32Int32", @"Int64Int64", @"Uint32Uint32", @"Uint64Uint64",
|
||||
@"Sint32Sint32", @"Sint64Sint64", @"Fixed32Fixed32", @"Fixed64Fixed64",
|
||||
@"Sfixed32Sfixed32", @"Sfixed64Sfixed64", @"Int32Float", @"Int32Double",
|
||||
@"BoolBool", @"StringString", @"StringBytes", @"StringMessage",
|
||||
@"Int32Bytes", @"Int32Enum", @"Int32Message",
|
||||
@"Int32Int32",
|
||||
@"Int64Int64",
|
||||
@"Uint32Uint32",
|
||||
@"Uint64Uint64",
|
||||
@"Sint32Sint32",
|
||||
@"Sint64Sint64",
|
||||
@"Fixed32Fixed32",
|
||||
@"Fixed64Fixed64",
|
||||
@"Sfixed32Sfixed32",
|
||||
@"Sfixed64Sfixed64",
|
||||
@"Int32Float",
|
||||
@"Int32Double",
|
||||
@"BoolBool",
|
||||
@"StringString",
|
||||
@"StringBytes",
|
||||
@"StringMessage",
|
||||
@"Int32Bytes",
|
||||
@"Int32Enum",
|
||||
@"Int32Message",
|
||||
];
|
||||
|
||||
for (NSString *name in mapNames) {
|
||||
// build the selector, i.e. - hasMapInt32Int32/setHasMapInt32Int32:
|
||||
SEL hasSel = NSSelectorFromString([NSString stringWithFormat:@"hasMap%@", name]);
|
||||
SEL setHasSel = NSSelectorFromString([NSString stringWithFormat:@"setHasMap%@:", name]);
|
||||
XCTAssertFalse([Message2 instancesRespondToSelector:hasSel], @"field: %@", name);
|
||||
XCTAssertFalse([Message2 instancesRespondToSelector:setHasSel], @"field: %@", name);
|
||||
SEL hasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"hasMap%@", name]);
|
||||
SEL setHasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"setHasMap%@:", name]);
|
||||
XCTAssertFalse([Message2 instancesRespondToSelector:hasSel], @"field: %@",
|
||||
name);
|
||||
XCTAssertFalse([Message2 instancesRespondToSelector:setHasSel],
|
||||
@"field: %@", name);
|
||||
// build the selector, i.e. - mapInt32Int32Count
|
||||
SEL countSel = NSSelectorFromString([NSString stringWithFormat:@"map%@_Count", name]);
|
||||
XCTAssertTrue([Message2 instancesRespondToSelector:countSel], @"field: %@", name);
|
||||
SEL countSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"map%@_Count", name]);
|
||||
XCTAssertTrue([Message2 instancesRespondToSelector:countSel], @"field: %@",
|
||||
name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)testProto3HasMethodSupport {
|
||||
@@ -183,15 +217,21 @@
|
||||
|
||||
for (NSString *name in names) {
|
||||
// build the selector, i.e. - hasOptionalInt32/setHasOptionalInt32:
|
||||
SEL hasSel = NSSelectorFromString([NSString stringWithFormat:@"hasOptional%@", name]);
|
||||
SEL setHasSel = NSSelectorFromString([NSString stringWithFormat:@"setHasOptional%@:", name]);
|
||||
SEL hasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"hasOptional%@", name]);
|
||||
SEL setHasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"setHasOptional%@:", name]);
|
||||
if ([name isEqual:@"Message"]) {
|
||||
// Sub messages/groups are the exception.
|
||||
XCTAssertTrue([Message3 instancesRespondToSelector:hasSel], @"field: %@", name);
|
||||
XCTAssertTrue([Message3 instancesRespondToSelector:setHasSel], @"field: %@", name);
|
||||
XCTAssertTrue([Message3 instancesRespondToSelector:hasSel], @"field: %@",
|
||||
name);
|
||||
XCTAssertTrue([Message3 instancesRespondToSelector:setHasSel],
|
||||
@"field: %@", name);
|
||||
} else {
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:hasSel], @"field: %@", name);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:setHasSel], @"field: %@", name);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:hasSel], @"field: %@",
|
||||
name);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:setHasSel],
|
||||
@"field: %@", name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,24 +241,33 @@
|
||||
|
||||
for (NSString *name in names) {
|
||||
// build the selector, i.e. - hasRepeatedInt32Array/setHasRepeatedInt32Array:
|
||||
SEL hasSel = NSSelectorFromString([NSString stringWithFormat:@"hasRepeated%@Array", name]);
|
||||
SEL setHasSel =
|
||||
NSSelectorFromString([NSString stringWithFormat:@"setHasRepeated%@Array:", name]);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:hasSel], @"field: %@", name);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:setHasSel], @"field: %@", name);
|
||||
SEL hasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"hasRepeated%@Array", name]);
|
||||
SEL setHasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"setHasRepeated%@Array:", name]);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:hasSel], @"field: %@",
|
||||
name);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:setHasSel],
|
||||
@"field: %@", name);
|
||||
// build the selector, i.e. - repeatedInt32Array_Count
|
||||
SEL countSel = NSSelectorFromString([NSString stringWithFormat:@"repeated%@Array_Count", name]);
|
||||
XCTAssertTrue([Message3 instancesRespondToSelector:countSel], @"field: %@", name);
|
||||
SEL countSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"repeated%@Array_Count", name]);
|
||||
XCTAssertTrue([Message3 instancesRespondToSelector:countSel], @"field: %@",
|
||||
name);
|
||||
}
|
||||
|
||||
// OneOf fields - no has*/setHas*
|
||||
|
||||
for (NSString *name in names) {
|
||||
// build the selector, i.e. - hasOneofInt32/setHasOneofInt32:
|
||||
SEL hasSel = NSSelectorFromString([NSString stringWithFormat:@"hasOneof%@", name]);
|
||||
SEL setHasSel = NSSelectorFromString([NSString stringWithFormat:@"setHasOneof%@:", name]);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:hasSel], @"field: %@", name);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:setHasSel], @"field: %@", name);
|
||||
SEL hasSel =
|
||||
NSSelectorFromString([NSString stringWithFormat:@"hasOneof%@", name]);
|
||||
SEL setHasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"setHasOneof%@:", name]);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:hasSel], @"field: %@",
|
||||
name);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:setHasSel],
|
||||
@"field: %@", name);
|
||||
}
|
||||
|
||||
// Single Optional fields
|
||||
@@ -228,10 +277,14 @@
|
||||
|
||||
for (NSString *name in names) {
|
||||
// build the selector, i.e. - hasOptionalInt32/setHasOptionalInt32:
|
||||
SEL hasSel = NSSelectorFromString([NSString stringWithFormat:@"hasOptional%@", name]);
|
||||
SEL setHasSel = NSSelectorFromString([NSString stringWithFormat:@"setHasOptional%@:", name]);
|
||||
XCTAssertTrue([Message3Optional instancesRespondToSelector:hasSel], @"field: %@", name);
|
||||
XCTAssertTrue([Message3Optional instancesRespondToSelector:setHasSel], @"field: %@", name);
|
||||
SEL hasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"hasOptional%@", name]);
|
||||
SEL setHasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"setHasOptional%@:", name]);
|
||||
XCTAssertTrue([Message3Optional instancesRespondToSelector:hasSel], @"field: %@",
|
||||
name);
|
||||
XCTAssertTrue([Message3Optional instancesRespondToSelector:setHasSel],
|
||||
@"field: %@", name);
|
||||
}
|
||||
|
||||
// map<> fields
|
||||
@@ -239,22 +292,42 @@
|
||||
// - *Count
|
||||
|
||||
NSArray *mapNames = @[
|
||||
@"Int32Int32", @"Int64Int64", @"Uint32Uint32", @"Uint64Uint64",
|
||||
@"Sint32Sint32", @"Sint64Sint64", @"Fixed32Fixed32", @"Fixed64Fixed64",
|
||||
@"Sfixed32Sfixed32", @"Sfixed64Sfixed64", @"Int32Float", @"Int32Double",
|
||||
@"BoolBool", @"StringString", @"StringBytes", @"StringMessage",
|
||||
@"Int32Bytes", @"Int32Enum", @"Int32Message",
|
||||
@"Int32Int32",
|
||||
@"Int64Int64",
|
||||
@"Uint32Uint32",
|
||||
@"Uint64Uint64",
|
||||
@"Sint32Sint32",
|
||||
@"Sint64Sint64",
|
||||
@"Fixed32Fixed32",
|
||||
@"Fixed64Fixed64",
|
||||
@"Sfixed32Sfixed32",
|
||||
@"Sfixed64Sfixed64",
|
||||
@"Int32Float",
|
||||
@"Int32Double",
|
||||
@"BoolBool",
|
||||
@"StringString",
|
||||
@"StringBytes",
|
||||
@"StringMessage",
|
||||
@"Int32Bytes",
|
||||
@"Int32Enum",
|
||||
@"Int32Message",
|
||||
];
|
||||
|
||||
for (NSString *name in mapNames) {
|
||||
// build the selector, i.e. - hasMapInt32Int32/setHasMapInt32Int32:
|
||||
SEL hasSel = NSSelectorFromString([NSString stringWithFormat:@"hasMap%@", name]);
|
||||
SEL setHasSel = NSSelectorFromString([NSString stringWithFormat:@"setHasMap%@:", name]);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:hasSel], @"field: %@", name);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:setHasSel], @"field: %@", name);
|
||||
SEL hasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"hasMap%@", name]);
|
||||
SEL setHasSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"setHasMap%@:", name]);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:hasSel], @"field: %@",
|
||||
name);
|
||||
XCTAssertFalse([Message3 instancesRespondToSelector:setHasSel],
|
||||
@"field: %@", name);
|
||||
// build the selector, i.e. - mapInt32Int32Count
|
||||
SEL countSel = NSSelectorFromString([NSString stringWithFormat:@"map%@_Count", name]);
|
||||
XCTAssertTrue([Message3 instancesRespondToSelector:countSel], @"field: %@", name);
|
||||
SEL countSel = NSSelectorFromString(
|
||||
[NSString stringWithFormat:@"map%@_Count", name]);
|
||||
XCTAssertTrue([Message3 instancesRespondToSelector:countSel], @"field: %@",
|
||||
name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,9 +337,6 @@
|
||||
// being true.
|
||||
//
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-DEFINE PROTO2_TEST_HAS_FIELD(FIELD, NON_ZERO_VALUE, ZERO_VALUE)
|
||||
//% { // optional##FIELD :: NON_ZERO_VALUE
|
||||
//% Message2 *msg = [[Message2 alloc] init];
|
||||
@@ -329,6 +399,7 @@
|
||||
//%PROTO2_TEST_CLEAR_FIELD_WITH_NIL(Message, [Message2 message])
|
||||
//%PDDM-EXPAND PROTO2_TEST_HAS_FIELDS()
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
{ // optionalInt32 :: 1
|
||||
Message2 *msg = [[Message2 alloc] init];
|
||||
@@ -682,9 +753,8 @@
|
||||
[msg release];
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END PROTO2_TEST_HAS_FIELDS()
|
||||
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
- (void)testProto3SingleFieldHasBehavior {
|
||||
@@ -693,9 +763,6 @@
|
||||
// being true. When set to the default, shouldn't be true.
|
||||
//
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-DEFINE PROTO3_TEST_HAS_FIELD(FIELD, NON_ZERO_VALUE, ZERO_VALUE)
|
||||
//% { // optional##FIELD
|
||||
//% Message3 *msg = [[Message3 alloc] init];
|
||||
@@ -748,6 +815,7 @@
|
||||
//%PROTO3_TEST_CLEAR_FIELD_WITH_NIL(Message, [Message3 message])
|
||||
//%PDDM-EXPAND PROTO3_TEST_HAS_FIELDS()
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
{ // optionalInt32
|
||||
Message3 *msg = [[Message3 alloc] init];
|
||||
@@ -947,9 +1015,8 @@
|
||||
[msg release];
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END PROTO3_TEST_HAS_FIELDS()
|
||||
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
- (void)testProto3SingleOptionalFieldHasBehavior {
|
||||
@@ -957,9 +1024,6 @@
|
||||
// Setting to any value including the default (0) should result in true.
|
||||
//
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-DEFINE PROTO3_TEST_OPTIONAL_HAS_FIELD(FIELD, NON_ZERO_VALUE, ZERO_VALUE)
|
||||
//% { // optional##FIELD
|
||||
//% Message3Optional *msg = [[Message3Optional alloc] init];
|
||||
@@ -996,6 +1060,7 @@
|
||||
//%PROTO3_TEST_OPTIONAL_HAS_FIELD(Enum, Message3Optional_Enum_Bar, Message3Optional_Enum_Foo)
|
||||
//%PDDM-EXPAND PROTO3_TEST_OPTIONAL_HAS_FIELDS()
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
{ // optionalInt32
|
||||
Message3Optional *msg = [[Message3Optional alloc] init];
|
||||
@@ -1193,9 +1258,8 @@
|
||||
[msg release];
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END PROTO3_TEST_OPTIONAL_HAS_FIELDS()
|
||||
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
- (void)testAccessingProto2UnknownEnumValues {
|
||||
@@ -1204,11 +1268,13 @@
|
||||
// Set it to something non zero, try and confirm it doesn't change.
|
||||
|
||||
msg.optionalEnum = Message2_Enum_Bar;
|
||||
XCTAssertThrowsSpecificNamed(msg.optionalEnum = 666, NSException, NSInvalidArgumentException);
|
||||
XCTAssertThrowsSpecificNamed(msg.optionalEnum = 666, NSException,
|
||||
NSInvalidArgumentException);
|
||||
XCTAssertEqual(msg.optionalEnum, Message2_Enum_Bar);
|
||||
|
||||
msg.oneofEnum = Message2_Enum_Bar;
|
||||
XCTAssertThrowsSpecificNamed(msg.oneofEnum = 666, NSException, NSInvalidArgumentException);
|
||||
XCTAssertThrowsSpecificNamed(msg.oneofEnum = 666, NSException,
|
||||
NSInvalidArgumentException);
|
||||
XCTAssertEqual(msg.oneofEnum, Message2_Enum_Bar);
|
||||
|
||||
[msg release];
|
||||
@@ -1220,17 +1286,20 @@
|
||||
// Set it to something non zero, try and confirm it doesn't change.
|
||||
|
||||
msg.optionalEnum = Message3_Enum_Bar;
|
||||
XCTAssertThrowsSpecificNamed(msg.optionalEnum = 666, NSException, NSInvalidArgumentException);
|
||||
XCTAssertThrowsSpecificNamed(msg.optionalEnum = 666, NSException,
|
||||
NSInvalidArgumentException);
|
||||
XCTAssertEqual(msg.optionalEnum, Message3_Enum_Bar);
|
||||
|
||||
msg.oneofEnum = Message3_Enum_Bar;
|
||||
XCTAssertThrowsSpecificNamed(msg.oneofEnum = 666, NSException, NSInvalidArgumentException);
|
||||
XCTAssertThrowsSpecificNamed(msg.oneofEnum = 666, NSException,
|
||||
NSInvalidArgumentException);
|
||||
XCTAssertEqual(msg.oneofEnum, Message3_Enum_Bar);
|
||||
|
||||
// Set via raw api to confirm it works.
|
||||
|
||||
SetMessage3_OptionalEnum_RawValue(msg, 666);
|
||||
XCTAssertEqual(msg.optionalEnum, Message3_Enum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual(msg.optionalEnum,
|
||||
Message3_Enum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual(Message3_OptionalEnum_RawValue(msg), 666);
|
||||
|
||||
SetMessage3_OneofEnum_RawValue(msg, 666);
|
||||
@@ -1594,7 +1663,8 @@
|
||||
XCTAssertEqual(msg.oneofDouble, 111.0);
|
||||
XCTAssertEqual(msg.oneofBool, YES);
|
||||
XCTAssertEqualObjects(msg.oneofString, oneofStringDefault);
|
||||
XCTAssertEqualObjects(msg.oneofBytes, [@"bar" dataUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertEqualObjects(msg.oneofBytes,
|
||||
[@"bar" dataUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertNotNil(msg.oneofGroup);
|
||||
XCTAssertNotNil(msg.oneofMessage);
|
||||
XCTAssertEqual(msg.oneofEnum, Message2_Enum_Baz);
|
||||
@@ -1677,15 +1747,24 @@
|
||||
msg = [[Message2 alloc] init];
|
||||
|
||||
int32_t values[] = {
|
||||
Message2_O_OneOfCase_OneofInt32, Message2_O_OneOfCase_OneofInt64,
|
||||
Message2_O_OneOfCase_OneofUint32, Message2_O_OneOfCase_OneofUint64,
|
||||
Message2_O_OneOfCase_OneofSint32, Message2_O_OneOfCase_OneofSint64,
|
||||
Message2_O_OneOfCase_OneofFixed32, Message2_O_OneOfCase_OneofFixed64,
|
||||
Message2_O_OneOfCase_OneofSfixed32, Message2_O_OneOfCase_OneofSfixed64,
|
||||
Message2_O_OneOfCase_OneofFloat, Message2_O_OneOfCase_OneofDouble,
|
||||
Message2_O_OneOfCase_OneofBool, Message2_O_OneOfCase_OneofString,
|
||||
Message2_O_OneOfCase_OneofBytes, Message2_O_OneOfCase_OneofGroup,
|
||||
Message2_O_OneOfCase_OneofMessage, Message2_O_OneOfCase_OneofEnum,
|
||||
Message2_O_OneOfCase_OneofInt32,
|
||||
Message2_O_OneOfCase_OneofInt64,
|
||||
Message2_O_OneOfCase_OneofUint32,
|
||||
Message2_O_OneOfCase_OneofUint64,
|
||||
Message2_O_OneOfCase_OneofSint32,
|
||||
Message2_O_OneOfCase_OneofSint64,
|
||||
Message2_O_OneOfCase_OneofFixed32,
|
||||
Message2_O_OneOfCase_OneofFixed64,
|
||||
Message2_O_OneOfCase_OneofSfixed32,
|
||||
Message2_O_OneOfCase_OneofSfixed64,
|
||||
Message2_O_OneOfCase_OneofFloat,
|
||||
Message2_O_OneOfCase_OneofDouble,
|
||||
Message2_O_OneOfCase_OneofBool,
|
||||
Message2_O_OneOfCase_OneofString,
|
||||
Message2_O_OneOfCase_OneofBytes,
|
||||
Message2_O_OneOfCase_OneofGroup,
|
||||
Message2_O_OneOfCase_OneofMessage,
|
||||
Message2_O_OneOfCase_OneofEnum,
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
|
||||
@@ -1753,7 +1832,8 @@
|
||||
// No need to check the value was set, the above tests did that.
|
||||
Message2_ClearOOneOfCase(msg);
|
||||
// Nothing in the case.
|
||||
XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_GPBUnsetOneOfCase, "Loop: %zd", i);
|
||||
XCTAssertEqual(msg.oOneOfCase, Message2_O_OneOfCase_GPBUnsetOneOfCase,
|
||||
"Loop: %zd", i);
|
||||
// Confirm everything is back to defaults after a clear.
|
||||
XCTAssertEqual(msg.oneofInt32, 100, "Loop: %zd", i);
|
||||
XCTAssertEqual(msg.oneofInt64, 101, "Loop: %zd", i);
|
||||
@@ -2121,7 +2201,8 @@
|
||||
XCTAssertEqual(msg.oneofDouble, 0.0);
|
||||
XCTAssertEqual(msg.oneofBool, NO);
|
||||
XCTAssertEqualObjects(msg.oneofString, oneofStringDefault);
|
||||
XCTAssertEqualObjects(msg.oneofBytes, [@"bar" dataUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertEqualObjects(msg.oneofBytes,
|
||||
[@"bar" dataUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertNotNil(msg.oneofMessage);
|
||||
XCTAssertEqual(msg.oneofEnum, Message3_Enum_Foo);
|
||||
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_OneofBytes);
|
||||
@@ -2176,15 +2257,23 @@
|
||||
msg = [[Message3 alloc] init];
|
||||
|
||||
int32_t values[] = {
|
||||
Message3_O_OneOfCase_OneofInt32, Message3_O_OneOfCase_OneofInt64,
|
||||
Message3_O_OneOfCase_OneofUint32, Message3_O_OneOfCase_OneofUint64,
|
||||
Message3_O_OneOfCase_OneofSint32, Message3_O_OneOfCase_OneofSint64,
|
||||
Message3_O_OneOfCase_OneofFixed32, Message3_O_OneOfCase_OneofFixed64,
|
||||
Message3_O_OneOfCase_OneofSfixed32, Message3_O_OneOfCase_OneofSfixed64,
|
||||
Message3_O_OneOfCase_OneofFloat, Message3_O_OneOfCase_OneofDouble,
|
||||
Message3_O_OneOfCase_OneofBool, Message3_O_OneOfCase_OneofString,
|
||||
Message3_O_OneOfCase_OneofBytes, Message3_O_OneOfCase_OneofMessage,
|
||||
Message3_O_OneOfCase_OneofEnum,
|
||||
Message3_O_OneOfCase_OneofInt32,
|
||||
Message3_O_OneOfCase_OneofInt64,
|
||||
Message3_O_OneOfCase_OneofUint32,
|
||||
Message3_O_OneOfCase_OneofUint64,
|
||||
Message3_O_OneOfCase_OneofSint32,
|
||||
Message3_O_OneOfCase_OneofSint64,
|
||||
Message3_O_OneOfCase_OneofFixed32,
|
||||
Message3_O_OneOfCase_OneofFixed64,
|
||||
Message3_O_OneOfCase_OneofSfixed32,
|
||||
Message3_O_OneOfCase_OneofSfixed64,
|
||||
Message3_O_OneOfCase_OneofFloat,
|
||||
Message3_O_OneOfCase_OneofDouble,
|
||||
Message3_O_OneOfCase_OneofBool,
|
||||
Message3_O_OneOfCase_OneofString,
|
||||
Message3_O_OneOfCase_OneofBytes,
|
||||
Message3_O_OneOfCase_OneofMessage,
|
||||
Message3_O_OneOfCase_OneofEnum,
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
|
||||
@@ -2249,7 +2338,8 @@
|
||||
// No need to check the value was set, the above tests did that.
|
||||
Message3_ClearOOneOfCase(msg);
|
||||
// Nothing in the case.
|
||||
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_GPBUnsetOneOfCase, "Loop: %zd", i);
|
||||
XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_GPBUnsetOneOfCase,
|
||||
"Loop: %zd", i);
|
||||
// Confirm everything is back to defaults after a clear.
|
||||
XCTAssertEqual(msg.oneofInt32, 0, "Loop: %zd", i);
|
||||
XCTAssertEqual(msg.oneofInt64, 0, "Loop: %zd", i);
|
||||
@@ -2276,6 +2366,7 @@
|
||||
}
|
||||
|
||||
- (void)testProto2OneofSetToDefault {
|
||||
|
||||
// proto3 doesn't normally write out zero (default) fields, but if they are
|
||||
// in a oneof it does. proto2 doesn't have this special behavior, but we
|
||||
// still confirm setting to the explicit default does set the case to be
|
||||
@@ -2287,24 +2378,24 @@
|
||||
Message2 *msg = [[Message2 alloc] init];
|
||||
|
||||
int32_t values[] = {
|
||||
Message2_O_OneOfCase_OneofInt32,
|
||||
Message2_O_OneOfCase_OneofInt64,
|
||||
Message2_O_OneOfCase_OneofUint32,
|
||||
Message2_O_OneOfCase_OneofUint64,
|
||||
Message2_O_OneOfCase_OneofSint32,
|
||||
Message2_O_OneOfCase_OneofSint64,
|
||||
Message2_O_OneOfCase_OneofFixed32,
|
||||
Message2_O_OneOfCase_OneofFixed64,
|
||||
Message2_O_OneOfCase_OneofSfixed32,
|
||||
Message2_O_OneOfCase_OneofSfixed64,
|
||||
Message2_O_OneOfCase_OneofFloat,
|
||||
Message2_O_OneOfCase_OneofDouble,
|
||||
Message2_O_OneOfCase_OneofBool,
|
||||
Message2_O_OneOfCase_OneofString,
|
||||
Message2_O_OneOfCase_OneofBytes,
|
||||
// Skip group
|
||||
// Skip message
|
||||
Message2_O_OneOfCase_OneofEnum,
|
||||
Message2_O_OneOfCase_OneofInt32,
|
||||
Message2_O_OneOfCase_OneofInt64,
|
||||
Message2_O_OneOfCase_OneofUint32,
|
||||
Message2_O_OneOfCase_OneofUint64,
|
||||
Message2_O_OneOfCase_OneofSint32,
|
||||
Message2_O_OneOfCase_OneofSint64,
|
||||
Message2_O_OneOfCase_OneofFixed32,
|
||||
Message2_O_OneOfCase_OneofFixed64,
|
||||
Message2_O_OneOfCase_OneofSfixed32,
|
||||
Message2_O_OneOfCase_OneofSfixed64,
|
||||
Message2_O_OneOfCase_OneofFloat,
|
||||
Message2_O_OneOfCase_OneofDouble,
|
||||
Message2_O_OneOfCase_OneofBool,
|
||||
Message2_O_OneOfCase_OneofString,
|
||||
Message2_O_OneOfCase_OneofBytes,
|
||||
// Skip group
|
||||
// Skip message
|
||||
Message2_O_OneOfCase_OneofEnum,
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
|
||||
@@ -2405,6 +2496,7 @@
|
||||
}
|
||||
|
||||
- (void)testProto3OneofSetToZero {
|
||||
|
||||
// Normally setting a proto3 field to the zero value should result in it being
|
||||
// reset/cleared. But in a oneof, it still gets recorded so it can go out
|
||||
// over the wire and the other side can see what was set in the oneof.
|
||||
@@ -2415,15 +2507,23 @@
|
||||
Message3 *msg = [[Message3 alloc] init];
|
||||
|
||||
int32_t values[] = {
|
||||
Message3_O_OneOfCase_OneofInt32, Message3_O_OneOfCase_OneofInt64,
|
||||
Message3_O_OneOfCase_OneofUint32, Message3_O_OneOfCase_OneofUint64,
|
||||
Message3_O_OneOfCase_OneofSint32, Message3_O_OneOfCase_OneofSint64,
|
||||
Message3_O_OneOfCase_OneofFixed32, Message3_O_OneOfCase_OneofFixed64,
|
||||
Message3_O_OneOfCase_OneofSfixed32, Message3_O_OneOfCase_OneofSfixed64,
|
||||
Message3_O_OneOfCase_OneofFloat, Message3_O_OneOfCase_OneofDouble,
|
||||
Message3_O_OneOfCase_OneofBool, Message3_O_OneOfCase_OneofString,
|
||||
Message3_O_OneOfCase_OneofBytes, Message3_O_OneOfCase_OneofMessage,
|
||||
Message3_O_OneOfCase_OneofEnum,
|
||||
Message3_O_OneOfCase_OneofInt32,
|
||||
Message3_O_OneOfCase_OneofInt64,
|
||||
Message3_O_OneOfCase_OneofUint32,
|
||||
Message3_O_OneOfCase_OneofUint64,
|
||||
Message3_O_OneOfCase_OneofSint32,
|
||||
Message3_O_OneOfCase_OneofSint64,
|
||||
Message3_O_OneOfCase_OneofFixed32,
|
||||
Message3_O_OneOfCase_OneofFixed64,
|
||||
Message3_O_OneOfCase_OneofSfixed32,
|
||||
Message3_O_OneOfCase_OneofSfixed64,
|
||||
Message3_O_OneOfCase_OneofFloat,
|
||||
Message3_O_OneOfCase_OneofDouble,
|
||||
Message3_O_OneOfCase_OneofBool,
|
||||
Message3_O_OneOfCase_OneofString,
|
||||
Message3_O_OneOfCase_OneofBytes,
|
||||
Message3_O_OneOfCase_OneofMessage,
|
||||
Message3_O_OneOfCase_OneofEnum,
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < GPBARRAYSIZE(values); ++i) {
|
||||
@@ -2554,19 +2654,27 @@
|
||||
XCTAssertNotEqual(msg1.repeatedStringArray, msg2.repeatedStringArray);
|
||||
XCTAssertNotEqual(msg1.repeatedBytesArray, msg2.repeatedBytesArray);
|
||||
XCTAssertNotEqual(msg1.repeatedGroupArray, msg2.repeatedGroupArray);
|
||||
XCTAssertNotEqual(msg1.repeatedNestedMessageArray, msg2.repeatedNestedMessageArray);
|
||||
XCTAssertNotEqual(msg1.repeatedForeignMessageArray, msg2.repeatedForeignMessageArray);
|
||||
XCTAssertNotEqual(msg1.repeatedImportMessageArray, msg2.repeatedImportMessageArray);
|
||||
XCTAssertNotEqual(msg1.repeatedNestedMessageArray,
|
||||
msg2.repeatedNestedMessageArray);
|
||||
XCTAssertNotEqual(msg1.repeatedForeignMessageArray,
|
||||
msg2.repeatedForeignMessageArray);
|
||||
XCTAssertNotEqual(msg1.repeatedImportMessageArray,
|
||||
msg2.repeatedImportMessageArray);
|
||||
XCTAssertNotEqual(msg1.repeatedNestedEnumArray, msg2.repeatedNestedEnumArray);
|
||||
XCTAssertNotEqual(msg1.repeatedForeignEnumArray, msg2.repeatedForeignEnumArray);
|
||||
XCTAssertNotEqual(msg1.repeatedForeignEnumArray,
|
||||
msg2.repeatedForeignEnumArray);
|
||||
XCTAssertNotEqual(msg1.repeatedImportEnumArray, msg2.repeatedImportEnumArray);
|
||||
XCTAssertNotEqual(msg1.repeatedStringPieceArray, msg2.repeatedStringPieceArray);
|
||||
XCTAssertNotEqual(msg1.repeatedStringPieceArray,
|
||||
msg2.repeatedStringPieceArray);
|
||||
XCTAssertNotEqual(msg1.repeatedCordArray, msg2.repeatedCordArray);
|
||||
|
||||
for (int i = 0; i < repeatCount; i++) {
|
||||
XCTAssertNotEqual(msg1.repeatedNestedMessageArray[i], msg2.repeatedNestedMessageArray[i]);
|
||||
XCTAssertNotEqual(msg1.repeatedForeignMessageArray[i], msg2.repeatedForeignMessageArray[i]);
|
||||
XCTAssertNotEqual(msg1.repeatedImportMessageArray[i], msg2.repeatedImportMessageArray[i]);
|
||||
XCTAssertNotEqual(msg1.repeatedNestedMessageArray[i],
|
||||
msg2.repeatedNestedMessageArray[i]);
|
||||
XCTAssertNotEqual(msg1.repeatedForeignMessageArray[i],
|
||||
msg2.repeatedForeignMessageArray[i]);
|
||||
XCTAssertNotEqual(msg1.repeatedImportMessageArray[i],
|
||||
msg2.repeatedImportMessageArray[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2600,7 +2708,8 @@
|
||||
|
||||
// Ensure the messages are unique per map.
|
||||
[msg1.mapInt32ForeignMessage
|
||||
enumerateKeysAndObjectsUsingBlock:^(int32_t key, id value, __unused BOOL *stop) {
|
||||
enumerateKeysAndObjectsUsingBlock:^(int32_t key, id value, BOOL *stop) {
|
||||
#pragma unused(stop)
|
||||
ForeignMessage *subMsg2 = [msg2.mapInt32ForeignMessage objectForKey:key];
|
||||
XCTAssertNotEqual(value, subMsg2); // Ptr compare, new object.
|
||||
}];
|
||||
@@ -2611,7 +2720,7 @@
|
||||
GPBFieldDescriptor *fieldDescriptor = [[message descriptor] fieldWithName:@"repeatedStringArray"];
|
||||
XCTAssertNotNil(fieldDescriptor);
|
||||
NSMutableArray *fieldArray = GPBGetMessageRepeatedField(message, fieldDescriptor);
|
||||
XCTAssertNotNil(fieldArray); // Should have autocreated.
|
||||
XCTAssertNotNil(fieldArray); // Should have autocreated.
|
||||
XCTAssertTrue(fieldArray == message.repeatedStringArray); // Same pointer
|
||||
}
|
||||
|
||||
@@ -2631,7 +2740,7 @@
|
||||
GPBFieldDescriptor *fieldDescriptor = [[message descriptor] fieldWithName:@"mapStringString"];
|
||||
XCTAssertNotNil(fieldDescriptor);
|
||||
NSMutableDictionary *fieldMap = GPBGetMessageMapField(message, fieldDescriptor);
|
||||
XCTAssertNotNil(fieldMap); // Should have autocreated.
|
||||
XCTAssertNotNil(fieldMap); // Should have autocreated.
|
||||
XCTAssertTrue(fieldMap == message.mapStringString); // Same pointer
|
||||
}
|
||||
|
||||
|
||||
@@ -34,12 +34,13 @@
|
||||
|
||||
#import "GPBMessage.h"
|
||||
|
||||
#import "objectivec/Tests/MapProto2Unittest.pbobjc.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"
|
||||
#import "google/protobuf/MapProto2Unittest.pbobjc.h"
|
||||
#import "google/protobuf/MapUnittest.pbobjc.h"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/UnittestDropUnknownFields.pbobjc.h"
|
||||
#import "google/protobuf/UnittestPreserveUnknownEnum.pbobjc.h"
|
||||
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
|
||||
#import "google/protobuf/UnittestRuntimeProto3.pbobjc.h"
|
||||
|
||||
@interface MessageSerializationTests : GPBTestCase
|
||||
@end
|
||||
@@ -113,9 +114,6 @@
|
||||
// Proto3 optionals should be just like proto2, zero values also get serialized.
|
||||
//
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-DEFINE PROTO3_TEST_SERIALIZE_OPTIONAL_FIELD(FIELD, ZERO_VALUE, EXPECTED_LEN)
|
||||
//% { // optional##FIELD
|
||||
//% Message3Optional *msg = [[Message3Optional alloc] init];
|
||||
@@ -156,6 +154,7 @@
|
||||
//%PROTO3_TEST_SERIALIZE_OPTIONAL_FIELD(Enum, Message3Optional_Enum_Foo, 3)
|
||||
//%PDDM-EXPAND PROTO3_TEST_SERIALIZE_OPTIONAL_FIELDS()
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
{ // optionalInt32
|
||||
Message3Optional *msg = [[Message3Optional alloc] init];
|
||||
@@ -417,17 +416,17 @@
|
||||
[msg release];
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END PROTO3_TEST_SERIALIZE_OPTIONAL_FIELDS()
|
||||
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
- (void)testProto2UnknownEnumToUnknownField {
|
||||
Message3 *orig = [[Message3 alloc] init];
|
||||
|
||||
orig.optionalEnum = Message3_Enum_Extra3;
|
||||
orig.repeatedEnumArray = [GPBEnumArray arrayWithValidationFunction:Message3_Enum_IsValidValue
|
||||
rawValue:Message3_Enum_Extra3];
|
||||
orig.repeatedEnumArray =
|
||||
[GPBEnumArray arrayWithValidationFunction:Message3_Enum_IsValidValue
|
||||
rawValue:Message3_Enum_Extra3];
|
||||
orig.oneofEnum = Message3_Enum_Extra3;
|
||||
|
||||
NSData *data = [orig data];
|
||||
@@ -446,12 +445,15 @@
|
||||
|
||||
XCTAssertEqual([unknownFields countOfFields], 3U);
|
||||
XCTAssertTrue([unknownFields hasField:Message2_FieldNumber_OptionalEnum]);
|
||||
XCTAssertTrue([unknownFields hasField:Message2_FieldNumber_RepeatedEnumArray]);
|
||||
XCTAssertTrue(
|
||||
[unknownFields hasField:Message2_FieldNumber_RepeatedEnumArray]);
|
||||
XCTAssertTrue([unknownFields hasField:Message2_FieldNumber_OneofEnum]);
|
||||
|
||||
GPBUnknownField *field = [unknownFields getField:Message2_FieldNumber_OptionalEnum];
|
||||
GPBUnknownField *field =
|
||||
[unknownFields getField:Message2_FieldNumber_OptionalEnum];
|
||||
XCTAssertEqual(field.varintList.count, 1U);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], (uint64_t)Message3_Enum_Extra3);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0],
|
||||
(uint64_t)Message3_Enum_Extra3);
|
||||
|
||||
field = [unknownFields getField:Message2_FieldNumber_RepeatedEnumArray];
|
||||
XCTAssertEqual(field.varintList.count, 1U);
|
||||
@@ -459,32 +461,36 @@
|
||||
|
||||
field = [unknownFields getField:Message2_FieldNumber_OneofEnum];
|
||||
XCTAssertEqual(field.varintList.count, 1U);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0], (uint64_t)Message3_Enum_Extra3);
|
||||
XCTAssertEqual([field.varintList valueAtIndex:0],
|
||||
(uint64_t)Message3_Enum_Extra3);
|
||||
|
||||
[msg release];
|
||||
[orig release];
|
||||
}
|
||||
|
||||
- (void)testProto3UnknownEnumPreserving {
|
||||
UnknownEnumsMyMessagePlusExtra *orig = [UnknownEnumsMyMessagePlusExtra message];
|
||||
UnknownEnumsMyMessagePlusExtra *orig =
|
||||
[UnknownEnumsMyMessagePlusExtra message];
|
||||
|
||||
orig.e = UnknownEnumsMyEnumPlusExtra_EExtra;
|
||||
orig.repeatedEArray =
|
||||
[GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnumPlusExtra_IsValidValue
|
||||
rawValue:UnknownEnumsMyEnumPlusExtra_EExtra];
|
||||
orig.repeatedPackedEArray =
|
||||
[GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnumPlusExtra_IsValidValue
|
||||
rawValue:UnknownEnumsMyEnumPlusExtra_EExtra];
|
||||
orig.repeatedEArray = [GPBEnumArray
|
||||
arrayWithValidationFunction:UnknownEnumsMyEnumPlusExtra_IsValidValue
|
||||
rawValue:UnknownEnumsMyEnumPlusExtra_EExtra];
|
||||
orig.repeatedPackedEArray = [GPBEnumArray
|
||||
arrayWithValidationFunction:UnknownEnumsMyEnumPlusExtra_IsValidValue
|
||||
rawValue:UnknownEnumsMyEnumPlusExtra_EExtra];
|
||||
orig.oneofE1 = UnknownEnumsMyEnumPlusExtra_EExtra;
|
||||
|
||||
// Everything should be there via raw values.
|
||||
|
||||
NSData *data = [orig data];
|
||||
XCTAssertNotNil(data);
|
||||
UnknownEnumsMyMessage *msg = [UnknownEnumsMyMessage parseFromData:data error:NULL];
|
||||
UnknownEnumsMyMessage *msg =
|
||||
[UnknownEnumsMyMessage parseFromData:data error:NULL];
|
||||
|
||||
XCTAssertEqual(msg.e, UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual(UnknownEnumsMyMessage_E_RawValue(msg), UnknownEnumsMyEnumPlusExtra_EExtra);
|
||||
XCTAssertEqual(UnknownEnumsMyMessage_E_RawValue(msg),
|
||||
UnknownEnumsMyEnumPlusExtra_EExtra);
|
||||
XCTAssertEqual(msg.repeatedEArray.count, 1U);
|
||||
XCTAssertEqual([msg.repeatedEArray valueAtIndex:0],
|
||||
UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
@@ -495,8 +501,10 @@
|
||||
UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual([msg.repeatedPackedEArray rawValueAtIndex:0],
|
||||
(UnknownEnumsMyEnum)UnknownEnumsMyEnumPlusExtra_EExtra);
|
||||
XCTAssertEqual(msg.oneofE1, UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual(UnknownEnumsMyMessage_OneofE1_RawValue(msg), UnknownEnumsMyEnumPlusExtra_EExtra);
|
||||
XCTAssertEqual(msg.oneofE1,
|
||||
UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual(UnknownEnumsMyMessage_OneofE1_RawValue(msg),
|
||||
UnknownEnumsMyEnumPlusExtra_EExtra);
|
||||
|
||||
// Everything should go out and come back.
|
||||
|
||||
@@ -505,15 +513,14 @@
|
||||
|
||||
XCTAssertEqual(orig.e, UnknownEnumsMyEnumPlusExtra_EExtra);
|
||||
XCTAssertEqual(orig.repeatedEArray.count, 1U);
|
||||
XCTAssertEqual([orig.repeatedEArray valueAtIndex:0], UnknownEnumsMyEnumPlusExtra_EExtra);
|
||||
XCTAssertEqual([orig.repeatedEArray valueAtIndex:0],
|
||||
UnknownEnumsMyEnumPlusExtra_EExtra);
|
||||
XCTAssertEqual(orig.repeatedPackedEArray.count, 1U);
|
||||
XCTAssertEqual([orig.repeatedPackedEArray valueAtIndex:0], UnknownEnumsMyEnumPlusExtra_EExtra);
|
||||
XCTAssertEqual([orig.repeatedPackedEArray valueAtIndex:0],
|
||||
UnknownEnumsMyEnumPlusExtra_EExtra);
|
||||
XCTAssertEqual(orig.oneofE1, UnknownEnumsMyEnumPlusExtra_EExtra);
|
||||
}
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-DEFINE TEST_ROUNDTRIP_ONEOF(MESSAGE, FIELD, VALUE)
|
||||
//%TEST_ROUNDTRIP_ONEOF_ADV(MESSAGE, FIELD, VALUE, )
|
||||
//%PDDM-DEFINE TEST_ROUNDTRIP_ONEOF_ADV(MESSAGE, FIELD, VALUE, EQ_SUFFIX)
|
||||
@@ -577,6 +584,7 @@
|
||||
//%
|
||||
//%PDDM-EXPAND TEST_ROUNDTRIP_ONEOFS(2, NO)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
- (void)testProto2RoundTripOneof {
|
||||
|
||||
@@ -807,8 +815,10 @@
|
||||
[subMessage release];
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND TEST_ROUNDTRIP_ONEOFS(3, YES)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
- (void)testProto3RoundTripOneof {
|
||||
|
||||
@@ -1025,9 +1035,8 @@
|
||||
[subMessage release];
|
||||
}
|
||||
|
||||
//%PDDM-EXPAND-END (2 expansions)
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END (2 expansions)
|
||||
|
||||
- (void)testPackedUnpackedMessageParsing {
|
||||
// packed is optional, a repeated field should parse when packed or unpacked.
|
||||
@@ -1045,13 +1054,15 @@
|
||||
@"Data should differ (packed vs unpacked) use");
|
||||
|
||||
NSError *error = nil;
|
||||
TestPackedTypes *packedParse = [TestPackedTypes parseFromData:unpackedData error:&error];
|
||||
TestPackedTypes *packedParse =
|
||||
[TestPackedTypes parseFromData:unpackedData error:&error];
|
||||
XCTAssertNotNil(packedParse);
|
||||
XCTAssertNil(error);
|
||||
XCTAssertEqualObjects(packedParse, packedOrig);
|
||||
|
||||
error = nil;
|
||||
TestUnpackedTypes *unpackedParsed = [TestUnpackedTypes parseFromData:packedData error:&error];
|
||||
TestUnpackedTypes *unpackedParsed =
|
||||
[TestUnpackedTypes parseFromData:packedData error:&error];
|
||||
XCTAssertNotNil(unpackedParsed);
|
||||
XCTAssertNil(error);
|
||||
XCTAssertEqualObjects(unpackedParsed, unpackedOrig);
|
||||
@@ -1108,7 +1119,8 @@
|
||||
XCTAssertEqualObjects(fieldsData, extsData);
|
||||
|
||||
NSError *error = nil;
|
||||
TestPackedTypes *fieldsParse = [TestPackedTypes parseFromData:extsData error:&error];
|
||||
TestPackedTypes *fieldsParse =
|
||||
[TestPackedTypes parseFromData:extsData error:&error];
|
||||
XCTAssertNotNil(fieldsParse);
|
||||
XCTAssertNil(error);
|
||||
XCTAssertEqualObjects(fieldsParse, fieldsOrig);
|
||||
@@ -1138,7 +1150,8 @@
|
||||
XCTAssertNotNil(extsData);
|
||||
XCTAssertEqualObjects(fieldsData, extsData);
|
||||
|
||||
TestUnpackedTypes *fieldsParse = [TestUnpackedTypes parseFromData:extsData error:NULL];
|
||||
TestUnpackedTypes *fieldsParse =
|
||||
[TestUnpackedTypes parseFromData:extsData error:NULL];
|
||||
XCTAssertNotNil(fieldsParse);
|
||||
XCTAssertEqualObjects(fieldsParse, fieldsOrig);
|
||||
|
||||
@@ -1151,9 +1164,11 @@
|
||||
}
|
||||
|
||||
- (void)testErrorSubsectionInvalidLimit {
|
||||
NSData *data = DataFromCStr("\x0A\x08\x0A\x07\x12\x04\x72\x02\x4B\x50\x12\x04\x72\x02\x4B\x50");
|
||||
NSData *data = DataFromCStr(
|
||||
"\x0A\x08\x0A\x07\x12\x04\x72\x02\x4B\x50\x12\x04\x72\x02\x4B\x50");
|
||||
NSError *error = nil;
|
||||
NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data error:&error];
|
||||
NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
|
||||
error:&error];
|
||||
XCTAssertNil(msg);
|
||||
XCTAssertNotNil(error);
|
||||
XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
|
||||
@@ -1163,7 +1178,8 @@
|
||||
- (void)testErrorSubsectionLimitReached {
|
||||
NSData *data = DataFromCStr("\x0A\x06\x12\x03\x72\x02\x4B\x50");
|
||||
NSError *error = nil;
|
||||
NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data error:&error];
|
||||
NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
|
||||
error:&error];
|
||||
XCTAssertNil(msg);
|
||||
XCTAssertNotNil(error);
|
||||
XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
|
||||
@@ -1193,7 +1209,8 @@
|
||||
- (void)testErrorInvalidSize {
|
||||
NSData *data = DataFromCStr("\x72\x03\x4B\x50");
|
||||
NSError *error = nil;
|
||||
NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data error:&error];
|
||||
NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
|
||||
error:&error];
|
||||
XCTAssertNil(msg);
|
||||
XCTAssertNotNil(error);
|
||||
XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
|
||||
@@ -1203,7 +1220,8 @@
|
||||
- (void)testErrorInvalidTag {
|
||||
NSData *data = DataFromCStr("\x0F");
|
||||
NSError *error = nil;
|
||||
NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data error:&error];
|
||||
NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
|
||||
error:&error];
|
||||
XCTAssertNil(msg);
|
||||
XCTAssertNotNil(error);
|
||||
XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
|
||||
@@ -1213,7 +1231,12 @@
|
||||
- (void)testZeroFieldNum {
|
||||
// These are ConformanceTestSuite::TestIllegalTags.
|
||||
|
||||
const char *tests[] = {"\1DEADBEEF", "\2\1\1", "\3\4", "\5DEAD"};
|
||||
const char *tests[] = {
|
||||
"\1DEADBEEF",
|
||||
"\2\1\1",
|
||||
"\3\4",
|
||||
"\5DEAD"
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < GPBARRAYSIZE(tests); ++i) {
|
||||
NSData *data = DataFromCStr(tests[i]);
|
||||
@@ -1241,25 +1264,27 @@
|
||||
}
|
||||
|
||||
- (void)testErrorRecursionDepthReached {
|
||||
NSData *data = DataFromCStr("\x0A\xF2\x01\x0A\xEF\x01\x0A\xEC\x01\x0A\xE9\x01\x0A\xE6\x01"
|
||||
"\x0A\xE3\x01\x0A\xE0\x01\x0A\xDD\x01\x0A\xDA\x01\x0A\xD7\x01"
|
||||
"\x0A\xD4\x01\x0A\xD1\x01\x0A\xCE\x01\x0A\xCB\x01\x0A\xC8\x01"
|
||||
"\x0A\xC5\x01\x0A\xC2\x01\x0A\xBF\x01\x0A\xBC\x01\x0A\xB9\x01"
|
||||
"\x0A\xB6\x01\x0A\xB3\x01\x0A\xB0\x01\x0A\xAD\x01\x0A\xAA\x01"
|
||||
"\x0A\xA7\x01\x0A\xA4\x01\x0A\xA1\x01\x0A\x9E\x01\x0A\x9B\x01"
|
||||
"\x0A\x98\x01\x0A\x95\x01\x0A\x92\x01\x0A\x8F\x01\x0A\x8C\x01"
|
||||
"\x0A\x89\x01\x0A\x86\x01\x0A\x83\x01\x0A\x80\x01\x0A\x7E"
|
||||
"\x0A\x7C\x0A\x7A\x0A\x78\x0A\x76\x0A\x74\x0A\x72\x0A\x70"
|
||||
"\x0A\x6E\x0A\x6C\x0A\x6A\x0A\x68\x0A\x66\x0A\x64\x0A\x62"
|
||||
"\x0A\x60\x0A\x5E\x0A\x5C\x0A\x5A\x0A\x58\x0A\x56\x0A\x54"
|
||||
"\x0A\x52\x0A\x50\x0A\x4E\x0A\x4C\x0A\x4A\x0A\x48\x0A\x46"
|
||||
"\x0A\x44\x0A\x42\x0A\x40\x0A\x3E\x0A\x3C\x0A\x3A\x0A\x38"
|
||||
"\x0A\x36\x0A\x34\x0A\x32\x0A\x30\x0A\x2E\x0A\x2C\x0A\x2A"
|
||||
"\x0A\x28\x0A\x26\x0A\x24\x0A\x22\x0A\x20\x0A\x1E\x0A\x1C"
|
||||
"\x0A\x1A\x0A\x18\x0A\x16\x0A\x14\x0A\x12\x0A\x10\x0A\x0E"
|
||||
"\x0A\x0C\x0A\x0A\x0A\x08\x0A\x06\x12\x04\x72\x02\x4B\x50");
|
||||
NSData *data = DataFromCStr(
|
||||
"\x0A\xF2\x01\x0A\xEF\x01\x0A\xEC\x01\x0A\xE9\x01\x0A\xE6\x01"
|
||||
"\x0A\xE3\x01\x0A\xE0\x01\x0A\xDD\x01\x0A\xDA\x01\x0A\xD7\x01"
|
||||
"\x0A\xD4\x01\x0A\xD1\x01\x0A\xCE\x01\x0A\xCB\x01\x0A\xC8\x01"
|
||||
"\x0A\xC5\x01\x0A\xC2\x01\x0A\xBF\x01\x0A\xBC\x01\x0A\xB9\x01"
|
||||
"\x0A\xB6\x01\x0A\xB3\x01\x0A\xB0\x01\x0A\xAD\x01\x0A\xAA\x01"
|
||||
"\x0A\xA7\x01\x0A\xA4\x01\x0A\xA1\x01\x0A\x9E\x01\x0A\x9B\x01"
|
||||
"\x0A\x98\x01\x0A\x95\x01\x0A\x92\x01\x0A\x8F\x01\x0A\x8C\x01"
|
||||
"\x0A\x89\x01\x0A\x86\x01\x0A\x83\x01\x0A\x80\x01\x0A\x7E"
|
||||
"\x0A\x7C\x0A\x7A\x0A\x78\x0A\x76\x0A\x74\x0A\x72\x0A\x70"
|
||||
"\x0A\x6E\x0A\x6C\x0A\x6A\x0A\x68\x0A\x66\x0A\x64\x0A\x62"
|
||||
"\x0A\x60\x0A\x5E\x0A\x5C\x0A\x5A\x0A\x58\x0A\x56\x0A\x54"
|
||||
"\x0A\x52\x0A\x50\x0A\x4E\x0A\x4C\x0A\x4A\x0A\x48\x0A\x46"
|
||||
"\x0A\x44\x0A\x42\x0A\x40\x0A\x3E\x0A\x3C\x0A\x3A\x0A\x38"
|
||||
"\x0A\x36\x0A\x34\x0A\x32\x0A\x30\x0A\x2E\x0A\x2C\x0A\x2A"
|
||||
"\x0A\x28\x0A\x26\x0A\x24\x0A\x22\x0A\x20\x0A\x1E\x0A\x1C"
|
||||
"\x0A\x1A\x0A\x18\x0A\x16\x0A\x14\x0A\x12\x0A\x10\x0A\x0E"
|
||||
"\x0A\x0C\x0A\x0A\x0A\x08\x0A\x06\x12\x04\x72\x02\x4B\x50");
|
||||
NSError *error = nil;
|
||||
NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data error:&error];
|
||||
NestedTestAllTypes *msg = [NestedTestAllTypes parseFromData:data
|
||||
error:&error];
|
||||
XCTAssertNil(msg);
|
||||
XCTAssertNotNil(error);
|
||||
XCTAssertEqualObjects(error.domain, GPBCodedInputStreamErrorDomain);
|
||||
@@ -1270,7 +1295,9 @@
|
||||
NSData *data = DataFromCStr("\xFF\xFF\xFF\xFF\x0F");
|
||||
GPBCodedInputStream *input = [GPBCodedInputStream streamWithData:data];
|
||||
NSError *error;
|
||||
[GPBMessage parseDelimitedFromCodedInputStream:input extensionRegistry:nil error:&error];
|
||||
[GPBMessage parseDelimitedFromCodedInputStream:input
|
||||
extensionRegistry:nil
|
||||
error:&error];
|
||||
XCTAssertNil(error);
|
||||
}
|
||||
|
||||
@@ -1406,8 +1433,10 @@
|
||||
initWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue] autorelease];
|
||||
orig.unknownMapField = [[[GPBInt32EnumDictionary alloc]
|
||||
initWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue] autorelease];
|
||||
[orig.knownMapField setEnum:Proto2MapEnumPlusExtra_EProto2MapEnumFoo forKey:0];
|
||||
[orig.unknownMapField setEnum:Proto2MapEnumPlusExtra_EProto2MapEnumExtra forKey:0];
|
||||
[orig.knownMapField setEnum:Proto2MapEnumPlusExtra_EProto2MapEnumFoo
|
||||
forKey:0];
|
||||
[orig.unknownMapField setEnum:Proto2MapEnumPlusExtra_EProto2MapEnumExtra
|
||||
forKey:0];
|
||||
|
||||
NSData *data = [orig data];
|
||||
XCTAssertNotNil(data);
|
||||
@@ -1419,7 +1448,8 @@
|
||||
XCTAssertEqual(msg1.unknownFields.countOfFields, 1U);
|
||||
|
||||
data = [msg1 data];
|
||||
TestEnumMapPlusExtra *msg2 = [TestEnumMapPlusExtra parseFromData:data error:NULL];
|
||||
TestEnumMapPlusExtra *msg2 =
|
||||
[TestEnumMapPlusExtra parseFromData:data error:NULL];
|
||||
val = -1;
|
||||
XCTAssertEqual(msg2.knownMapField.count, 1U);
|
||||
XCTAssertTrue([msg2.knownMapField getEnum:&val forKey:0]);
|
||||
|
||||
@@ -36,12 +36,12 @@
|
||||
#import "GPBDescriptor.h"
|
||||
#import "GPBDictionary_PackagePrivate.h"
|
||||
#import "GPBMessage_PackagePrivate.h"
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
#import "GPBUnknownField_PackagePrivate.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestImport.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjc.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestObjcOptions.pbobjc.h"
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/UnittestObjc.pbobjc.h"
|
||||
#import "google/protobuf/UnittestObjcOptions.pbobjc.h"
|
||||
#import "google/protobuf/UnittestImport.pbobjc.h"
|
||||
|
||||
// Helper class to test KVO.
|
||||
@interface GPBKVOTestObserver : NSObject {
|
||||
@@ -49,7 +49,7 @@
|
||||
NSString *keyPath_;
|
||||
}
|
||||
|
||||
@property(nonatomic) BOOL didObserve;
|
||||
@property (nonatomic) BOOL didObserve;
|
||||
- (id)initWithObservee:(id)observee keyPath:(NSString *)keyPath;
|
||||
@end
|
||||
|
||||
@@ -74,9 +74,13 @@
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath
|
||||
ofObject:(__unused id)object
|
||||
change:(__unused NSDictionary *)change
|
||||
context:(__unused void *)context {
|
||||
ofObject:(id)object
|
||||
change:(NSDictionary *)change
|
||||
context:(void *)context
|
||||
{
|
||||
#pragma unused(object)
|
||||
#pragma unused(change)
|
||||
#pragma unused(context)
|
||||
if ([keyPath isEqualToString:keyPath_]) {
|
||||
self.didObserve = YES;
|
||||
}
|
||||
@@ -152,9 +156,12 @@
|
||||
[message setExtension:[UnittestRoot optionalStringExtension] value:@"foo"];
|
||||
ForeignMessage *foreignMessage = [ForeignMessage message];
|
||||
foreignMessage.c = 4;
|
||||
[message setExtension:[UnittestRoot optionalForeignMessageExtension] value:foreignMessage];
|
||||
TestAllTypes_NestedMessage *nestedMessage = [TestAllTypes_NestedMessage message];
|
||||
[message setExtension:[UnittestRoot optionalNestedMessageExtension] value:nestedMessage];
|
||||
[message setExtension:[UnittestRoot optionalForeignMessageExtension]
|
||||
value:foreignMessage];
|
||||
TestAllTypes_NestedMessage *nestedMessage =
|
||||
[TestAllTypes_NestedMessage message];
|
||||
[message setExtension:[UnittestRoot optionalNestedMessageExtension]
|
||||
value:nestedMessage];
|
||||
return message;
|
||||
}
|
||||
|
||||
@@ -163,10 +170,13 @@
|
||||
[message setExtension:[UnittestRoot optionalInt64Extension] value:@6];
|
||||
[message setExtension:[UnittestRoot optionalStringExtension] value:@"bar"];
|
||||
ForeignMessage *foreignMessage = [ForeignMessage message];
|
||||
[message setExtension:[UnittestRoot optionalForeignMessageExtension] value:foreignMessage];
|
||||
TestAllTypes_NestedMessage *nestedMessage = [TestAllTypes_NestedMessage message];
|
||||
[message setExtension:[UnittestRoot optionalForeignMessageExtension]
|
||||
value:foreignMessage];
|
||||
TestAllTypes_NestedMessage *nestedMessage =
|
||||
[TestAllTypes_NestedMessage message];
|
||||
nestedMessage.bb = 7;
|
||||
[message setExtension:[UnittestRoot optionalNestedMessageExtension] value:nestedMessage];
|
||||
[message setExtension:[UnittestRoot optionalNestedMessageExtension]
|
||||
value:nestedMessage];
|
||||
return message;
|
||||
}
|
||||
|
||||
@@ -177,10 +187,13 @@
|
||||
[message setExtension:[UnittestRoot optionalStringExtension] value:@"bar"];
|
||||
ForeignMessage *foreignMessage = [ForeignMessage message];
|
||||
foreignMessage.c = 4;
|
||||
[message setExtension:[UnittestRoot optionalForeignMessageExtension] value:foreignMessage];
|
||||
TestAllTypes_NestedMessage *nestedMessage = [TestAllTypes_NestedMessage message];
|
||||
[message setExtension:[UnittestRoot optionalForeignMessageExtension]
|
||||
value:foreignMessage];
|
||||
TestAllTypes_NestedMessage *nestedMessage =
|
||||
[TestAllTypes_NestedMessage message];
|
||||
nestedMessage.bb = 7;
|
||||
[message setExtension:[UnittestRoot optionalNestedMessageExtension] value:nestedMessage];
|
||||
[message setExtension:[UnittestRoot optionalNestedMessageExtension]
|
||||
value:nestedMessage];
|
||||
return message;
|
||||
}
|
||||
|
||||
@@ -198,9 +211,11 @@
|
||||
result = [[self.mergeDestinationWithoutForeignMessageIvar copy] autorelease];
|
||||
[result mergeFrom:self.mergeSource];
|
||||
resultData = [result data];
|
||||
mergeResultData = [self.mergeResultForDestinationWithoutForeignMessageIvar data];
|
||||
mergeResultData =
|
||||
[self.mergeResultForDestinationWithoutForeignMessageIvar data];
|
||||
XCTAssertEqualObjects(resultData, mergeResultData);
|
||||
XCTAssertEqualObjects(result, self.mergeResultForDestinationWithoutForeignMessageIvar);
|
||||
XCTAssertEqualObjects(
|
||||
result, self.mergeResultForDestinationWithoutForeignMessageIvar);
|
||||
|
||||
// Test when destination is empty.
|
||||
// The result must is same as the source.
|
||||
@@ -224,7 +239,8 @@
|
||||
result = [self mergeExtensionsDestination];
|
||||
NSData *data = [[self mergeExtensionsSource] data];
|
||||
XCTAssertNotNil(data);
|
||||
[result mergeFromData:data extensionRegistry:[UnittestRoot extensionRegistry]];
|
||||
[result mergeFromData:data
|
||||
extensionRegistry:[UnittestRoot extensionRegistry]];
|
||||
resultData = [result data];
|
||||
XCTAssertEqualObjects(resultData, mergeResultData);
|
||||
XCTAssertEqualObjects(result, [self mergeExtensionsResult]);
|
||||
@@ -290,13 +306,16 @@
|
||||
[message setExtension:[TestRequired single] value:[TestRequired message]];
|
||||
XCTAssertFalse(message.initialized);
|
||||
|
||||
[message setExtension:[TestRequired single] value:self.testRequiredInitialized];
|
||||
[message setExtension:[TestRequired single]
|
||||
value:self.testRequiredInitialized];
|
||||
XCTAssertTrue(message.initialized);
|
||||
|
||||
[message addExtension:[TestRequired multi] value:[TestRequired message]];
|
||||
XCTAssertFalse(message.initialized);
|
||||
|
||||
[message setExtension:[TestRequired multi] index:0 value:self.testRequiredInitialized];
|
||||
[message setExtension:[TestRequired multi]
|
||||
index:0
|
||||
value:self.testRequiredInitialized];
|
||||
XCTAssertTrue(message.initialized);
|
||||
}
|
||||
|
||||
@@ -348,7 +367,8 @@
|
||||
|
||||
- (void)testParseUninitialized {
|
||||
NSError *error = nil;
|
||||
TestRequired *msg = [TestRequired parseFromData:GPBEmptyNSData() error:&error];
|
||||
TestRequired *msg =
|
||||
[TestRequired parseFromData:GPBEmptyNSData() error:&error];
|
||||
// In DEBUG, the parse will fail, but in non DEBUG, it passes because
|
||||
// the check isn't done (for speed).
|
||||
#ifdef DEBUG
|
||||
@@ -368,7 +388,8 @@
|
||||
|
||||
- (void)testCoding {
|
||||
GPBMessage *original = [self mergeResult];
|
||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:original];
|
||||
NSData *data =
|
||||
[NSKeyedArchiver archivedDataWithRootObject:original];
|
||||
id unarchivedObject = [NSKeyedUnarchiver unarchiveObjectWithData:data];
|
||||
|
||||
XCTAssertEqualObjects(unarchivedObject, original);
|
||||
@@ -390,7 +411,8 @@
|
||||
|
||||
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
|
||||
[unarchiver setRequiresSecureCoding:YES];
|
||||
id unarchivedObject = [unarchiver decodeObjectOfClass:[GPBMessage class] forKey:key];
|
||||
id unarchivedObject = [unarchiver decodeObjectOfClass:[GPBMessage class]
|
||||
forKey:key];
|
||||
[unarchiver finishDecoding];
|
||||
|
||||
XCTAssertEqualObjects(unarchivedObject, original);
|
||||
@@ -463,7 +485,9 @@
|
||||
- (void)testKVOBasic {
|
||||
TestAllTypes *message = [TestAllTypes message];
|
||||
GPBKVOTestObserver *observer =
|
||||
[[[GPBKVOTestObserver alloc] initWithObservee:message keyPath:@"optionalString"] autorelease];
|
||||
[[[GPBKVOTestObserver alloc] initWithObservee:message
|
||||
keyPath:@"optionalString"]
|
||||
autorelease];
|
||||
XCTAssertFalse(observer.didObserve);
|
||||
message.defaultString = @"Hello";
|
||||
XCTAssertFalse(observer.didObserve);
|
||||
@@ -475,10 +499,12 @@
|
||||
TestAllTypes *message = [TestAllTypes message];
|
||||
GPBKVOTestObserver *autocreateObserver =
|
||||
[[[GPBKVOTestObserver alloc] initWithObservee:message
|
||||
keyPath:@"optionalImportMessage"] autorelease];
|
||||
GPBKVOTestObserver *innerFieldObserver =
|
||||
[[[GPBKVOTestObserver alloc] initWithObservee:message
|
||||
keyPath:@"optionalImportMessage.d"] autorelease];
|
||||
keyPath:@"optionalImportMessage"]
|
||||
autorelease];
|
||||
GPBKVOTestObserver *innerFieldObserver =
|
||||
[[[GPBKVOTestObserver alloc] initWithObservee:message
|
||||
keyPath:@"optionalImportMessage.d"]
|
||||
autorelease];
|
||||
XCTAssertFalse(autocreateObserver.didObserve);
|
||||
XCTAssertFalse(innerFieldObserver.didObserve);
|
||||
|
||||
@@ -510,8 +536,10 @@
|
||||
TestAllTypes *message = [TestAllTypes message];
|
||||
[self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
|
||||
|
||||
GPBUnknownFieldSet *unknownFields = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField *field = [[[GPBUnknownField alloc] initWithNumber:2] autorelease];
|
||||
GPBUnknownFieldSet *unknownFields =
|
||||
[[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField *field =
|
||||
[[[GPBUnknownField alloc] initWithNumber:2] autorelease];
|
||||
[field addVarint:2];
|
||||
[unknownFields addField:field];
|
||||
field = [[[GPBUnknownField alloc] initWithNumber:3] autorelease];
|
||||
@@ -539,7 +567,8 @@
|
||||
TestAllTypes *message = [TestAllTypes message];
|
||||
GPBDescriptor *descriptor = [[message class] descriptor];
|
||||
XCTAssertNotNil(descriptor);
|
||||
GPBFieldDescriptor *fieldDescriptor = [descriptor fieldWithName:@"defaultInt32"];
|
||||
GPBFieldDescriptor *fieldDescriptor =
|
||||
[descriptor fieldWithName:@"defaultInt32"];
|
||||
XCTAssertNotNil(fieldDescriptor);
|
||||
GPBGenericValue defaultValue = [fieldDescriptor defaultValue];
|
||||
[message setDefaultInt32:defaultValue.valueInt32];
|
||||
@@ -650,7 +679,8 @@
|
||||
TestAllTypes *message = [TestAllTypes message];
|
||||
[self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
|
||||
[self modifyRepeatedFields:message];
|
||||
[self assertRepeatedFieldsModified:message repeatedCount:kGPBDefaultRepeatCount];
|
||||
[self assertRepeatedFieldsModified:message
|
||||
repeatedCount:kGPBDefaultRepeatCount];
|
||||
}
|
||||
|
||||
- (void)testClear {
|
||||
@@ -682,16 +712,19 @@
|
||||
GPBMessage *message2 = [TestAllExtensions message];
|
||||
[message2 addExtension:[UnittestRoot repeatedInt32Extension] value:@1];
|
||||
|
||||
XCTAssertEqual([[message2 getExtension:[UnittestRoot repeatedInt32Extension]] count],
|
||||
(NSUInteger)1);
|
||||
XCTAssertEqual(
|
||||
[[message2 getExtension:[UnittestRoot repeatedInt32Extension]] count],
|
||||
(NSUInteger)1);
|
||||
[message2 clearExtension:[UnittestRoot repeatedInt32Extension]];
|
||||
XCTAssertEqual([[message2 getExtension:[UnittestRoot repeatedInt32Extension]] count],
|
||||
(NSUInteger)0);
|
||||
XCTAssertEqual(
|
||||
[[message2 getExtension:[UnittestRoot repeatedInt32Extension]] count],
|
||||
(NSUInteger)0);
|
||||
|
||||
// Clearing an unset extension field shouldn't make the target message
|
||||
// visible.
|
||||
GPBMessage *message3 = [TestAllExtensions message];
|
||||
GPBMessage *extension_msg = [message3 getExtension:[UnittestObjcRoot recursiveExtension]];
|
||||
GPBMessage *extension_msg =
|
||||
[message3 getExtension:[UnittestObjcRoot recursiveExtension]];
|
||||
XCTAssertFalse([message3 hasExtension:[UnittestObjcRoot recursiveExtension]]);
|
||||
[extension_msg clearExtension:[UnittestRoot optionalInt32Extension]];
|
||||
XCTAssertFalse([message3 hasExtension:[UnittestObjcRoot recursiveExtension]]);
|
||||
@@ -712,11 +745,15 @@
|
||||
// They should auto create something when fetched.
|
||||
|
||||
TestAllTypes_OptionalGroup *optionalGroup = [message.optionalGroup retain];
|
||||
TestAllTypes_NestedMessage *optionalNestedMessage = [message.optionalNestedMessage retain];
|
||||
ForeignMessage *optionalForeignMessage = [message.optionalForeignMessage retain];
|
||||
TestAllTypes_NestedMessage *optionalNestedMessage =
|
||||
[message.optionalNestedMessage retain];
|
||||
ForeignMessage *optionalForeignMessage =
|
||||
[message.optionalForeignMessage retain];
|
||||
ImportMessage *optionalImportMessage = [message.optionalImportMessage retain];
|
||||
PublicImportMessage *optionalPublicImportMessage = [message.optionalPublicImportMessage retain];
|
||||
TestAllTypes_NestedMessage *optionalLazyMessage = [message.optionalLazyMessage retain];
|
||||
PublicImportMessage *optionalPublicImportMessage =
|
||||
[message.optionalPublicImportMessage retain];
|
||||
TestAllTypes_NestedMessage *optionalLazyMessage =
|
||||
[message.optionalLazyMessage retain];
|
||||
|
||||
XCTAssertNotNil(optionalGroup);
|
||||
XCTAssertNotNil(optionalNestedMessage);
|
||||
@@ -742,7 +779,8 @@
|
||||
XCTAssertEqual(message.optionalNestedMessage, optionalNestedMessage);
|
||||
XCTAssertEqual(message.optionalForeignMessage, optionalForeignMessage);
|
||||
XCTAssertEqual(message.optionalImportMessage, optionalImportMessage);
|
||||
XCTAssertEqual(message.optionalPublicImportMessage, optionalPublicImportMessage);
|
||||
XCTAssertEqual(message.optionalPublicImportMessage,
|
||||
optionalPublicImportMessage);
|
||||
XCTAssertEqual(message.optionalLazyMessage, optionalLazyMessage);
|
||||
|
||||
// And the default objects for a second message should be distinct (again,
|
||||
@@ -755,7 +793,8 @@
|
||||
XCTAssertNotEqual(message2.optionalNestedMessage, optionalNestedMessage);
|
||||
XCTAssertNotEqual(message2.optionalForeignMessage, optionalForeignMessage);
|
||||
XCTAssertNotEqual(message2.optionalImportMessage, optionalImportMessage);
|
||||
XCTAssertNotEqual(message2.optionalPublicImportMessage, optionalPublicImportMessage);
|
||||
XCTAssertNotEqual(message2.optionalPublicImportMessage,
|
||||
optionalPublicImportMessage);
|
||||
XCTAssertNotEqual(message2.optionalLazyMessage, optionalLazyMessage);
|
||||
|
||||
// Setting the values to nil will clear the has flag, and on next access you
|
||||
@@ -780,7 +819,8 @@
|
||||
XCTAssertNotEqual(message.optionalNestedMessage, optionalNestedMessage);
|
||||
XCTAssertNotEqual(message.optionalForeignMessage, optionalForeignMessage);
|
||||
XCTAssertNotEqual(message.optionalImportMessage, optionalImportMessage);
|
||||
XCTAssertNotEqual(message.optionalPublicImportMessage, optionalPublicImportMessage);
|
||||
XCTAssertNotEqual(message.optionalPublicImportMessage,
|
||||
optionalPublicImportMessage);
|
||||
XCTAssertNotEqual(message.optionalLazyMessage, optionalLazyMessage);
|
||||
|
||||
[optionalGroup release];
|
||||
@@ -813,7 +853,8 @@
|
||||
XCTAssertFalse([message2 hasOptionalNestedMessage]);
|
||||
|
||||
// Intentionally doing a pointer comparison.
|
||||
XCTAssertNotEqual(message.optionalNestedMessage, message2.optionalNestedMessage);
|
||||
XCTAssertNotEqual(message.optionalNestedMessage,
|
||||
message2.optionalNestedMessage);
|
||||
}
|
||||
|
||||
- (void)testClearAutocreatedSubmessage {
|
||||
@@ -839,9 +880,10 @@
|
||||
ForeignMessage *subMessage;
|
||||
@autoreleasepool {
|
||||
TestAllTypes *message2 = [TestAllTypes message];
|
||||
subMessage = message2.optionalForeignMessage; // Autocreated
|
||||
subMessage = message2.optionalForeignMessage; // Autocreated
|
||||
message.optionalForeignMessage = subMessage;
|
||||
XCTAssertTrue(GPBWasMessageAutocreatedBy(message.optionalForeignMessage, message2));
|
||||
XCTAssertTrue(GPBWasMessageAutocreatedBy(message.optionalForeignMessage,
|
||||
message2));
|
||||
}
|
||||
|
||||
// Should be the same object, and should still be live.
|
||||
@@ -977,7 +1019,8 @@
|
||||
// Setting autocreated submessage to another value should cause the old one to
|
||||
// lose its creator.
|
||||
TestAllTypes *message = [TestAllTypes message];
|
||||
TestAllTypes_NestedMessage *nestedMessage = [message.optionalNestedMessage retain];
|
||||
TestAllTypes_NestedMessage *nestedMessage =
|
||||
[message.optionalNestedMessage retain];
|
||||
|
||||
message.optionalNestedMessage = [TestAllTypes_NestedMessage message];
|
||||
XCTAssertTrue([message hasOptionalNestedMessage]);
|
||||
@@ -996,7 +1039,8 @@
|
||||
XCTAssertNil(message.optionalNestedMessage.unknownFields);
|
||||
XCTAssertFalse([message hasOptionalNestedMessage]);
|
||||
|
||||
GPBUnknownFieldSet *unknownFields = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownFieldSet *unknownFields =
|
||||
[[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
message.optionalNestedMessage.unknownFields = unknownFields;
|
||||
XCTAssertTrue([message hasOptionalNestedMessage]);
|
||||
|
||||
@@ -1045,8 +1089,10 @@
|
||||
|
||||
- (void)testDefaultingArrays {
|
||||
// Basic tests for default creation of arrays in a message.
|
||||
TestRecursiveMessageWithRepeatedField *message = [TestRecursiveMessageWithRepeatedField message];
|
||||
TestRecursiveMessageWithRepeatedField *message2 = [TestRecursiveMessageWithRepeatedField message];
|
||||
TestRecursiveMessageWithRepeatedField *message =
|
||||
[TestRecursiveMessageWithRepeatedField message];
|
||||
TestRecursiveMessageWithRepeatedField *message2 =
|
||||
[TestRecursiveMessageWithRepeatedField message];
|
||||
|
||||
// Simply accessing the array should not make any fields visible.
|
||||
XCTAssertNotNil(message.a.a.iArray);
|
||||
@@ -1113,9 +1159,11 @@
|
||||
XCTAssertNotNil(message.repeatedStringArray);
|
||||
TestAllTypes *message4 = [[message3 copy] autorelease];
|
||||
XCTAssertNotEqual(message3.repeatedInt32Array, message4.repeatedInt32Array);
|
||||
XCTAssertEqualObjects(message3.repeatedInt32Array, message4.repeatedInt32Array);
|
||||
XCTAssertEqualObjects(message3.repeatedInt32Array,
|
||||
message4.repeatedInt32Array);
|
||||
XCTAssertNotEqual(message3.repeatedStringArray, message4.repeatedStringArray);
|
||||
XCTAssertEqualObjects(message3.repeatedStringArray, message4.repeatedStringArray);
|
||||
XCTAssertEqualObjects(message3.repeatedStringArray,
|
||||
message4.repeatedStringArray);
|
||||
}
|
||||
|
||||
- (void)testAutocreatedArrayRetain {
|
||||
@@ -1128,13 +1176,18 @@
|
||||
message.repeatedStringArray = message2.repeatedStringArray;
|
||||
// Pointer conparision
|
||||
XCTAssertEqual(message.repeatedInt32Array->_autocreator, message2);
|
||||
XCTAssertTrue([message.repeatedStringArray isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(((GPBAutocreatedArray *)message.repeatedStringArray)->_autocreator, message2);
|
||||
XCTAssertTrue([message.repeatedStringArray
|
||||
isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(
|
||||
((GPBAutocreatedArray *)message.repeatedStringArray)->_autocreator,
|
||||
message2);
|
||||
}
|
||||
|
||||
XCTAssertNil(message.repeatedInt32Array->_autocreator);
|
||||
XCTAssertTrue([message.repeatedStringArray isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertNil(((GPBAutocreatedArray *)message.repeatedStringArray)->_autocreator);
|
||||
XCTAssertTrue(
|
||||
[message.repeatedStringArray isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertNil(
|
||||
((GPBAutocreatedArray *)message.repeatedStringArray)->_autocreator);
|
||||
}
|
||||
|
||||
- (void)testSetNilAutocreatedArray {
|
||||
@@ -1192,7 +1245,8 @@
|
||||
XCTAssertNotNil(message.a);
|
||||
XCTAssertNotNil(message.a.strArray);
|
||||
XCTAssertFalse([message hasA]);
|
||||
GPBAutocreatedArray *strArray = (GPBAutocreatedArray *)[message.a.strArray retain];
|
||||
GPBAutocreatedArray *strArray =
|
||||
(GPBAutocreatedArray *)[message.a.strArray retain];
|
||||
XCTAssertTrue([strArray isKindOfClass:[GPBAutocreatedArray class]]);
|
||||
XCTAssertEqual(strArray->_autocreator, message.a); // Pointer comparison
|
||||
message.a.strArray = [NSMutableArray arrayWithObject:@"foo"];
|
||||
@@ -1232,7 +1286,8 @@
|
||||
- (void)testAutocreatedArrayRemoveAllValues {
|
||||
// Calling removeAllValues on autocreated array should not cause it to be
|
||||
// visible.
|
||||
TestRecursiveMessageWithRepeatedField *message = [TestRecursiveMessageWithRepeatedField message];
|
||||
TestRecursiveMessageWithRepeatedField *message =
|
||||
[TestRecursiveMessageWithRepeatedField message];
|
||||
[message.a.iArray removeAll];
|
||||
XCTAssertFalse([message hasA]);
|
||||
[message.a.strArray removeAllObjects];
|
||||
@@ -1241,8 +1296,10 @@
|
||||
|
||||
- (void)testDefaultingMaps {
|
||||
// Basic tests for default creation of maps in a message.
|
||||
TestRecursiveMessageWithRepeatedField *message = [TestRecursiveMessageWithRepeatedField message];
|
||||
TestRecursiveMessageWithRepeatedField *message2 = [TestRecursiveMessageWithRepeatedField message];
|
||||
TestRecursiveMessageWithRepeatedField *message =
|
||||
[TestRecursiveMessageWithRepeatedField message];
|
||||
TestRecursiveMessageWithRepeatedField *message2 =
|
||||
[TestRecursiveMessageWithRepeatedField message];
|
||||
|
||||
// Simply accessing the map should not make any fields visible.
|
||||
XCTAssertNotNil(message.a.a.iToI);
|
||||
@@ -1292,23 +1349,28 @@
|
||||
|
||||
- (void)testAutocreatedMapCopy {
|
||||
// Copy should not copy autocreated maps.
|
||||
TestRecursiveMessageWithRepeatedField *message = [TestRecursiveMessageWithRepeatedField message];
|
||||
TestRecursiveMessageWithRepeatedField *message =
|
||||
[TestRecursiveMessageWithRepeatedField message];
|
||||
XCTAssertNotNil(message.strToStr);
|
||||
XCTAssertNotNil(message.iToI);
|
||||
TestRecursiveMessageWithRepeatedField *message2 = [[message copy] autorelease];
|
||||
TestRecursiveMessageWithRepeatedField *message2 =
|
||||
[[message copy] autorelease];
|
||||
// Pointer conparisions.
|
||||
XCTAssertNotEqual(message.strToStr, message2.strToStr);
|
||||
XCTAssertNotEqual(message.iToI, message2.iToI);
|
||||
|
||||
// Mutable copy should copy empty arrays that were explicitly set (end up
|
||||
// with different objects that are equal).
|
||||
TestRecursiveMessageWithRepeatedField *message3 = [TestRecursiveMessageWithRepeatedField message];
|
||||
TestRecursiveMessageWithRepeatedField *message3 =
|
||||
[TestRecursiveMessageWithRepeatedField message];
|
||||
message3.iToI = [[[GPBInt32Int32Dictionary alloc] init] autorelease];
|
||||
[message3.iToI setInt32:10 forKey:20];
|
||||
message3.strToStr = [NSMutableDictionary dictionaryWithObject:@"abc" forKey:@"123"];
|
||||
message3.strToStr =
|
||||
[NSMutableDictionary dictionaryWithObject:@"abc" forKey:@"123"];
|
||||
XCTAssertNotNil(message.iToI);
|
||||
XCTAssertNotNil(message.iToI);
|
||||
TestRecursiveMessageWithRepeatedField *message4 = [[message3 copy] autorelease];
|
||||
TestRecursiveMessageWithRepeatedField *message4 =
|
||||
[[message3 copy] autorelease];
|
||||
XCTAssertNotEqual(message3.iToI, message4.iToI);
|
||||
XCTAssertEqualObjects(message3.iToI, message4.iToI);
|
||||
XCTAssertNotEqual(message3.strToStr, message4.strToStr);
|
||||
@@ -1317,7 +1379,8 @@
|
||||
|
||||
- (void)testAutocreatedMapRetain {
|
||||
// Should be able to retain autocreated map while the creator is dealloced.
|
||||
TestRecursiveMessageWithRepeatedField *message = [TestRecursiveMessageWithRepeatedField message];
|
||||
TestRecursiveMessageWithRepeatedField *message =
|
||||
[TestRecursiveMessageWithRepeatedField message];
|
||||
|
||||
@autoreleasepool {
|
||||
TestRecursiveMessageWithRepeatedField *message2 =
|
||||
@@ -1326,20 +1389,27 @@
|
||||
message.strToStr = message2.strToStr;
|
||||
// Pointer conparision
|
||||
XCTAssertEqual(message.iToI->_autocreator, message2);
|
||||
XCTAssertTrue([message.strToStr isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(((GPBAutocreatedDictionary *)message.strToStr)->_autocreator, message2);
|
||||
XCTAssertTrue([message.strToStr
|
||||
isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(
|
||||
((GPBAutocreatedDictionary *)message.strToStr)->_autocreator,
|
||||
message2);
|
||||
}
|
||||
|
||||
XCTAssertNil(message.iToI->_autocreator);
|
||||
XCTAssertTrue([message.strToStr isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertNil(((GPBAutocreatedDictionary *)message.strToStr)->_autocreator);
|
||||
XCTAssertTrue(
|
||||
[message.strToStr isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertNil(
|
||||
((GPBAutocreatedDictionary *)message.strToStr)->_autocreator);
|
||||
}
|
||||
|
||||
- (void)testSetNilAutocreatedMap {
|
||||
// Setting map to nil should cause it to lose its delegate.
|
||||
TestRecursiveMessageWithRepeatedField *message = [TestRecursiveMessageWithRepeatedField message];
|
||||
TestRecursiveMessageWithRepeatedField *message =
|
||||
[TestRecursiveMessageWithRepeatedField message];
|
||||
GPBInt32Int32Dictionary *iToI = [message.iToI retain];
|
||||
GPBAutocreatedDictionary *strToStr = (GPBAutocreatedDictionary *)[message.strToStr retain];
|
||||
GPBAutocreatedDictionary *strToStr =
|
||||
(GPBAutocreatedDictionary *)[message.strToStr retain];
|
||||
XCTAssertTrue([strToStr isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(iToI->_autocreator, message);
|
||||
XCTAssertEqual(strToStr->_autocreator, message);
|
||||
@@ -1356,13 +1426,15 @@
|
||||
// an autocreated one or a straight NSDictionary.
|
||||
|
||||
// The real test here is that nothing crashes while doing the work.
|
||||
TestRecursiveMessageWithRepeatedField *message = [TestRecursiveMessageWithRepeatedField message];
|
||||
TestRecursiveMessageWithRepeatedField *message =
|
||||
[TestRecursiveMessageWithRepeatedField message];
|
||||
message.strToStr[@"foo"] = @"bar";
|
||||
XCTAssertEqual(message.strToStr_Count, (NSUInteger)1);
|
||||
message.strToStr =
|
||||
[NSMutableDictionary dictionaryWithObjectsAndKeys:@"bar", @"key1", @"baz", @"key2", nil];
|
||||
XCTAssertEqual(message.strToStr_Count, (NSUInteger)2);
|
||||
message.strToStr = [NSMutableDictionary dictionaryWithObject:@"baz" forKey:@"mumble"];
|
||||
message.strToStr =
|
||||
[NSMutableDictionary dictionaryWithObject:@"baz" forKey:@"mumble"];
|
||||
XCTAssertEqual(message.strToStr_Count, (NSUInteger)1);
|
||||
}
|
||||
|
||||
@@ -1391,10 +1463,12 @@
|
||||
XCTAssertNotNil(message.a);
|
||||
XCTAssertNotNil(message.a.strToStr);
|
||||
XCTAssertFalse([message hasA]);
|
||||
GPBAutocreatedDictionary *strToStr = (GPBAutocreatedDictionary *)[message.a.strToStr retain];
|
||||
GPBAutocreatedDictionary *strToStr =
|
||||
(GPBAutocreatedDictionary *)[message.a.strToStr retain];
|
||||
XCTAssertTrue([strToStr isKindOfClass:[GPBAutocreatedDictionary class]]);
|
||||
XCTAssertEqual(strToStr->_autocreator, message.a); // Pointer comparison
|
||||
message.a.strToStr = [NSMutableDictionary dictionaryWithObject:@"abc" forKey:@"def"];
|
||||
message.a.strToStr =
|
||||
[NSMutableDictionary dictionaryWithObject:@"abc" forKey:@"def"];
|
||||
XCTAssertTrue([message hasA]);
|
||||
XCTAssertNotEqual(message.a.strToStr, strToStr); // Pointer comparison
|
||||
XCTAssertNil(strToStr->_autocreator);
|
||||
@@ -1430,7 +1504,8 @@
|
||||
|
||||
- (void)testAutocreatedMapRemoveAllValues {
|
||||
// Calling removeAll on autocreated map should not cause it to be visible.
|
||||
TestRecursiveMessageWithRepeatedField *message = [TestRecursiveMessageWithRepeatedField message];
|
||||
TestRecursiveMessageWithRepeatedField *message =
|
||||
[TestRecursiveMessageWithRepeatedField message];
|
||||
[message.a.iToI removeAll];
|
||||
XCTAssertFalse([message hasA]);
|
||||
[message.a.strToStr removeAllObjects];
|
||||
@@ -1447,7 +1522,8 @@
|
||||
TestAllExtensions *message = [TestAllExtensions message];
|
||||
[self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
|
||||
[self modifyRepeatedExtensions:message];
|
||||
[self assertRepeatedExtensionsModified:message repeatedCount:kGPBDefaultRepeatCount];
|
||||
[self assertRepeatedExtensionsModified:message
|
||||
repeatedCount:kGPBDefaultRepeatCount];
|
||||
}
|
||||
|
||||
- (void)testExtensionDefaults {
|
||||
@@ -1488,11 +1564,16 @@
|
||||
|
||||
XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
|
||||
XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
|
||||
XCTAssertFalse([message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
|
||||
XCTAssertFalse([message hasExtension:[UnittestRoot optionalForeignMessageExtension]]);
|
||||
XCTAssertFalse([message hasExtension:[UnittestRoot optionalImportMessageExtension]]);
|
||||
XCTAssertFalse([message hasExtension:[UnittestRoot optionalPublicImportMessageExtension]]);
|
||||
XCTAssertFalse([message hasExtension:[UnittestRoot optionalLazyMessageExtension]]);
|
||||
XCTAssertFalse(
|
||||
[message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
|
||||
XCTAssertFalse(
|
||||
[message hasExtension:[UnittestRoot optionalForeignMessageExtension]]);
|
||||
XCTAssertFalse(
|
||||
[message hasExtension:[UnittestRoot optionalImportMessageExtension]]);
|
||||
XCTAssertFalse([message
|
||||
hasExtension:[UnittestRoot optionalPublicImportMessageExtension]]);
|
||||
XCTAssertFalse(
|
||||
[message hasExtension:[UnittestRoot optionalLazyMessageExtension]]);
|
||||
|
||||
// They should auto create something when fetched.
|
||||
|
||||
@@ -1504,8 +1585,8 @@
|
||||
[message getExtension:[UnittestRoot optionalForeignMessageExtension]];
|
||||
ImportMessage *optionalImportMessage =
|
||||
[message getExtension:[UnittestRoot optionalImportMessageExtension]];
|
||||
PublicImportMessage *optionalPublicImportMessage =
|
||||
[message getExtension:[UnittestRoot optionalPublicImportMessageExtension]];
|
||||
PublicImportMessage *optionalPublicImportMessage = [message
|
||||
getExtension:[UnittestRoot optionalPublicImportMessageExtension]];
|
||||
TestAllTypes_NestedMessage *optionalLazyMessage =
|
||||
[message getExtension:[UnittestRoot optionalLazyMessageExtension]];
|
||||
|
||||
@@ -1530,17 +1611,23 @@
|
||||
// And they set that value back in to the message since the value created was
|
||||
// mutable (so a second fetch should give the same object).
|
||||
|
||||
XCTAssertEqual([message getExtension:[UnittestRoot optionalGroupExtension]], optionalGroup);
|
||||
XCTAssertEqual([message getExtension:[UnittestRoot optionalNestedMessageExtension]],
|
||||
optionalNestedMessage);
|
||||
XCTAssertEqual([message getExtension:[UnittestRoot optionalForeignMessageExtension]],
|
||||
optionalForeignMessage);
|
||||
XCTAssertEqual([message getExtension:[UnittestRoot optionalImportMessageExtension]],
|
||||
optionalImportMessage);
|
||||
XCTAssertEqual([message getExtension:[UnittestRoot optionalPublicImportMessageExtension]],
|
||||
optionalPublicImportMessage);
|
||||
XCTAssertEqual([message getExtension:[UnittestRoot optionalLazyMessageExtension]],
|
||||
optionalLazyMessage);
|
||||
XCTAssertEqual([message getExtension:[UnittestRoot optionalGroupExtension]],
|
||||
optionalGroup);
|
||||
XCTAssertEqual(
|
||||
[message getExtension:[UnittestRoot optionalNestedMessageExtension]],
|
||||
optionalNestedMessage);
|
||||
XCTAssertEqual(
|
||||
[message getExtension:[UnittestRoot optionalForeignMessageExtension]],
|
||||
optionalForeignMessage);
|
||||
XCTAssertEqual(
|
||||
[message getExtension:[UnittestRoot optionalImportMessageExtension]],
|
||||
optionalImportMessage);
|
||||
XCTAssertEqual(
|
||||
[message getExtension:[UnittestRoot optionalPublicImportMessageExtension]],
|
||||
optionalPublicImportMessage);
|
||||
XCTAssertEqual(
|
||||
[message getExtension:[UnittestRoot optionalLazyMessageExtension]],
|
||||
optionalLazyMessage);
|
||||
|
||||
// And the default objects for a second message should be distinct (again,
|
||||
// since they are mutable, each needs their own copy).
|
||||
@@ -1548,47 +1635,70 @@
|
||||
TestAllExtensions *message2 = [TestAllExtensions message];
|
||||
|
||||
// Intentionally doing a pointer comparison.
|
||||
XCTAssertNotEqual([message2 getExtension:[UnittestRoot optionalGroupExtension]], optionalGroup);
|
||||
XCTAssertNotEqual([message2 getExtension:[UnittestRoot optionalNestedMessageExtension]],
|
||||
optionalNestedMessage);
|
||||
XCTAssertNotEqual([message2 getExtension:[UnittestRoot optionalForeignMessageExtension]],
|
||||
optionalForeignMessage);
|
||||
XCTAssertNotEqual([message2 getExtension:[UnittestRoot optionalImportMessageExtension]],
|
||||
optionalImportMessage);
|
||||
XCTAssertNotEqual([message2 getExtension:[UnittestRoot optionalPublicImportMessageExtension]],
|
||||
optionalPublicImportMessage);
|
||||
XCTAssertNotEqual([message2 getExtension:[UnittestRoot optionalLazyMessageExtension]],
|
||||
optionalLazyMessage);
|
||||
XCTAssertNotEqual(
|
||||
[message2 getExtension:[UnittestRoot optionalGroupExtension]],
|
||||
optionalGroup);
|
||||
XCTAssertNotEqual(
|
||||
[message2 getExtension:[UnittestRoot optionalNestedMessageExtension]],
|
||||
optionalNestedMessage);
|
||||
XCTAssertNotEqual(
|
||||
[message2 getExtension:[UnittestRoot optionalForeignMessageExtension]],
|
||||
optionalForeignMessage);
|
||||
XCTAssertNotEqual(
|
||||
[message2 getExtension:[UnittestRoot optionalImportMessageExtension]],
|
||||
optionalImportMessage);
|
||||
XCTAssertNotEqual(
|
||||
[message2 getExtension:[UnittestRoot optionalPublicImportMessageExtension]],
|
||||
optionalPublicImportMessage);
|
||||
XCTAssertNotEqual(
|
||||
[message2 getExtension:[UnittestRoot optionalLazyMessageExtension]],
|
||||
optionalLazyMessage);
|
||||
|
||||
// Clear values, and on next access you get back new submessages.
|
||||
|
||||
[message setExtension:[UnittestRoot optionalGroupExtension] value:nil];
|
||||
[message setExtension:[UnittestRoot optionalGroupExtension] value:nil];
|
||||
[message setExtension:[UnittestRoot optionalNestedMessageExtension] value:nil];
|
||||
[message setExtension:[UnittestRoot optionalForeignMessageExtension] value:nil];
|
||||
[message setExtension:[UnittestRoot optionalImportMessageExtension] value:nil];
|
||||
[message setExtension:[UnittestRoot optionalPublicImportMessageExtension] value:nil];
|
||||
[message setExtension:[UnittestRoot optionalNestedMessageExtension]
|
||||
value:nil];
|
||||
[message setExtension:[UnittestRoot optionalForeignMessageExtension]
|
||||
value:nil];
|
||||
[message setExtension:[UnittestRoot optionalImportMessageExtension]
|
||||
value:nil];
|
||||
[message setExtension:[UnittestRoot optionalPublicImportMessageExtension]
|
||||
value:nil];
|
||||
[message setExtension:[UnittestRoot optionalLazyMessageExtension] value:nil];
|
||||
|
||||
XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
|
||||
XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
|
||||
XCTAssertFalse([message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
|
||||
XCTAssertFalse([message hasExtension:[UnittestRoot optionalForeignMessageExtension]]);
|
||||
XCTAssertFalse([message hasExtension:[UnittestRoot optionalImportMessageExtension]]);
|
||||
XCTAssertFalse([message hasExtension:[UnittestRoot optionalPublicImportMessageExtension]]);
|
||||
XCTAssertFalse([message hasExtension:[UnittestRoot optionalLazyMessageExtension]]);
|
||||
XCTAssertFalse(
|
||||
[message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
|
||||
XCTAssertFalse(
|
||||
[message hasExtension:[UnittestRoot optionalForeignMessageExtension]]);
|
||||
XCTAssertFalse(
|
||||
[message hasExtension:[UnittestRoot optionalImportMessageExtension]]);
|
||||
XCTAssertFalse([message
|
||||
hasExtension:[UnittestRoot optionalPublicImportMessageExtension]]);
|
||||
XCTAssertFalse(
|
||||
[message hasExtension:[UnittestRoot optionalLazyMessageExtension]]);
|
||||
|
||||
XCTAssertEqual([message getExtension:[UnittestRoot optionalGroupExtension]], optionalGroup);
|
||||
XCTAssertEqual([message getExtension:[UnittestRoot optionalNestedMessageExtension]],
|
||||
optionalNestedMessage);
|
||||
XCTAssertEqual([message getExtension:[UnittestRoot optionalForeignMessageExtension]],
|
||||
optionalForeignMessage);
|
||||
XCTAssertEqual([message getExtension:[UnittestRoot optionalImportMessageExtension]],
|
||||
optionalImportMessage);
|
||||
XCTAssertEqual([message getExtension:[UnittestRoot optionalPublicImportMessageExtension]],
|
||||
optionalPublicImportMessage);
|
||||
XCTAssertEqual([message getExtension:[UnittestRoot optionalLazyMessageExtension]],
|
||||
optionalLazyMessage);
|
||||
XCTAssertEqual([message getExtension:[UnittestRoot optionalGroupExtension]],
|
||||
optionalGroup);
|
||||
XCTAssertEqual(
|
||||
[message getExtension:[UnittestRoot optionalNestedMessageExtension]],
|
||||
optionalNestedMessage);
|
||||
XCTAssertEqual(
|
||||
[message getExtension:[UnittestRoot optionalForeignMessageExtension]],
|
||||
optionalForeignMessage);
|
||||
XCTAssertEqual(
|
||||
[message getExtension:[UnittestRoot optionalImportMessageExtension]],
|
||||
optionalImportMessage);
|
||||
XCTAssertEqual(
|
||||
[message
|
||||
getExtension:[UnittestRoot optionalPublicImportMessageExtension]],
|
||||
optionalPublicImportMessage);
|
||||
XCTAssertEqual(
|
||||
[message getExtension:[UnittestRoot optionalLazyMessageExtension]],
|
||||
optionalLazyMessage);
|
||||
}
|
||||
|
||||
- (void)testMultiplePointersToAutocreatedExtension {
|
||||
@@ -1598,11 +1708,13 @@
|
||||
TestAllExtensions *message2 = [TestAllExtensions message];
|
||||
GPBExtensionDescriptor *extension = [UnittestRoot optionalGroupExtension];
|
||||
[message setExtension:extension value:[message2 getExtension:extension]];
|
||||
XCTAssertEqual([message getExtension:extension], [message2 getExtension:extension]);
|
||||
XCTAssertEqual([message getExtension:extension],
|
||||
[message2 getExtension:extension]);
|
||||
XCTAssertFalse([message2 hasExtension:extension]);
|
||||
XCTAssertTrue([message hasExtension:extension]);
|
||||
|
||||
TestAllTypes_OptionalGroup *extensionValue = [message2 getExtension:extension];
|
||||
TestAllTypes_OptionalGroup *extensionValue =
|
||||
[message2 getExtension:extension];
|
||||
extensionValue.a = 1;
|
||||
XCTAssertTrue([message2 hasExtension:extension]);
|
||||
XCTAssertTrue([message hasExtension:extension]);
|
||||
@@ -1611,10 +1723,12 @@
|
||||
- (void)testCopyWithAutocreatedExtension {
|
||||
// Mutable copy shouldn't copy autocreated extensions.
|
||||
TestAllExtensions *message = [TestAllExtensions message];
|
||||
GPBExtensionDescriptor *optionalGroupExtension = [UnittestRoot optionalGroupExtension];
|
||||
GPBExtensionDescriptor *optionalGroupExtension =
|
||||
[UnittestRoot optionalGroupExtension];
|
||||
GPBExtensionDescriptor *optionalNestedMessageExtesion =
|
||||
[UnittestRoot optionalNestedMessageExtension];
|
||||
TestAllTypes_OptionalGroup *optionalGroup = [message getExtension:optionalGroupExtension];
|
||||
TestAllTypes_OptionalGroup *optionalGroup =
|
||||
[message getExtension:optionalGroupExtension];
|
||||
optionalGroup.a = 42;
|
||||
XCTAssertNotNil(optionalGroup);
|
||||
XCTAssertNotNil([message getExtension:optionalNestedMessageExtesion]);
|
||||
@@ -1641,11 +1755,13 @@
|
||||
- (void)testClearMessageAutocreatedExtension {
|
||||
// Call clear should cause it to recreate its autocreated extensions.
|
||||
TestAllExtensions *message = [TestAllExtensions message];
|
||||
GPBExtensionDescriptor *optionalGroupExtension = [UnittestRoot optionalGroupExtension];
|
||||
GPBExtensionDescriptor *optionalGroupExtension =
|
||||
[UnittestRoot optionalGroupExtension];
|
||||
TestAllTypes_OptionalGroup *optionalGroup =
|
||||
[[message getExtension:optionalGroupExtension] retain];
|
||||
[message clear];
|
||||
TestAllTypes_OptionalGroup *optionalGroupNew = [message getExtension:optionalGroupExtension];
|
||||
TestAllTypes_OptionalGroup *optionalGroupNew =
|
||||
[message getExtension:optionalGroupExtension];
|
||||
|
||||
// Intentionally doing a pointer comparison.
|
||||
XCTAssertNotEqual(optionalGroup, optionalGroupNew);
|
||||
@@ -1656,37 +1772,42 @@
|
||||
// Should be able to retain autocreated extension while the creator is
|
||||
// dealloced.
|
||||
TestAllExtensions *message = [TestAllExtensions message];
|
||||
GPBExtensionDescriptor *optionalGroupExtension = [UnittestRoot optionalGroupExtension];
|
||||
GPBExtensionDescriptor *optionalGroupExtension =
|
||||
[UnittestRoot optionalGroupExtension];
|
||||
|
||||
@autoreleasepool {
|
||||
TestAllExtensions *message2 = [TestAllExtensions message];
|
||||
[message setExtension:optionalGroupExtension
|
||||
value:[message2 getExtension:optionalGroupExtension]];
|
||||
XCTAssertTrue(
|
||||
GPBWasMessageAutocreatedBy([message getExtension:optionalGroupExtension], message2));
|
||||
XCTAssertTrue(GPBWasMessageAutocreatedBy(
|
||||
[message getExtension:optionalGroupExtension], message2));
|
||||
}
|
||||
|
||||
XCTAssertFalse(
|
||||
GPBWasMessageAutocreatedBy([message getExtension:optionalGroupExtension], message));
|
||||
XCTAssertFalse(GPBWasMessageAutocreatedBy(
|
||||
[message getExtension:optionalGroupExtension], message));
|
||||
}
|
||||
|
||||
- (void)testClearAutocreatedExtension {
|
||||
// Clearing autocreated extension should NOT cause it to lose its creator.
|
||||
TestAllExtensions *message = [TestAllExtensions message];
|
||||
GPBExtensionDescriptor *optionalGroupExtension = [UnittestRoot optionalGroupExtension];
|
||||
GPBExtensionDescriptor *optionalGroupExtension =
|
||||
[UnittestRoot optionalGroupExtension];
|
||||
TestAllTypes_OptionalGroup *optionalGroup =
|
||||
[[message getExtension:optionalGroupExtension] retain];
|
||||
[message clearExtension:optionalGroupExtension];
|
||||
TestAllTypes_OptionalGroup *optionalGroupNew = [message getExtension:optionalGroupExtension];
|
||||
TestAllTypes_OptionalGroup *optionalGroupNew =
|
||||
[message getExtension:optionalGroupExtension];
|
||||
XCTAssertEqual(optionalGroup, optionalGroupNew);
|
||||
XCTAssertFalse([message hasExtension:optionalGroupExtension]);
|
||||
[optionalGroup release];
|
||||
|
||||
// Clearing autocreated extension should not cause its creator to become
|
||||
// visible
|
||||
GPBExtensionDescriptor *recursiveExtension = [UnittestObjcRoot recursiveExtension];
|
||||
GPBExtensionDescriptor *recursiveExtension =
|
||||
[UnittestObjcRoot recursiveExtension];
|
||||
TestAllExtensions *message_lvl2 = [message getExtension:recursiveExtension];
|
||||
TestAllExtensions *message_lvl3 = [message_lvl2 getExtension:recursiveExtension];
|
||||
TestAllExtensions *message_lvl3 =
|
||||
[message_lvl2 getExtension:recursiveExtension];
|
||||
[message_lvl3 clearExtension:recursiveExtension];
|
||||
XCTAssertFalse([message hasExtension:recursiveExtension]);
|
||||
}
|
||||
@@ -1695,10 +1816,13 @@
|
||||
// Setting an extension should cause the extension to appear to its creator.
|
||||
// Test this several levels deep.
|
||||
TestAllExtensions *message = [TestAllExtensions message];
|
||||
GPBExtensionDescriptor *recursiveExtension = [UnittestObjcRoot recursiveExtension];
|
||||
GPBExtensionDescriptor *recursiveExtension =
|
||||
[UnittestObjcRoot recursiveExtension];
|
||||
TestAllExtensions *message_lvl2 = [message getExtension:recursiveExtension];
|
||||
TestAllExtensions *message_lvl3 = [message_lvl2 getExtension:recursiveExtension];
|
||||
TestAllExtensions *message_lvl4 = [message_lvl3 getExtension:recursiveExtension];
|
||||
TestAllExtensions *message_lvl3 =
|
||||
[message_lvl2 getExtension:recursiveExtension];
|
||||
TestAllExtensions *message_lvl4 =
|
||||
[message_lvl3 getExtension:recursiveExtension];
|
||||
XCTAssertFalse([message hasExtension:recursiveExtension]);
|
||||
XCTAssertFalse([message_lvl2 hasExtension:recursiveExtension]);
|
||||
XCTAssertFalse([message_lvl3 hasExtension:recursiveExtension]);
|
||||
@@ -1716,15 +1840,18 @@
|
||||
- (void)testSetAutocreatedExtensionToSelf {
|
||||
// Setting extension to itself should cause it to become visible.
|
||||
TestAllExtensions *message = [TestAllExtensions message];
|
||||
GPBExtensionDescriptor *optionalGroupExtension = [UnittestRoot optionalGroupExtension];
|
||||
GPBExtensionDescriptor *optionalGroupExtension =
|
||||
[UnittestRoot optionalGroupExtension];
|
||||
XCTAssertNotNil([message getExtension:optionalGroupExtension]);
|
||||
XCTAssertFalse([message hasExtension:optionalGroupExtension]);
|
||||
[message setExtension:optionalGroupExtension value:[message getExtension:optionalGroupExtension]];
|
||||
[message setExtension:optionalGroupExtension
|
||||
value:[message getExtension:optionalGroupExtension]];
|
||||
XCTAssertTrue([message hasExtension:optionalGroupExtension]);
|
||||
}
|
||||
|
||||
- (void)testAutocreatedExtensionMemoryLeaks {
|
||||
GPBExtensionDescriptor *recursiveExtension = [UnittestObjcRoot recursiveExtension];
|
||||
GPBExtensionDescriptor *recursiveExtension =
|
||||
[UnittestObjcRoot recursiveExtension];
|
||||
|
||||
// Test for memory leaks with autocreated extensions.
|
||||
TestAllExtensions *message;
|
||||
@@ -1736,7 +1863,8 @@
|
||||
message_lvl2 = [[message getExtension:recursiveExtension] retain];
|
||||
message_lvl3 = [[message_lvl2 getExtension:recursiveExtension] retain];
|
||||
message_lvl4 = [[message_lvl3 getExtension:recursiveExtension] retain];
|
||||
[message_lvl2 setExtension:[UnittestRoot optionalInt32Extension] value:@(1)];
|
||||
[message_lvl2 setExtension:[UnittestRoot optionalInt32Extension]
|
||||
value:@(1)];
|
||||
}
|
||||
|
||||
XCTAssertEqual(message.retainCount, (NSUInteger)1);
|
||||
@@ -1756,7 +1884,8 @@
|
||||
}
|
||||
|
||||
- (void)testSetExtensionWithAutocreatedValue {
|
||||
GPBExtensionDescriptor *recursiveExtension = [UnittestObjcRoot recursiveExtension];
|
||||
GPBExtensionDescriptor *recursiveExtension =
|
||||
[UnittestObjcRoot recursiveExtension];
|
||||
|
||||
TestAllExtensions *message;
|
||||
@autoreleasepool {
|
||||
@@ -1766,7 +1895,8 @@
|
||||
|
||||
// This statements checks that the extension value isn't accidentally
|
||||
// dealloced when removing it from the autocreated map.
|
||||
[message setExtension:recursiveExtension value:[message getExtension:recursiveExtension]];
|
||||
[message setExtension:recursiveExtension
|
||||
value:[message getExtension:recursiveExtension]];
|
||||
XCTAssertTrue([message hasExtension:recursiveExtension]);
|
||||
[message release];
|
||||
}
|
||||
@@ -1779,22 +1909,26 @@
|
||||
}
|
||||
|
||||
- (void)testGenerateAndParseUnknownMessage {
|
||||
GPBUnknownFieldSet *unknowns = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownFieldSet *unknowns =
|
||||
[[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
[unknowns mergeVarintField:123 value:456];
|
||||
GPBMessage *message = [GPBMessage message];
|
||||
[message setUnknownFields:unknowns];
|
||||
NSData *data = [message data];
|
||||
GPBMessage *message2 = [GPBMessage parseFromData:data extensionRegistry:nil error:NULL];
|
||||
GPBMessage *message2 =
|
||||
[GPBMessage parseFromData:data extensionRegistry:nil error:NULL];
|
||||
XCTAssertEqualObjects(message, message2);
|
||||
}
|
||||
|
||||
- (void)testDelimitedWriteAndParseMultipleMessages {
|
||||
GPBUnknownFieldSet *unknowns1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownFieldSet *unknowns1 =
|
||||
[[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
[unknowns1 mergeVarintField:123 value:456];
|
||||
GPBMessage *message1 = [GPBMessage message];
|
||||
[message1 setUnknownFields:unknowns1];
|
||||
|
||||
GPBUnknownFieldSet *unknowns2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownFieldSet *unknowns2 =
|
||||
[[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
[unknowns2 mergeVarintField:789 value:987];
|
||||
[unknowns2 mergeVarintField:654 value:321];
|
||||
GPBMessage *message2 = [GPBMessage message];
|
||||
@@ -1803,7 +1937,8 @@
|
||||
NSMutableData *delimitedData = [NSMutableData data];
|
||||
[delimitedData appendData:[message1 delimitedData]];
|
||||
[delimitedData appendData:[message2 delimitedData]];
|
||||
GPBCodedInputStream *input = [GPBCodedInputStream streamWithData:delimitedData];
|
||||
GPBCodedInputStream *input =
|
||||
[GPBCodedInputStream streamWithData:delimitedData];
|
||||
GPBMessage *message3 = [GPBMessage parseDelimitedFromCodedInputStream:input
|
||||
extensionRegistry:nil
|
||||
error:NULL];
|
||||
@@ -1835,7 +1970,8 @@
|
||||
}
|
||||
|
||||
- (void)testEnumDescriptorFromExtensionDescriptor {
|
||||
GPBExtensionDescriptor *extDescriptor = [UnittestRoot optionalForeignEnumExtension];
|
||||
GPBExtensionDescriptor *extDescriptor =
|
||||
[UnittestRoot optionalForeignEnumExtension];
|
||||
XCTAssertEqual(extDescriptor.dataType, GPBDataTypeEnum);
|
||||
GPBEnumDescriptor *enumDescriptor = extDescriptor.enumDescriptor;
|
||||
GPBEnumDescriptor *expectedDescriptor = ForeignEnum_EnumDescriptor();
|
||||
@@ -1843,8 +1979,8 @@
|
||||
}
|
||||
|
||||
- (void)testPropertyNaming {
|
||||
// names.cc has some special handing to get proper all caps for a few cases to
|
||||
// meet objc developer expectations.
|
||||
// objectivec_helpers.cc has some special handing to get proper all caps
|
||||
// for a few cases to meet objc developer expectations.
|
||||
//
|
||||
// This "test" confirms that the expected names are generated, otherwise the
|
||||
// test itself will fail to compile.
|
||||
@@ -1861,7 +1997,7 @@
|
||||
}
|
||||
|
||||
- (void)testEnumNaming {
|
||||
// names.cc has some interesting cases to deal with in
|
||||
// objectivec_helpers.cc has some interesting cases to deal with in
|
||||
// EnumValueName/EnumValueShortName. Confirm that things generated as
|
||||
// expected.
|
||||
|
||||
@@ -1942,7 +2078,8 @@
|
||||
|
||||
// Repeated field (shouldn't ever be an issue since developer has to use the
|
||||
// right GPBArray methods themselves).
|
||||
msg.mumbleArray = [GPBEnumArray arrayWithValidationFunction:EnumTestMsg_MyEnum_IsValidValue];
|
||||
msg.mumbleArray = [GPBEnumArray
|
||||
arrayWithValidationFunction:EnumTestMsg_MyEnum_IsValidValue];
|
||||
[msg.mumbleArray addValue:EnumTestMsg_MyEnum_Zero];
|
||||
[msg.mumbleArray addValue:EnumTestMsg_MyEnum_One];
|
||||
[msg.mumbleArray addValue:EnumTestMsg_MyEnum_Two];
|
||||
@@ -1958,16 +2095,20 @@
|
||||
XCTAssertNotNil(data);
|
||||
msgPrime = [EnumTestMsg parseFromData:data error:NULL];
|
||||
XCTAssertEqualObjects(msgPrime, msg);
|
||||
XCTAssertEqual([msgPrime.mumbleArray valueAtIndex:0], EnumTestMsg_MyEnum_Zero);
|
||||
XCTAssertEqual([msgPrime.mumbleArray valueAtIndex:0],
|
||||
EnumTestMsg_MyEnum_Zero);
|
||||
XCTAssertEqual([msgPrime.mumbleArray valueAtIndex:1], EnumTestMsg_MyEnum_One);
|
||||
XCTAssertEqual([msgPrime.mumbleArray valueAtIndex:2], EnumTestMsg_MyEnum_Two);
|
||||
XCTAssertEqual([msgPrime.mumbleArray valueAtIndex:3], EnumTestMsg_MyEnum_NegOne);
|
||||
XCTAssertEqual([msgPrime.mumbleArray valueAtIndex:4], EnumTestMsg_MyEnum_NegTwo);
|
||||
XCTAssertEqual([msgPrime.mumbleArray valueAtIndex:3],
|
||||
EnumTestMsg_MyEnum_NegOne);
|
||||
XCTAssertEqual([msgPrime.mumbleArray valueAtIndex:4],
|
||||
EnumTestMsg_MyEnum_NegTwo);
|
||||
}
|
||||
|
||||
- (void)testReservedWordNaming {
|
||||
// names.cc has some special handing to make sure that some "reserved" objc
|
||||
// names get renamed in a way so they don't conflict.
|
||||
// objectivec_helpers.cc has some special handing to make sure that
|
||||
// some "reserved" objc names get renamed in a way so they
|
||||
// don't conflict.
|
||||
//
|
||||
// This "test" confirms that the expected names are generated,
|
||||
// otherwise the test itself will fail to compile.
|
||||
@@ -2059,12 +2200,12 @@
|
||||
msg1.boolField32 = YES;
|
||||
msg2.boolField32 = YES;
|
||||
|
||||
XCTAssertTrue(msg1 != msg2); // Different pointers.
|
||||
XCTAssertTrue(msg1 != msg2); // Different pointers.
|
||||
XCTAssertEqual([msg1 hash], [msg2 hash]);
|
||||
XCTAssertEqualObjects(msg1, msg2);
|
||||
|
||||
BoolOnlyMessage *msg1Prime = [[msg1 copy] autorelease];
|
||||
XCTAssertTrue(msg1Prime != msg1); // Different pointers.
|
||||
XCTAssertTrue(msg1Prime != msg1); // Different pointers.
|
||||
XCTAssertEqual([msg1 hash], [msg1Prime hash]);
|
||||
XCTAssertEqualObjects(msg1, msg1Prime);
|
||||
|
||||
@@ -2111,26 +2252,24 @@
|
||||
TestMessageOfMaps *msg2 = [[msg copy] autorelease];
|
||||
XCTAssertNotNil(msg2);
|
||||
XCTAssertEqualObjects(msg2, msg);
|
||||
XCTAssertTrue(msg2 != msg); // ptr compare
|
||||
XCTAssertTrue(msg.strToStr != msg2.strToStr); // ptr compare
|
||||
XCTAssertTrue(msg.intToStr != msg2.intToStr); // ptr compare
|
||||
XCTAssertTrue(msg.intToInt != msg2.intToInt); // ptr compare
|
||||
XCTAssertTrue(msg.strToBool != msg2.strToBool); // ptr compare
|
||||
XCTAssertTrue(msg.boolToStr != msg2.boolToStr); // ptr compare
|
||||
XCTAssertTrue(msg2 != msg); // ptr compare
|
||||
XCTAssertTrue(msg.strToStr != msg2.strToStr); // ptr compare
|
||||
XCTAssertTrue(msg.intToStr != msg2.intToStr); // ptr compare
|
||||
XCTAssertTrue(msg.intToInt != msg2.intToInt); // ptr compare
|
||||
XCTAssertTrue(msg.strToBool != msg2.strToBool); // ptr compare
|
||||
XCTAssertTrue(msg.boolToStr != msg2.boolToStr); // ptr compare
|
||||
XCTAssertTrue(msg.boolToBool != msg2.boolToBool); // ptr compare
|
||||
XCTAssertTrue(msg.intToBool != msg2.intToBool); // ptr compare
|
||||
XCTAssertTrue(msg.boolToInt != msg2.boolToInt); // ptr compare
|
||||
XCTAssertTrue(msg.strToMsg != msg2.strToMsg); // ptr compare
|
||||
XCTAssertTrue(msg.intToMsg != msg2.intToMsg); // ptr compare
|
||||
XCTAssertTrue(msg.boolToMsg != msg2.boolToMsg); // ptr compare
|
||||
XCTAssertTrue(msg.intToBool != msg2.intToBool); // ptr compare
|
||||
XCTAssertTrue(msg.boolToInt != msg2.boolToInt); // ptr compare
|
||||
XCTAssertTrue(msg.strToMsg != msg2.strToMsg); // ptr compare
|
||||
XCTAssertTrue(msg.intToMsg != msg2.intToMsg); // ptr compare
|
||||
XCTAssertTrue(msg.boolToMsg != msg2.boolToMsg); // ptr compare
|
||||
|
||||
XCTAssertTrue(msg.strToMsg[@"baz"] != msg2.strToMsg[@"baz"]); // ptr compare
|
||||
XCTAssertEqualObjects(msg.strToMsg[@"baz"], msg2.strToMsg[@"baz"]);
|
||||
XCTAssertTrue([msg.intToMsg objectForKey:222] !=
|
||||
[msg2.intToMsg objectForKey:222]); // ptr compare
|
||||
XCTAssertTrue([msg.intToMsg objectForKey:222] != [msg2.intToMsg objectForKey:222]); // ptr compare
|
||||
XCTAssertEqualObjects([msg.intToMsg objectForKey:222], [msg2.intToMsg objectForKey:222]);
|
||||
XCTAssertTrue([msg.boolToMsg objectForKey:YES] !=
|
||||
[msg2.boolToMsg objectForKey:YES]); // ptr compare
|
||||
XCTAssertTrue([msg.boolToMsg objectForKey:YES] != [msg2.boolToMsg objectForKey:YES]); // ptr compare
|
||||
XCTAssertEqualObjects([msg.boolToMsg objectForKey:YES], [msg2.boolToMsg objectForKey:YES]);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,10 @@
|
||||
// (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).
|
||||
//
|
||||
@@ -41,19 +43,20 @@
|
||||
// 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"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/UnittestImport.pbobjc.h"
|
||||
|
||||
// Sanity check the conditions of the test within the Xcode project.
|
||||
#if !__cplusplus
|
||||
#error This isn't compiled as Objective C++?
|
||||
#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?
|
||||
// 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
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
// 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"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/UnittestImport.pbobjc.h"
|
||||
#import "google/protobuf/UnittestObjc.pbobjc.h"
|
||||
|
||||
//
|
||||
// This file really just uses the unittests framework as a testbed to
|
||||
@@ -69,9 +69,9 @@ static const uint32_t kRepeatedCount = 100;
|
||||
// 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];
|
||||
TestAllTypes *allTypesMessage = [TestAllTypes message];
|
||||
[self setAllFields:allTypesMessage repeatedCount:2];
|
||||
NSData* allTypesData = allTypesMessage.data;
|
||||
NSData *allTypesData = allTypesMessage.data;
|
||||
|
||||
[self measureBlock:^{
|
||||
for (int i = 0; i < 500; ++i) {
|
||||
@@ -86,9 +86,9 @@ static const uint32_t kRepeatedCount = 100;
|
||||
// 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];
|
||||
TestAllTypes *allTypesMessage = [TestAllTypes message];
|
||||
[self setAllFields:allTypesMessage repeatedCount:2];
|
||||
NSData* allTypesData = allTypesMessage.data;
|
||||
NSData *allTypesData = allTypesMessage.data;
|
||||
|
||||
dispatch_queue_t concurrentQueue = dispatch_queue_create("perfQueue", DISPATCH_QUEUE_CONCURRENT);
|
||||
|
||||
@@ -104,9 +104,7 @@ static const uint32_t kRepeatedCount = 100;
|
||||
[TestAllTypes parseFromData:allTypesData error:NULL];
|
||||
});
|
||||
|
||||
dispatch_group_notify(group, concurrentQueue,
|
||||
^{
|
||||
});
|
||||
dispatch_group_notify(group, concurrentQueue, ^{});
|
||||
|
||||
dispatch_release(group);
|
||||
}
|
||||
@@ -120,9 +118,9 @@ static const uint32_t kRepeatedCount = 100;
|
||||
// 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];
|
||||
TestAllExtensions *allExtensionsMessage = [TestAllExtensions message];
|
||||
[self setAllExtensions:allExtensionsMessage repeatedCount:2];
|
||||
NSData* allExtensionsData = allExtensionsMessage.data;
|
||||
NSData *allExtensionsData = allExtensionsMessage.data;
|
||||
|
||||
[self measureBlock:^{
|
||||
for (int i = 0; i < 500; ++i) {
|
||||
@@ -141,9 +139,9 @@ static const uint32_t kRepeatedCount = 100;
|
||||
// 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];
|
||||
TestAllExtensions *allExtensionsMessage = [TestAllExtensions message];
|
||||
[self setAllExtensions:allExtensionsMessage repeatedCount:2];
|
||||
NSData* allExtensionsData = allExtensionsMessage.data;
|
||||
NSData *allExtensionsData = allExtensionsMessage.data;
|
||||
|
||||
dispatch_queue_t concurrentQueue = dispatch_queue_create("perfQueue", DISPATCH_QUEUE_CONCURRENT);
|
||||
|
||||
@@ -163,9 +161,7 @@ static const uint32_t kRepeatedCount = 100;
|
||||
error:NULL];
|
||||
});
|
||||
|
||||
dispatch_group_notify(group, concurrentQueue,
|
||||
^{
|
||||
});
|
||||
dispatch_group_notify(group, concurrentQueue, ^{});
|
||||
|
||||
dispatch_release(group);
|
||||
}
|
||||
@@ -181,7 +177,8 @@ static const uint32_t kRepeatedCount = 100;
|
||||
[self setAllExtensions:message repeatedCount:kRepeatedCount];
|
||||
NSData* rawBytes = [message data];
|
||||
[message release];
|
||||
TestAllExtensions* message2 = [[TestAllExtensions alloc] initWithData:rawBytes error:NULL];
|
||||
TestAllExtensions* message2 =
|
||||
[[TestAllExtensions alloc] initWithData:rawBytes error:NULL];
|
||||
[message2 release];
|
||||
}
|
||||
}];
|
||||
@@ -207,8 +204,8 @@ static const uint32_t kRepeatedCount = 100;
|
||||
[self setPackedExtensions:message repeatedCount:kRepeatedCount];
|
||||
NSData* rawBytes = [message data];
|
||||
[message release];
|
||||
TestPackedExtensions* message2 = [[TestPackedExtensions alloc] initWithData:rawBytes
|
||||
error:NULL];
|
||||
TestPackedExtensions* message2 =
|
||||
[[TestPackedExtensions alloc] initWithData:rawBytes error:NULL];
|
||||
[message2 release];
|
||||
}
|
||||
}];
|
||||
|
||||
@@ -48,6 +48,7 @@ static inline NSData *DataFromCStr(const char *str) {
|
||||
#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;
|
||||
|
||||
@@ -55,11 +56,16 @@ extern const uint32_t kGPBDefaultRepeatCount;
|
||||
|
||||
- (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)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;
|
||||
@@ -67,14 +73,20 @@ extern const uint32_t kGPBDefaultRepeatCount;
|
||||
- (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)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)assertPackedFieldsSet:(TestPackedTypes *)message
|
||||
repeatedCount:(uint32_t)count;
|
||||
- (void)assertPackedExtensionsSet:(TestPackedExtensions *)message
|
||||
repeatedCount:(uint32_t)count;
|
||||
|
||||
- (void)modifyRepeatedExtensions:(TestAllExtensions *)message;
|
||||
- (void)modifyRepeatedFields:(TestAllTypes *)message;
|
||||
@@ -84,7 +96,8 @@ extern const uint32_t kGPBDefaultRepeatCount;
|
||||
- (NSData *)getDataFileNamed:(NSString *)name dataToWrite:(NSData *)dataToWrite;
|
||||
|
||||
- (void)assertAllFieldsKVCMatch:(TestAllTypes *)message;
|
||||
- (void)setAllFieldsViaKVC:(TestAllTypes *)message repeatedCount:(uint32_t)count;
|
||||
- (void)setAllFieldsViaKVC:(TestAllTypes *)message
|
||||
repeatedCount:(uint32_t)count;
|
||||
- (void)assertClearKVC:(TestAllTypes *)message;
|
||||
|
||||
@end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -31,27 +31,43 @@
|
||||
// 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"
|
||||
// The unittest_custom_options.proto extends the messages in descriptor.proto
|
||||
// so we build it in to test extending in general. The library doesn't provide
|
||||
// a descriptor as it doesn't use the classes/enums.
|
||||
#import "google/protobuf/Descriptor.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"
|
||||
#import "google/protobuf/AnyTest.pbobjc.m"
|
||||
#import "google/protobuf/MapProto2Unittest.pbobjc.m"
|
||||
#import "google/protobuf/MapUnittest.pbobjc.m"
|
||||
#import "google/protobuf/Unittest.pbobjc.m"
|
||||
#import "google/protobuf/UnittestArena.pbobjc.m"
|
||||
#import "google/protobuf/UnittestCustomOptions.pbobjc.m"
|
||||
#import "google/protobuf/UnittestCycle.pbobjc.m"
|
||||
#import "google/protobuf/UnittestDeprecated.pbobjc.m"
|
||||
#import "google/protobuf/UnittestDeprecatedFile.pbobjc.m"
|
||||
#import "google/protobuf/UnittestDropUnknownFields.pbobjc.m"
|
||||
#import "google/protobuf/UnittestEmbedOptimizeFor.pbobjc.m"
|
||||
#import "google/protobuf/UnittestEmpty.pbobjc.m"
|
||||
#import "google/protobuf/UnittestEnormousDescriptor.pbobjc.m"
|
||||
#import "google/protobuf/UnittestImport.pbobjc.m"
|
||||
#import "google/protobuf/UnittestImportLite.pbobjc.m"
|
||||
#import "google/protobuf/UnittestImportPublic.pbobjc.m"
|
||||
#import "google/protobuf/UnittestImportPublicLite.pbobjc.m"
|
||||
#import "google/protobuf/UnittestLite.pbobjc.m"
|
||||
#import "google/protobuf/UnittestMset.pbobjc.m"
|
||||
#import "google/protobuf/UnittestMsetWireFormat.pbobjc.m"
|
||||
#import "google/protobuf/UnittestNoGenericServices.pbobjc.m"
|
||||
#import "google/protobuf/UnittestObjc.pbobjc.m"
|
||||
#import "google/protobuf/UnittestObjcStartup.pbobjc.m"
|
||||
#import "google/protobuf/UnittestOptimizeFor.pbobjc.m"
|
||||
#import "google/protobuf/UnittestPreserveUnknownEnum.pbobjc.m"
|
||||
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.m"
|
||||
#import "google/protobuf/UnittestRuntimeProto3.pbobjc.m"
|
||||
|
||||
#import "google/protobuf/UnittestExtensionChainA.pbobjc.m"
|
||||
#import "google/protobuf/UnittestExtensionChainB.pbobjc.m"
|
||||
#import "google/protobuf/UnittestExtensionChainC.pbobjc.m"
|
||||
#import "google/protobuf/UnittestExtensionChainD.pbobjc.m"
|
||||
#import "google/protobuf/UnittestExtensionChainE.pbobjc.m"
|
||||
// See GPBUnittestProtos2.m for for "UnittestExtensionChainF.pbobjc.m"
|
||||
#import "objectivec/Tests/UnittestExtensionChainG.pbobjc.m"
|
||||
#import "google/protobuf/UnittestExtensionChainG.pbobjc.m"
|
||||
|
||||
@@ -31,4 +31,4 @@
|
||||
// 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"
|
||||
#import "google/protobuf/UnittestExtensionChainF.pbobjc.m"
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
#import "GPBUnknownField_PackagePrivate.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "GPBUnknownFieldSet_PackagePrivate.h"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
|
||||
@interface GPBUnknownFieldSet (GPBUnknownFieldSetTest)
|
||||
- (void)getTags:(int32_t*)tags;
|
||||
@@ -61,7 +61,7 @@
|
||||
}
|
||||
|
||||
- (void)testInvalidFieldNumber {
|
||||
GPBUnknownFieldSet* set = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownFieldSet *set = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* field = [[[GPBUnknownField alloc] initWithNumber:0] autorelease];
|
||||
XCTAssertThrowsSpecificNamed([set addField:field], NSException, NSInvalidArgumentException);
|
||||
}
|
||||
@@ -69,10 +69,10 @@
|
||||
- (void)testEqualityAndHash {
|
||||
// Empty
|
||||
|
||||
GPBUnknownFieldSet* set1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownFieldSet *set1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
XCTAssertTrue([set1 isEqual:set1]);
|
||||
XCTAssertFalse([set1 isEqual:@"foo"]);
|
||||
GPBUnknownFieldSet* set2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownFieldSet *set2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
XCTAssertEqualObjects(set1, set2);
|
||||
XCTAssertEqual([set1 hash], [set2 hash]);
|
||||
|
||||
@@ -126,11 +126,11 @@
|
||||
|
||||
// Group
|
||||
|
||||
GPBUnknownFieldSet* group1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
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];
|
||||
GPBUnknownFieldSet *group2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup2 = [[[GPBUnknownField alloc] initWithNumber:10] autorelease];
|
||||
[fieldGroup2 addVarint:1];
|
||||
[group2 addField:fieldGroup2];
|
||||
@@ -153,9 +153,10 @@
|
||||
// numbers as allFieldsData except that each field is some other wire
|
||||
// type.
|
||||
- (NSData*)getBizarroData {
|
||||
GPBUnknownFieldSet* bizarroFields = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownFieldSet* bizarroFields =
|
||||
[[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
NSUInteger count = [unknownFields_ countOfFields];
|
||||
int32_t* tags = malloc(count * sizeof(int32_t));
|
||||
int32_t *tags = malloc(count * sizeof(int32_t));
|
||||
if (!tags) {
|
||||
XCTFail(@"Failed to make scratch buffer for testing");
|
||||
return [NSData data];
|
||||
@@ -167,17 +168,20 @@
|
||||
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];
|
||||
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];
|
||||
GPBUnknownField* fixed32Field =
|
||||
[[[GPBUnknownField alloc] initWithNumber:tag] autorelease];
|
||||
[fixed32Field addFixed32:1];
|
||||
[bizarroFields addField:fixed32Field];
|
||||
}
|
||||
}
|
||||
} @finally {
|
||||
}
|
||||
@finally {
|
||||
free(tags);
|
||||
}
|
||||
|
||||
@@ -216,7 +220,7 @@
|
||||
[field addLengthDelimited:DataFromCStr("data1")];
|
||||
[set1 addField:field];
|
||||
|
||||
GPBUnknownFieldSet* group1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownFieldSet *group1 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup1 = [[[GPBUnknownField alloc] initWithNumber:200] autorelease];
|
||||
[fieldGroup1 addVarint:100];
|
||||
[group1 addField:fieldGroup1];
|
||||
@@ -242,7 +246,7 @@
|
||||
[field addLengthDelimited:DataFromCStr("data2")];
|
||||
[set2 addField:field];
|
||||
|
||||
GPBUnknownFieldSet* group2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownFieldSet *group2 = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup2 = [[[GPBUnknownField alloc] initWithNumber:201] autorelease];
|
||||
[fieldGroup2 addVarint:99];
|
||||
[group2 addField:fieldGroup2];
|
||||
@@ -276,11 +280,11 @@
|
||||
[field addLengthDelimited:DataFromCStr("data2")];
|
||||
[set3 addField:field];
|
||||
|
||||
GPBUnknownFieldSet* group3a = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
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];
|
||||
GPBUnknownFieldSet *group3b = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup3b2 = [[[GPBUnknownField alloc] initWithNumber:201] autorelease];
|
||||
[fieldGroup3b2 addVarint:99];
|
||||
[group3b addField:fieldGroup3b2];
|
||||
@@ -310,7 +314,7 @@
|
||||
}
|
||||
|
||||
- (void)testClearMessage {
|
||||
TestEmptyMessage* message = [TestEmptyMessage message];
|
||||
TestEmptyMessage *message = [TestEmptyMessage message];
|
||||
[message mergeFrom:emptyMessage_];
|
||||
[message clear];
|
||||
XCTAssertEqual(message.serializedSize, (size_t)0);
|
||||
@@ -318,8 +322,9 @@
|
||||
|
||||
- (void)testParseKnownAndUnknown {
|
||||
// Test mixing known and unknown fields when parsing.
|
||||
GPBUnknownFieldSet* fields = [[unknownFields_ copy] autorelease];
|
||||
GPBUnknownField* field = [[[GPBUnknownField alloc] initWithNumber:123456] autorelease];
|
||||
GPBUnknownFieldSet *fields = [[unknownFields_ copy] autorelease];
|
||||
GPBUnknownField *field =
|
||||
[[[GPBUnknownField alloc] initWithNumber:123456] autorelease];
|
||||
[field addVarint:654321];
|
||||
[fields addField:field];
|
||||
|
||||
@@ -339,8 +344,10 @@
|
||||
// when parsing.
|
||||
|
||||
NSData* bizarroData = [self getBizarroData];
|
||||
TestAllTypes* allTypesMessage = [TestAllTypes parseFromData:bizarroData error:NULL];
|
||||
TestEmptyMessage* emptyMessage = [TestEmptyMessage parseFromData:bizarroData error:NULL];
|
||||
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.
|
||||
@@ -354,7 +361,8 @@
|
||||
TestEmptyMessageWithExtensions* message =
|
||||
[TestEmptyMessageWithExtensions parseFromData:allFieldsData_ error:NULL];
|
||||
|
||||
XCTAssertEqual(unknownFields_.countOfFields, message.unknownFields.countOfFields);
|
||||
XCTAssertEqual(unknownFields_.countOfFields,
|
||||
message.unknownFields.countOfFields);
|
||||
XCTAssertEqualObjects(allFieldsData_, message.data);
|
||||
}
|
||||
|
||||
@@ -363,9 +371,10 @@
|
||||
// when parsing extensions.
|
||||
|
||||
NSData* bizarroData = [self getBizarroData];
|
||||
TestAllExtensions* allExtensionsMessage = [TestAllExtensions parseFromData:bizarroData
|
||||
error:NULL];
|
||||
TestEmptyMessage* emptyMessage = [TestEmptyMessage parseFromData:bizarroData error:NULL];
|
||||
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.
|
||||
@@ -456,7 +465,7 @@
|
||||
|
||||
// Group
|
||||
|
||||
GPBUnknownFieldSet* group = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownFieldSet *group = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
GPBUnknownField* fieldGroup = [[[GPBUnknownField alloc] initWithNumber:100] autorelease];
|
||||
[fieldGroup addVarint:100];
|
||||
[group addField:fieldGroup];
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
#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"
|
||||
#import "google/protobuf/MapUnittest.pbobjc.h"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/UnittestObjc.pbobjc.h"
|
||||
|
||||
@interface UtilitiesTests : GPBTestCase
|
||||
@end
|
||||
@@ -62,7 +62,6 @@
|
||||
|
||||
- (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).
|
||||
@@ -81,7 +80,6 @@
|
||||
// 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";
|
||||
|
||||
@@ -106,12 +104,10 @@
|
||||
// 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 {
|
||||
@@ -125,8 +121,10 @@
|
||||
|
||||
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];
|
||||
NSData *expectedData =
|
||||
[self getDataFileNamed:fileName dataToWrite:resultData];
|
||||
NSString *expected = [[NSString alloc] initWithData:expectedData
|
||||
encoding:NSUTF8StringEncoding];
|
||||
XCTAssertEqualObjects(expected, result);
|
||||
[expected release];
|
||||
}
|
||||
@@ -143,14 +141,12 @@
|
||||
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);
|
||||
}
|
||||
@@ -165,8 +161,10 @@
|
||||
|
||||
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];
|
||||
NSData *expectedData =
|
||||
[self getDataFileNamed:fileName dataToWrite:resultData];
|
||||
NSString *expected = [[NSString alloc] initWithData:expectedData
|
||||
encoding:NSUTF8StringEncoding];
|
||||
XCTAssertEqualObjects(expected, result);
|
||||
[expected release];
|
||||
}
|
||||
@@ -185,8 +183,10 @@
|
||||
// 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];
|
||||
NSData *expectedData =
|
||||
[self getDataFileNamed:fileName dataToWrite:resultData];
|
||||
NSString *expected = [[NSString alloc] initWithData:expectedData
|
||||
encoding:NSUTF8StringEncoding];
|
||||
XCTAssertEqualObjects(expected, result);
|
||||
[expected release];
|
||||
}
|
||||
@@ -195,7 +195,7 @@
|
||||
TestAllTypes *message = [TestAllTypes message];
|
||||
|
||||
NSDictionary *repeatedFieldValues = @{
|
||||
@"repeatedStringArray" : [@[ @"foo", @"bar" ] mutableCopy],
|
||||
@"repeatedStringArray" : [@[@"foo", @"bar"] mutableCopy],
|
||||
@"repeatedBoolArray" : [GPBBoolArray arrayWithValue:YES],
|
||||
@"repeatedInt32Array" : [GPBInt32Array arrayWithValue:14],
|
||||
@"repeatedInt64Array" : [GPBInt64Array arrayWithValue:15],
|
||||
@@ -208,19 +208,23 @@
|
||||
rawValue:TestAllTypes_NestedEnum_Foo],
|
||||
};
|
||||
for (NSString *fieldName in repeatedFieldValues) {
|
||||
GPBFieldDescriptor *field = [message.descriptor fieldWithName:fieldName];
|
||||
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]);
|
||||
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];
|
||||
GPBUnknownFieldSet *result =
|
||||
[[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
|
||||
GPBUnknownField *field = [[[GPBUnknownField alloc] initWithNumber:num] autorelease];
|
||||
GPBUnknownField *field =
|
||||
[[[GPBUnknownField alloc] initWithNumber:num] autorelease];
|
||||
[field addVarint:num];
|
||||
[result addField:field];
|
||||
|
||||
@@ -242,26 +246,32 @@ static GPBUnknownFieldSet *UnknownFieldsSetHelper(int num) {
|
||||
OptionalGroup_extension *optionalGroup = [OptionalGroup_extension message];
|
||||
optionalGroup.a = 123;
|
||||
optionalGroup.unknownFields = UnknownFieldsSetHelper(779);
|
||||
[message setExtension:[UnittestRoot optionalGroupExtension] value:optionalGroup];
|
||||
[message setExtension:[UnittestRoot optionalGroupExtension]
|
||||
value:optionalGroup];
|
||||
|
||||
// Message
|
||||
TestAllTypes_NestedMessage *nestedMessage = [TestAllTypes_NestedMessage message];
|
||||
TestAllTypes_NestedMessage *nestedMessage =
|
||||
[TestAllTypes_NestedMessage message];
|
||||
nestedMessage.bb = 456;
|
||||
nestedMessage.unknownFields = UnknownFieldsSetHelper(778);
|
||||
[message setExtension:[UnittestRoot optionalNestedMessageExtension] value:nestedMessage];
|
||||
[message setExtension:[UnittestRoot optionalNestedMessageExtension]
|
||||
value:nestedMessage];
|
||||
|
||||
// Repeated Group
|
||||
RepeatedGroup_extension *repeatedGroup = [[RepeatedGroup_extension alloc] init];
|
||||
RepeatedGroup_extension *repeatedGroup =
|
||||
[[RepeatedGroup_extension alloc] init];
|
||||
repeatedGroup.a = 567;
|
||||
repeatedGroup.unknownFields = UnknownFieldsSetHelper(780);
|
||||
[message addExtension:[UnittestRoot repeatedGroupExtension] value:repeatedGroup];
|
||||
[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];
|
||||
[message addExtension:[UnittestRoot repeatedNestedMessageExtension]
|
||||
value:nestedMessage];
|
||||
[nestedMessage release];
|
||||
}
|
||||
|
||||
@@ -301,8 +311,7 @@ static GPBUnknownFieldSet *UnknownFieldsSetHelper(int num) {
|
||||
|
||||
{
|
||||
XCTAssertTrue([message hasExtension:[UnittestRoot repeatedNestedMessageExtension]]);
|
||||
NSArray *repeatedNestedMessages =
|
||||
[message getExtension:[UnittestRoot repeatedNestedMessageExtension]];
|
||||
NSArray *repeatedNestedMessages = [message getExtension:[UnittestRoot repeatedNestedMessageExtension]];
|
||||
XCTAssertEqual(repeatedNestedMessages.count, (NSUInteger)1);
|
||||
TestAllTypes_NestedMessage *repeatedNestedMessage = repeatedNestedMessages.firstObject;
|
||||
XCTAssertNotNil(repeatedNestedMessage);
|
||||
@@ -349,14 +358,14 @@ static GPBUnknownFieldSet *UnknownFieldsSetHelper(int num) {
|
||||
|
||||
{
|
||||
XCTAssertTrue([message hasExtension:[UnittestRoot repeatedNestedMessageExtension]]);
|
||||
NSArray *repeatedNestedMessages =
|
||||
[message getExtension:[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 {
|
||||
@@ -405,6 +414,7 @@ static GPBUnknownFieldSet *UnknownFieldsSetHelper(int num) {
|
||||
XCTAssertNotNil(foreignMessage);
|
||||
XCTAssertNil(foreignMessage.unknownFields);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "GPBTestUtilities.h"
|
||||
#import "objectivec/Tests/AnyTest.pbobjc.h"
|
||||
#import "google/protobuf/AnyTest.pbobjc.h"
|
||||
|
||||
// Nanosecond time accuracy
|
||||
static const NSTimeInterval kTimeAccuracy = 1e-9;
|
||||
@@ -46,7 +46,8 @@ static const NSTimeInterval kTimeAccuracy = 1e-9;
|
||||
- (void)testTimeStamp {
|
||||
// Test negative and positive values.
|
||||
NSTimeInterval values[] = {
|
||||
-428027599.483999967, -1234567.0, -0.5, 0, 0.75, 54321.0, 2468086, 483999967};
|
||||
-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];
|
||||
|
||||
@@ -54,24 +55,30 @@ static const NSTimeInterval kTimeAccuracy = 1e-9;
|
||||
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);
|
||||
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,
|
||||
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);
|
||||
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,
|
||||
XCTAssertEqualWithAccuracy(value, timeStamp.timeIntervalSince1970,
|
||||
kTimeAccuracy,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
[timeStamp release];
|
||||
|
||||
@@ -79,10 +86,13 @@ static const NSTimeInterval kTimeAccuracy = 1e-9;
|
||||
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);
|
||||
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,
|
||||
XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970,
|
||||
kTimeAccuracy,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
[timeStamp release];
|
||||
|
||||
@@ -90,10 +100,13 @@ static const NSTimeInterval kTimeAccuracy = 1e-9;
|
||||
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);
|
||||
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,
|
||||
XCTAssertEqualWithAccuracy(value, timeStamp.date.timeIntervalSince1970,
|
||||
kTimeAccuracy,
|
||||
@"Offset %f - Date: %@", (double)value, date);
|
||||
|
||||
[timeStamp release];
|
||||
@@ -102,45 +115,55 @@ static const NSTimeInterval kTimeAccuracy = 1e-9;
|
||||
|
||||
- (void)testDuration {
|
||||
// Test negative and positive values.
|
||||
NSTimeInterval values[] = {-1000.0001, -500.0, -0.5, 0, 0.75, 1000.0, 2000.0002};
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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];
|
||||
TestAny *subMessage = [TestAny message];
|
||||
subMessage.int32Value = 12345;
|
||||
AnyTestMessage *message = [AnyTestMessage message];
|
||||
TestAny *message = [TestAny message];
|
||||
NSError *err = nil;
|
||||
message.anyValue = [GPBAny anyWithMessage:subMessage error:&err];
|
||||
XCTAssertNil(err);
|
||||
@@ -148,13 +171,14 @@ static const NSTimeInterval kTimeAccuracy = 1e-9;
|
||||
NSData *data = message.data;
|
||||
XCTAssertNotNil(data);
|
||||
|
||||
AnyTestMessage *message2 = [AnyTestMessage parseFromData:data error:&err];
|
||||
TestAny *message2 = [TestAny parseFromData:data error:&err];
|
||||
XCTAssertNil(err);
|
||||
XCTAssertNotNil(message2);
|
||||
XCTAssertTrue(message2.hasAnyValue);
|
||||
|
||||
AnyTestMessage *subMessage2 =
|
||||
(AnyTestMessage *)[message.anyValue unpackMessageClass:[AnyTestMessage class] error:&err];
|
||||
TestAny *subMessage2 =
|
||||
(TestAny *)[message.anyValue unpackMessageClass:[TestAny class]
|
||||
error:&err];
|
||||
XCTAssertNil(err);
|
||||
XCTAssertNotNil(subMessage2);
|
||||
XCTAssertEqual(subMessage2.int32Value, 12345);
|
||||
@@ -165,22 +189,25 @@ static const NSTimeInterval kTimeAccuracy = 1e-9;
|
||||
NSData *data2 = message.data;
|
||||
XCTAssertEqualObjects(data2, data);
|
||||
|
||||
AnyTestMessage *subMessage3 =
|
||||
(AnyTestMessage *)[message.anyValue unpackMessageClass:[AnyTestMessage class] error:NULL];
|
||||
TestAny *subMessage3 =
|
||||
(TestAny *)[message.anyValue unpackMessageClass:[TestAny class]
|
||||
error:NULL];
|
||||
XCTAssertNotNil(subMessage3);
|
||||
XCTAssertEqualObjects(subMessage2, subMessage3);
|
||||
|
||||
// Try to extract wrong type.
|
||||
|
||||
GPBTimestamp *wrongMessage =
|
||||
(GPBTimestamp *)[message.anyValue unpackMessageClass:[GPBTimestamp class] error:&err];
|
||||
(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];
|
||||
wrongMessage =
|
||||
(GPBTimestamp *)[message.anyValue unpackMessageClass:[GPBTimestamp class]
|
||||
error:NULL];
|
||||
XCTAssertNil(wrongMessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,9 @@
|
||||
#import "GPBCodedInputStream.h"
|
||||
#import "GPBMessage_PackagePrivate.h"
|
||||
#import "GPBUnknownField_PackagePrivate.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestMset.pbobjc.h"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/UnittestMset.pbobjc.h"
|
||||
#import "google/protobuf/UnittestMsetWireFormat.pbobjc.h"
|
||||
|
||||
@interface WireFormatTests : GPBTestCase
|
||||
@end
|
||||
@@ -54,13 +55,15 @@
|
||||
}
|
||||
|
||||
- (void)testSerializationPacked {
|
||||
TestPackedTypes* message = [self packedSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
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];
|
||||
TestPackedTypes* message2 =
|
||||
[TestPackedTypes parseFromData:rawBytes error:NULL];
|
||||
|
||||
[self assertPackedFieldsSet:message2 repeatedCount:kGPBDefaultRepeatCount];
|
||||
}
|
||||
@@ -70,7 +73,8 @@
|
||||
// so if we serealize a TestAllExtensions then parse it as TestAllTypes
|
||||
// it should work.
|
||||
|
||||
TestAllExtensions* message = [self allExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
TestAllExtensions* message =
|
||||
[self allExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
NSData* rawBytes = message.data;
|
||||
[self assertFieldsInOrder:rawBytes];
|
||||
XCTAssertEqual(message.serializedSize, (size_t)rawBytes.length);
|
||||
@@ -83,11 +87,13 @@
|
||||
- (void)testSerializePackedExtensions {
|
||||
// TestPackedTypes and TestPackedExtensions should have compatible wire
|
||||
// formats; check that they serialize to the same string.
|
||||
TestPackedExtensions* message = [self packedExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
TestPackedExtensions* message =
|
||||
[self packedExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
NSData* rawBytes = message.data;
|
||||
[self assertFieldsInOrder:rawBytes];
|
||||
|
||||
TestPackedTypes* message2 = [self packedSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
TestPackedTypes* message2 =
|
||||
[self packedSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
NSData* rawBytes2 = message2.data;
|
||||
|
||||
XCTAssertEqualObjects(rawBytes, rawBytes2);
|
||||
@@ -111,6 +117,7 @@
|
||||
[self assertAllExtensionsSet:message2 repeatedCount:kGPBDefaultRepeatCount];
|
||||
}
|
||||
|
||||
|
||||
- (void)testExtensionsSerializedSize {
|
||||
size_t allSet = [self allSetRepeatedCount:kGPBDefaultRepeatCount].serializedSize;
|
||||
size_t extensionSet = [self allExtensionsSetRepeatedCount:kGPBDefaultRepeatCount].serializedSize;
|
||||
@@ -119,7 +126,8 @@
|
||||
|
||||
- (void)testParsePackedExtensions {
|
||||
// Ensure that packed extensions can be properly parsed.
|
||||
TestPackedExtensions* message = [self packedExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
TestPackedExtensions* message =
|
||||
[self packedExtensionsSetRepeatedCount:kGPBDefaultRepeatCount];
|
||||
NSData* rawBytes = message.data;
|
||||
[self assertFieldsInOrder:rawBytes];
|
||||
|
||||
@@ -129,74 +137,79 @@
|
||||
extensionRegistry:registry
|
||||
error:NULL];
|
||||
|
||||
[self assertPackedExtensionsSet:message2 repeatedCount:kGPBDefaultRepeatCount];
|
||||
[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"];
|
||||
// Set up a TestMessageSet with two known messages and an unknown one.
|
||||
TestMessageSet* message_set = [TestMessageSet message];
|
||||
[[message_set getExtension:[TestMessageSetExtension1 messageSetExtension]]
|
||||
setI:123];
|
||||
[[message_set getExtension:[TestMessageSetExtension2 messageSetExtension]]
|
||||
setStr:@"foo"];
|
||||
GPBUnknownField* unknownField =
|
||||
[[[GPBUnknownField alloc] initWithNumber:kUnknownTypeId] autorelease];
|
||||
[unknownField addLengthDelimited:[NSData dataWithBytes:"bar" length:3]];
|
||||
GPBUnknownFieldSet* unknownFieldSet = [[[GPBUnknownFieldSet alloc] init] autorelease];
|
||||
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];
|
||||
// Parse back using RawMessageSet and check the contents.
|
||||
RawMessageSet* raw = [RawMessageSet 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);
|
||||
[TestMessageSetExtension1 messageSetExtension].fieldNumber);
|
||||
XCTAssertEqual((uint32_t)[raw.itemArray[1] typeId],
|
||||
[MSetMessageExtension2 messageSetExtension].fieldNumber);
|
||||
[TestMessageSetExtension2 messageSetExtension].fieldNumber);
|
||||
XCTAssertEqual([raw.itemArray[2] typeId], kUnknownTypeId);
|
||||
|
||||
MSetMessageExtension1* message1 =
|
||||
[MSetMessageExtension1 parseFromData:[((MSetRawMessageSet_Item*)raw.itemArray[0]) message]
|
||||
error:NULL];
|
||||
TestMessageSetExtension1* message1 =
|
||||
[TestMessageSetExtension1 parseFromData:[((RawMessageSet_Item*)raw.itemArray[0]) message]
|
||||
error:NULL];
|
||||
XCTAssertEqual(message1.i, 123);
|
||||
|
||||
MSetMessageExtension2* message2 =
|
||||
[MSetMessageExtension2 parseFromData:[((MSetRawMessageSet_Item*)raw.itemArray[1]) message]
|
||||
error:NULL];
|
||||
TestMessageSetExtension2* message2 =
|
||||
[TestMessageSetExtension2 parseFromData:[((RawMessageSet_Item*)raw.itemArray[1]) message]
|
||||
error:NULL];
|
||||
XCTAssertEqualObjects(message2.str, @"foo");
|
||||
|
||||
XCTAssertEqualObjects([raw.itemArray[2] message], [NSData dataWithBytes:"bar" length:3]);
|
||||
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];
|
||||
// Set up a RawMessageSet with two known messages and an unknown one.
|
||||
RawMessageSet* raw = [RawMessageSet message];
|
||||
|
||||
{
|
||||
MSetRawMessageSet_Item* item = [MSetRawMessageSet_Item message];
|
||||
item.typeId = [MSetMessageExtension1 messageSetExtension].fieldNumber;
|
||||
MSetMessageExtension1* message = [MSetMessageExtension1 message];
|
||||
RawMessageSet_Item* item = [RawMessageSet_Item message];
|
||||
item.typeId = [TestMessageSetExtension1 messageSetExtension].fieldNumber;
|
||||
TestMessageSetExtension1* message = [TestMessageSetExtension1 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];
|
||||
RawMessageSet_Item* item = [RawMessageSet_Item message];
|
||||
item.typeId = [TestMessageSetExtension2 messageSetExtension].fieldNumber;
|
||||
TestMessageSetExtension2* message = [TestMessageSetExtension2 message];
|
||||
message.str = @"foo";
|
||||
item.message = [message data];
|
||||
[raw.itemArray addObject:item];
|
||||
}
|
||||
|
||||
{
|
||||
MSetRawMessageSet_Item* item = [MSetRawMessageSet_Item message];
|
||||
RawMessageSet_Item* item = [RawMessageSet_Item message];
|
||||
item.typeId = kUnknownTypeId;
|
||||
item.message = [NSData dataWithBytes:"bar" length:3];
|
||||
[raw.itemArray addObject:item];
|
||||
@@ -204,20 +217,27 @@ const int kUnknownTypeId = 1550055;
|
||||
|
||||
NSData* data = [raw data];
|
||||
|
||||
// Parse as a MSetMessage and check the contents.
|
||||
MSetMessage* messageSet = [MSetMessage parseFromData:data
|
||||
extensionRegistry:[MSetUnittestMsetRoot extensionRegistry]
|
||||
error:NULL];
|
||||
// Parse as a TestMessageSet and check the contents.
|
||||
TestMessageSet* messageSet =
|
||||
[TestMessageSet parseFromData:data
|
||||
extensionRegistry:[UnittestMsetRoot extensionRegistry]
|
||||
error:NULL];
|
||||
|
||||
XCTAssertEqual([[messageSet getExtension:[MSetMessageExtension1 messageSetExtension]] i], 123);
|
||||
XCTAssertEqualObjects([[messageSet getExtension:[MSetMessageExtension2 messageSetExtension]] str],
|
||||
@"foo");
|
||||
XCTAssertEqual(
|
||||
[[messageSet
|
||||
getExtension:[TestMessageSetExtension1 messageSetExtension]] i],
|
||||
123);
|
||||
XCTAssertEqualObjects(
|
||||
[[messageSet
|
||||
getExtension:[TestMessageSetExtension2 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]);
|
||||
XCTAssertEqualObjects(unknownField.lengthDelimitedList[0],
|
||||
[NSData dataWithBytes:"bar" length:3]);
|
||||
}
|
||||
|
||||
- (void)assertFieldsInOrder:(NSData*)data {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//
|
||||
// Use this file to import your target's public headers that you would like to
|
||||
// expose to Swift.
|
||||
// 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"
|
||||
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
|
||||
#import "google/protobuf/UnittestRuntimeProto3.pbobjc.h"
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
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
|
||||
@@ -1,90 +0,0 @@
|
||||
// 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;
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
// 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;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,9 +29,7 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.cycle;
|
||||
|
||||
option objc_class_prefix = "Cycle";
|
||||
package protobuf_unittest;
|
||||
|
||||
// Cycles in the Message graph can cause problems for message class
|
||||
// initialization order.
|
||||
@@ -39,20 +37,20 @@ option objc_class_prefix = "Cycle";
|
||||
// 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 CycleFoo {
|
||||
optional CycleFoo a_foo = 1;
|
||||
optional CycleBar a_bar = 2;
|
||||
optional CycleBaz a_baz = 3;
|
||||
}
|
||||
|
||||
message Bar {
|
||||
optional Bar a_bar = 1;
|
||||
optional Baz a_baz = 2;
|
||||
optional Foo a_foo = 3;
|
||||
message CycleBar {
|
||||
optional CycleBar a_bar = 1;
|
||||
optional CycleBaz a_baz = 2;
|
||||
optional CycleFoo a_foo = 3;
|
||||
}
|
||||
|
||||
message Baz {
|
||||
optional Baz a_baz = 1;
|
||||
optional Foo a_foo = 2;
|
||||
optional Bar a_bar = 3;
|
||||
message CycleBaz {
|
||||
optional CycleBaz a_baz = 1;
|
||||
optional CycleFoo a_foo = 2;
|
||||
optional CycleBar a_bar = 3;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.deprecated;
|
||||
package protobuf_deprecated;
|
||||
option objc_class_prefix = "Dep";
|
||||
|
||||
//
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.deprecated_file;
|
||||
package protobuf_deprecated_file;
|
||||
option objc_class_prefix = "FileDep";
|
||||
|
||||
//
|
||||
|
||||
@@ -29,25 +29,23 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.chain;
|
||||
package protobuf_unittest;
|
||||
|
||||
import "objectivec/Tests/unittest.proto";
|
||||
import "google/protobuf/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";
|
||||
import "unittest_extension_chain_b.proto";
|
||||
import "unittest_extension_chain_c.proto";
|
||||
import "unittest_extension_chain_d.proto";
|
||||
|
||||
// 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;
|
||||
message ChainAMessage {
|
||||
optional ChainBMessage b = 1;
|
||||
optional ChainCMessage c = 2;
|
||||
optional ChainDMessage d = 3;
|
||||
}
|
||||
|
||||
extend objc.protobuf.tests.TestAllExtensions {
|
||||
extend TestAllExtensions {
|
||||
optional int32 chain_a_extension = 10001;
|
||||
}
|
||||
|
||||
@@ -29,21 +29,19 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.chain;
|
||||
package protobuf_unittest;
|
||||
|
||||
import "objectivec/Tests/unittest.proto";
|
||||
import "google/protobuf/unittest.proto";
|
||||
|
||||
import "objectivec/Tests/unittest_extension_chain_c.proto";
|
||||
|
||||
option objc_class_prefix = "Chain";
|
||||
import "unittest_extension_chain_c.proto";
|
||||
|
||||
// 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;
|
||||
message ChainBMessage {
|
||||
optional ChainCMessage c = 1;
|
||||
}
|
||||
|
||||
extend objc.protobuf.tests.TestAllExtensions {
|
||||
extend TestAllExtensions {
|
||||
optional int32 chain_b_extension = 10002;
|
||||
}
|
||||
|
||||
@@ -29,19 +29,17 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.chain;
|
||||
package protobuf_unittest;
|
||||
|
||||
import "objectivec/Tests/unittest.proto";
|
||||
|
||||
option objc_class_prefix = "Chain";
|
||||
import "google/protobuf/unittest.proto";
|
||||
|
||||
// The Root for this file should end up adding the local extension and merging
|
||||
// in the extensions from unittest.proto's Root.
|
||||
|
||||
message CMessage {
|
||||
message ChainCMessage {
|
||||
optional int32 my_field = 1;
|
||||
}
|
||||
|
||||
extend objc.protobuf.tests.TestAllExtensions {
|
||||
extend TestAllExtensions {
|
||||
optional int32 chain_c_extension = 10003;
|
||||
}
|
||||
|
||||
@@ -29,23 +29,21 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.chain;
|
||||
package protobuf_unittest;
|
||||
|
||||
import "objectivec/Tests/unittest.proto";
|
||||
import "google/protobuf/unittest.proto";
|
||||
|
||||
import "objectivec/Tests/unittest_extension_chain_b.proto";
|
||||
import "objectivec/Tests/unittest_extension_chain_c.proto";
|
||||
|
||||
option objc_class_prefix = "Chain";
|
||||
import "unittest_extension_chain_b.proto";
|
||||
import "unittest_extension_chain_c.proto";
|
||||
|
||||
// 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;
|
||||
message ChainDMessage {
|
||||
optional ChainBMessage b = 1;
|
||||
optional ChainCMessage c = 2;
|
||||
}
|
||||
|
||||
extend objc.protobuf.tests.TestAllExtensions {
|
||||
extend TestAllExtensions {
|
||||
optional int32 chain_d_extension = 10004;
|
||||
}
|
||||
|
||||
@@ -29,14 +29,12 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.chain;
|
||||
package protobuf_unittest;
|
||||
|
||||
import "objectivec/Tests/unittest.proto";
|
||||
|
||||
option objc_class_prefix = "Chain";
|
||||
import "google/protobuf/unittest.proto";
|
||||
|
||||
// The Root for this file should end up just merging in unittest's Root.
|
||||
|
||||
message EMessage {
|
||||
message ChainEMessage {
|
||||
optional TestAllTypes my_field = 1;
|
||||
}
|
||||
|
||||
@@ -29,11 +29,9 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.chain;
|
||||
package protobuf_unittest;
|
||||
|
||||
import "objectivec/Tests/unittest_extension_chain_g.proto";
|
||||
|
||||
option objc_class_prefix = "Chain";
|
||||
import "unittest_extension_chain_g.proto";
|
||||
|
||||
// The Root for this file should just be merging in the extensions from C's
|
||||
// Root (because G doesn't define anything itself).
|
||||
@@ -41,6 +39,6 @@ option objc_class_prefix = "Chain";
|
||||
// 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;
|
||||
message ChainFMessage {
|
||||
optional ChainGMessage g = 1;
|
||||
}
|
||||
|
||||
@@ -29,15 +29,13 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.chain;
|
||||
package protobuf_unittest;
|
||||
|
||||
import "objectivec/Tests/unittest_extension_chain_c.proto";
|
||||
|
||||
option objc_class_prefix = "Chain";
|
||||
import "unittest_extension_chain_c.proto";
|
||||
|
||||
// The Root for this file should just be merging in the extensions from C's
|
||||
// Root.
|
||||
|
||||
message GMessage {
|
||||
optional CMessage c = 1;
|
||||
message ChainGMessage {
|
||||
optional ChainCMessage c = 1;
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// 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;
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@@ -30,12 +30,9 @@
|
||||
syntax = "proto2";
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
import "objectivec/Tests/unittest.proto";
|
||||
import "google/protobuf/unittest.proto";
|
||||
|
||||
package objc.protobuf.tests;
|
||||
|
||||
// Explicit empty prefix, tests some validations code paths also.
|
||||
option objc_class_prefix = "";
|
||||
package protobuf_unittest;
|
||||
|
||||
// Used to check that Headerdocs and appledoc work correctly. If these comments
|
||||
// are not handled correctly, Xcode will fail to build the tests.
|
||||
@@ -239,7 +236,8 @@ extend self {
|
||||
repeated sint32 byref = 3004 [packed = true];
|
||||
}
|
||||
|
||||
// Test handing of fields that start with init*.
|
||||
// Test handing of fields that start with init* since Xcode 5's ARC support
|
||||
// doesn't like messages that look like initializers but aren't.
|
||||
message ObjCInitFoo {
|
||||
optional string init_val = 11;
|
||||
optional int32 init_size = 12;
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.options;
|
||||
|
||||
package protobuf_objc_unittest;
|
||||
option objc_class_prefix = "GPBTEST";
|
||||
|
||||
// Verify that enum types and values get the prefix.
|
||||
@@ -60,9 +59,3 @@ message GPBTESTshouldGetAPrefixMessage {
|
||||
// Verify that classes named the same as prefixes are prefixed.
|
||||
message GPBTEST {
|
||||
}
|
||||
|
||||
// Tests that lookup deals with prefix.
|
||||
message PrefixedParentMessage {
|
||||
message Child {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,21 +30,20 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package objc.protobuf.tests.startup;
|
||||
option objc_class_prefix = "TestObjCStartup";
|
||||
package protobuf_objc_unittest;
|
||||
|
||||
message Message {
|
||||
message TestObjCStartupMessage {
|
||||
extensions 1 to max;
|
||||
}
|
||||
|
||||
extend Message {
|
||||
extend TestObjCStartupMessage {
|
||||
// Singular
|
||||
optional int32 optional_int32_extension = 1;
|
||||
repeated int32 repeated_int32_extension = 2;
|
||||
}
|
||||
|
||||
message Nested {
|
||||
extend Message {
|
||||
message TestObjCStartupNested {
|
||||
extend TestObjCStartupMessage {
|
||||
optional string nested_string_extension = 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,7 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
// Explicit empty prefix, tests some validations code paths also.
|
||||
package objc.protobuf.tests;
|
||||
|
||||
option objc_class_prefix = "";
|
||||
package protobuf_unittest;
|
||||
|
||||
message Message2 {
|
||||
enum Enum {
|
||||
|
||||
@@ -29,10 +29,7 @@
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
// Explicit empty prefix, tests some validations code paths also.
|
||||
package objc.protobuf.tests;
|
||||
|
||||
option objc_class_prefix = "";
|
||||
package protobuf_unittest;
|
||||
|
||||
message Message3 {
|
||||
enum Enum {
|
||||
|
||||
Reference in New Issue
Block a user