| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 XCTAssertTrue([fieldDescriptor isValidEnumValue:2]); | 146 XCTAssertTrue([fieldDescriptor isValidEnumValue:2]); |
| 147 XCTAssertTrue([fieldDescriptor isValidEnumValue:3]); | 147 XCTAssertTrue([fieldDescriptor isValidEnumValue:3]); |
| 148 XCTAssertTrue([fieldDescriptor isValidEnumValue:-1]); | 148 XCTAssertTrue([fieldDescriptor isValidEnumValue:-1]); |
| 149 | 149 |
| 150 // Invalid values | 150 // Invalid values |
| 151 XCTAssertFalse([fieldDescriptor isValidEnumValue:4]); | 151 XCTAssertFalse([fieldDescriptor isValidEnumValue:4]); |
| 152 XCTAssertFalse([fieldDescriptor isValidEnumValue:0]); | 152 XCTAssertFalse([fieldDescriptor isValidEnumValue:0]); |
| 153 XCTAssertFalse([fieldDescriptor isValidEnumValue:-2]); | 153 XCTAssertFalse([fieldDescriptor isValidEnumValue:-2]); |
| 154 } | 154 } |
| 155 | 155 |
| 156 - (void)testEnumDescriptorLookup { | |
| 157 GPBDescriptor *descriptor = [TestAllTypes descriptor]; | |
| 158 GPBEnumDescriptor *enumDescriptor = | |
| 159 [descriptor enumWithName:@"TestAllTypes_NestedEnum"]; | |
| 160 XCTAssertNotNil(enumDescriptor); | |
| 161 | |
| 162 // Descriptor cannot find foreign or imported enums. | |
| 163 enumDescriptor = [descriptor enumWithName:@"ForeignEnumEnum"]; | |
| 164 XCTAssertNil(enumDescriptor); | |
| 165 enumDescriptor = [descriptor enumWithName:@"ImportEnumEnum"]; | |
| 166 XCTAssertNil(enumDescriptor); | |
| 167 } | |
| 168 | |
| 169 - (void)testOneofDescriptor { | 156 - (void)testOneofDescriptor { |
| 170 GPBDescriptor *descriptor = [TestOneof2 descriptor]; | 157 GPBDescriptor *descriptor = [TestOneof2 descriptor]; |
| 171 | 158 |
| 172 // All fields should be listed. | 159 // All fields should be listed. |
| 173 XCTAssertEqual(descriptor.fields.count, 17U); | 160 XCTAssertEqual(descriptor.fields.count, 17U); |
| 174 | 161 |
| 175 // There are two oneofs in there. | 162 // There are two oneofs in there. |
| 176 XCTAssertEqual(descriptor.oneofs.count, 2U); | 163 XCTAssertEqual(descriptor.oneofs.count, 2U); |
| 177 | 164 |
| 178 GPBFieldDescriptor *fooStringField = | 165 GPBFieldDescriptor *fooStringField = |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // (pointer comparisions) | 210 // (pointer comparisions) |
| 224 XCTAssertEqual(fooStringField.containingOneof, oneofFoo); | 211 XCTAssertEqual(fooStringField.containingOneof, oneofFoo); |
| 225 XCTAssertEqual(barStringField.containingOneof, oneofBar); | 212 XCTAssertEqual(barStringField.containingOneof, oneofBar); |
| 226 GPBFieldDescriptor *bazString = | 213 GPBFieldDescriptor *bazString = |
| 227 [descriptor fieldWithNumber:TestOneof2_FieldNumber_BazString]; | 214 [descriptor fieldWithNumber:TestOneof2_FieldNumber_BazString]; |
| 228 XCTAssertNotNil(bazString); | 215 XCTAssertNotNil(bazString); |
| 229 XCTAssertNil(bazString.containingOneof); | 216 XCTAssertNil(bazString.containingOneof); |
| 230 } | 217 } |
| 231 | 218 |
| 232 @end | 219 @end |
| OLD | NEW |