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

Side by Side Diff: third_party/protobuf/objectivec/Tests/GPBMessageTests.m

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 1164
1165 // Simply accessing the map should not make any fields visible. 1165 // Simply accessing the map should not make any fields visible.
1166 XCTAssertNotNil(message.a.a.iToI); 1166 XCTAssertNotNil(message.a.a.iToI);
1167 XCTAssertFalse([message hasA]); 1167 XCTAssertFalse([message hasA]);
1168 XCTAssertFalse([message.a hasA]); 1168 XCTAssertFalse([message.a hasA]);
1169 XCTAssertNotNil(message2.a.a.strToStr); 1169 XCTAssertNotNil(message2.a.a.strToStr);
1170 XCTAssertFalse([message2 hasA]); 1170 XCTAssertFalse([message2 hasA]);
1171 XCTAssertFalse([message2.a hasA]); 1171 XCTAssertFalse([message2.a hasA]);
1172 1172
1173 // But adding an element to the map should. 1173 // But adding an element to the map should.
1174 [message.a.a.iToI setValue:100 forKey:200]; 1174 [message.a.a.iToI setInt32:100 forKey:200];
1175 XCTAssertTrue([message hasA]); 1175 XCTAssertTrue([message hasA]);
1176 XCTAssertTrue([message.a hasA]); 1176 XCTAssertTrue([message.a hasA]);
1177 XCTAssertEqual([message.a.a.iToI count], (NSUInteger)1); 1177 XCTAssertEqual([message.a.a.iToI count], (NSUInteger)1);
1178 [message2.a.a.strToStr setObject:@"foo" forKey:@"bar"]; 1178 [message2.a.a.strToStr setObject:@"foo" forKey:@"bar"];
1179 XCTAssertTrue([message2 hasA]); 1179 XCTAssertTrue([message2 hasA]);
1180 XCTAssertTrue([message2.a hasA]); 1180 XCTAssertTrue([message2.a hasA]);
1181 XCTAssertEqual([message2.a.a.strToStr count], (NSUInteger)1); 1181 XCTAssertEqual([message2.a.a.strToStr count], (NSUInteger)1);
1182 } 1182 }
1183 1183
1184 - (void)testAutocreatedMapShared { 1184 - (void)testAutocreatedMapShared {
1185 // Multiple objects pointing to the same map. 1185 // Multiple objects pointing to the same map.
1186 TestRecursiveMessageWithRepeatedField *message1a = 1186 TestRecursiveMessageWithRepeatedField *message1a =
1187 [TestRecursiveMessageWithRepeatedField message]; 1187 [TestRecursiveMessageWithRepeatedField message];
1188 TestRecursiveMessageWithRepeatedField *message1b = 1188 TestRecursiveMessageWithRepeatedField *message1b =
1189 [TestRecursiveMessageWithRepeatedField message]; 1189 [TestRecursiveMessageWithRepeatedField message];
1190 message1a.a.iToI = message1b.a.iToI; 1190 message1a.a.iToI = message1b.a.iToI;
1191 XCTAssertTrue([message1a hasA]); 1191 XCTAssertTrue([message1a hasA]);
1192 XCTAssertFalse([message1b hasA]); 1192 XCTAssertFalse([message1b hasA]);
1193 [message1a.a.iToI setValue:1 forKey:2]; 1193 [message1a.a.iToI setInt32:1 forKey:2];
1194 XCTAssertTrue([message1a hasA]); 1194 XCTAssertTrue([message1a hasA]);
1195 XCTAssertTrue([message1b hasA]); 1195 XCTAssertTrue([message1b hasA]);
1196 XCTAssertEqual(message1a.a.iToI, message1b.a.iToI); 1196 XCTAssertEqual(message1a.a.iToI, message1b.a.iToI);
1197 1197
1198 TestRecursiveMessageWithRepeatedField *message2a = 1198 TestRecursiveMessageWithRepeatedField *message2a =
1199 [TestRecursiveMessageWithRepeatedField message]; 1199 [TestRecursiveMessageWithRepeatedField message];
1200 TestRecursiveMessageWithRepeatedField *message2b = 1200 TestRecursiveMessageWithRepeatedField *message2b =
1201 [TestRecursiveMessageWithRepeatedField message]; 1201 [TestRecursiveMessageWithRepeatedField message];
1202 message2a.a.strToStr = message2b.a.strToStr; 1202 message2a.a.strToStr = message2b.a.strToStr;
1203 XCTAssertTrue([message2a hasA]); 1203 XCTAssertTrue([message2a hasA]);
(...skipping 13 matching lines...) Expand all
1217 TestRecursiveMessageWithRepeatedField *message2 = 1217 TestRecursiveMessageWithRepeatedField *message2 =
1218 [[message copy] autorelease]; 1218 [[message copy] autorelease];
1219 // Pointer conparisions. 1219 // Pointer conparisions.
1220 XCTAssertNotEqual(message.strToStr, message2.strToStr); 1220 XCTAssertNotEqual(message.strToStr, message2.strToStr);
1221 XCTAssertNotEqual(message.iToI, message2.iToI); 1221 XCTAssertNotEqual(message.iToI, message2.iToI);
1222 1222
1223 // Mutable copy should copy empty arrays that were explicitly set (end up 1223 // Mutable copy should copy empty arrays that were explicitly set (end up
1224 // with different objects that are equal). 1224 // with different objects that are equal).
1225 TestRecursiveMessageWithRepeatedField *message3 = 1225 TestRecursiveMessageWithRepeatedField *message3 =
1226 [TestRecursiveMessageWithRepeatedField message]; 1226 [TestRecursiveMessageWithRepeatedField message];
1227 message3.iToI = [GPBInt32Int32Dictionary dictionaryWithValue:10 forKey:20]; 1227 message3.iToI = [GPBInt32Int32Dictionary dictionaryWithInt32:10 forKey:20];
1228 message3.strToStr = 1228 message3.strToStr =
1229 [NSMutableDictionary dictionaryWithObject:@"abc" forKey:@"123"]; 1229 [NSMutableDictionary dictionaryWithObject:@"abc" forKey:@"123"];
1230 XCTAssertNotNil(message.iToI); 1230 XCTAssertNotNil(message.iToI);
1231 XCTAssertNotNil(message.iToI); 1231 XCTAssertNotNil(message.iToI);
1232 TestRecursiveMessageWithRepeatedField *message4 = 1232 TestRecursiveMessageWithRepeatedField *message4 =
1233 [[message3 copy] autorelease]; 1233 [[message3 copy] autorelease];
1234 XCTAssertNotEqual(message3.iToI, message4.iToI); 1234 XCTAssertNotEqual(message3.iToI, message4.iToI);
1235 XCTAssertEqualObjects(message3.iToI, message4.iToI); 1235 XCTAssertEqualObjects(message3.iToI, message4.iToI);
1236 XCTAssertNotEqual(message3.strToStr, message4.strToStr); 1236 XCTAssertNotEqual(message3.strToStr, message4.strToStr);
1237 XCTAssertEqualObjects(message3.strToStr, message4.strToStr); 1237 XCTAssertEqualObjects(message3.strToStr, message4.strToStr);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 // Replacing map should orphan the old one and cause its creator to become 1285 // Replacing map should orphan the old one and cause its creator to become
1286 // visible. 1286 // visible.
1287 { 1287 {
1288 TestRecursiveMessageWithRepeatedField *message = 1288 TestRecursiveMessageWithRepeatedField *message =
1289 [TestRecursiveMessageWithRepeatedField message]; 1289 [TestRecursiveMessageWithRepeatedField message];
1290 XCTAssertNotNil(message.a); 1290 XCTAssertNotNil(message.a);
1291 XCTAssertNotNil(message.a.iToI); 1291 XCTAssertNotNil(message.a.iToI);
1292 XCTAssertFalse([message hasA]); 1292 XCTAssertFalse([message hasA]);
1293 GPBInt32Int32Dictionary *iToI = [message.a.iToI retain]; 1293 GPBInt32Int32Dictionary *iToI = [message.a.iToI retain];
1294 XCTAssertEqual(iToI->_autocreator, message.a); // Pointer comparision 1294 XCTAssertEqual(iToI->_autocreator, message.a); // Pointer comparision
1295 message.a.iToI = [GPBInt32Int32Dictionary dictionaryWithValue:6 forKey:7]; 1295 message.a.iToI = [GPBInt32Int32Dictionary dictionaryWithInt32:6 forKey:7];
1296 XCTAssertTrue([message hasA]); 1296 XCTAssertTrue([message hasA]);
1297 XCTAssertNotEqual(message.a.iToI, iToI); // Pointer comparision 1297 XCTAssertNotEqual(message.a.iToI, iToI); // Pointer comparision
1298 XCTAssertNil(iToI->_autocreator); 1298 XCTAssertNil(iToI->_autocreator);
1299 [iToI release]; 1299 [iToI release];
1300 } 1300 }
1301 1301
1302 { 1302 {
1303 TestRecursiveMessageWithRepeatedField *message = 1303 TestRecursiveMessageWithRepeatedField *message =
1304 [TestRecursiveMessageWithRepeatedField message]; 1304 [TestRecursiveMessageWithRepeatedField message];
1305 XCTAssertNotNil(message.a); 1305 XCTAssertNotNil(message.a);
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 // And when set to different values. 2013 // And when set to different values.
2014 msg1.boolField2 = YES; 2014 msg1.boolField2 = YES;
2015 XCTAssertNotEqualObjects(msg1Prime, msg1); 2015 XCTAssertNotEqualObjects(msg1Prime, msg1);
2016 // And then they match again. 2016 // And then they match again.
2017 msg1.boolField2 = NO; 2017 msg1.boolField2 = NO;
2018 XCTAssertEqualObjects(msg1Prime, msg1); 2018 XCTAssertEqualObjects(msg1Prime, msg1);
2019 XCTAssertEqual([msg1 hash], [msg1Prime hash]); 2019 XCTAssertEqual([msg1 hash], [msg1Prime hash]);
2020 } 2020 }
2021 2021
2022 @end 2022 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698