File tree Expand file tree Collapse file tree 3 files changed +21
-10
lines changed
Firebase/CoreDiagnostics/FIRCDLibrary
GoogleDataTransportCCTSupport Expand file tree Collapse file tree 3 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -236,12 +236,12 @@ + (NSString *)deviceModel {
236
236
* @param data The data to copy into the new bytes array.
237
237
*/
238
238
pb_bytes_array_t *FIREncodeData (NSData *data) {
239
- pb_bytes_array_t *pbBytes = calloc (1 , PB_BYTES_ARRAY_T_ALLOCSIZE (data.length ));
240
- if (pbBytes != NULL ) {
241
- [data getBytes: pbBytes range: NSMakeRange ( 0 , data.length) ];
242
- pbBytes ->size = (pb_size_t )data.length ;
239
+ pb_bytes_array_t *pbBytesArray = calloc (1 , PB_BYTES_ARRAY_T_ALLOCSIZE (data.length ));
240
+ if (pbBytesArray != NULL ) {
241
+ [data getBytes: pbBytesArray->bytes length: data.length];
242
+ pbBytesArray ->size = (pb_size_t )data.length ;
243
243
}
244
- return pbBytes ;
244
+ return pbBytesArray ;
245
245
}
246
246
247
247
/* * Maps a service string to the representative nanopb enum.
Original file line number Diff line number Diff line change 43
43
}
44
44
45
45
pb_bytes_array_t *GDTCCTEncodeData (NSData *data) {
46
- pb_bytes_array_t *pbBytes = calloc (1 , PB_BYTES_ARRAY_T_ALLOCSIZE (data.length ));
47
- if (pbBytes != NULL ) {
48
- [data getBytes: pbBytes range: NSMakeRange ( 0 , data.length) ];
49
- pbBytes ->size = (pb_size_t )data.length ;
46
+ pb_bytes_array_t *pbBytesArray = calloc (1 , PB_BYTES_ARRAY_T_ALLOCSIZE (data.length ));
47
+ if (pbBytesArray != NULL ) {
48
+ [data getBytes: pbBytesArray->bytes length: data.length];
49
+ pbBytesArray ->size = (pb_size_t )data.length ;
50
50
}
51
- return pbBytes ;
51
+ return pbBytesArray ;
52
52
}
53
53
54
54
#pragma mark - CCT object constructors
Original file line number Diff line number Diff line change @@ -161,4 +161,15 @@ - (void)testEncodingProtoAboveDefaultOSThreshold {
161
161
pb_release (gdt_cct_BatchedLogRequest_fields, &batch);
162
162
}
163
163
164
+ - (void )testSimpleByteEncodingConsistency {
165
+ NSData *data = [@" Simple." dataUsingEncoding: NSUTF8StringEncoding];
166
+ pb_bytes_array_t *bytesArray = GDTCCTEncodeData (data);
167
+ XCTAssertEqual (bytesArray->size , data.length );
168
+ XCTAssertTrue (bytesArray->bytes );
169
+ XCTAssertEqualObjects ([[NSString alloc ] initWithBytes: bytesArray->bytes
170
+ length: bytesArray->size
171
+ encoding: NSUTF8StringEncoding],
172
+ @" Simple." );
173
+ }
174
+
164
175
@end
You can’t perform that action at this time.
0 commit comments