Test -testRezipZippedData is pointless.
dmrev opened this issue · 4 comments
dmrev commented
It tests nil equal to nil.
nicklockwood commented
It does? It shouldn't… it's supposed to check that calling zippedData on already zippedData returns the same value instead of re-applying the zip function.
dmrev commented
- (void)testRezipZippedData
{
//set up data
NSString *inputString = @"Hello World!";
NSData *inputData = [inputString dataUsingEncoding:NSUTF8StringEncoding];
//compress
NSData *compressedData = [inputData gzippedData];
inputString = [[NSString alloc] initWithData:compressedData encoding:NSUTF8StringEncoding]; <-- doesn't make sense, returns nil, on swift - crashes.
//compress again
NSData *outputData = [compressedData gzippedData];
NSString *outputString = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding]; <-- doesn't make sense, returns nil, on swift - crashes.
XCTAssertEqualObjects(outputString, inputString); <-- doesn't make sense.
}
I think, it should be:
func testRezipZippedData() {
// setup
let inputString: NSString = "Hello World!"
let inputData = inputString.dataUsingEncoding(NSUTF8StringEncoding)!
// compress
let compressedData = inputData.gzippedData()!
// compress again
let outputData = compressedData.gzippedData()!
let outputString = NSString(data: outputData.gunzippedData()!, encoding: NSUTF8StringEncoding)
XCTAssertEqual(outputString, inputString)
}
nicklockwood commented
Hmm, you're right. Thanks.
nicklockwood commented
Fixed.