Add test for failing write of raw pointer to output stream

pull/4370/head
Felix Jendrusch 7 years ago
parent a48d58df96
commit 38508e9bbb
  1. 10
      objectivec/Tests/GPBCodedOuputStreamTests.m

@ -423,4 +423,14 @@
}
}
- (void)testThatItThrowsWhenWriteRawPtrFails {
NSOutputStream *output = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream *codedOutput =
[GPBCodedOutputStream streamWithOutputStream:output bufferSize:0]; // Skip buffering.
[output close]; // Close the output stream to force failure on write.
const char *cString = "raw";
XCTAssertThrowsSpecificNamed([codedOutput writeRawPtr:cString offset:0 length:strlen(cString)],
NSException, GPBCodedOutputStreamException_WriteFailed);
}
@end

Loading…
Cancel
Save