From 63d2345372b324e0a9a52946c33b58f172023c93 Mon Sep 17 00:00:00 2001 From: Kurt Revis Date: Mon, 21 Jan 2019 02:46:00 -0800 Subject: [PATCH] Fix testParseCueListWithoutEntries, simplify parseCueItemsData --- .../SnoizeMIDI/SMShowControlUtilities.m | 22 ++----------------- .../SMShowControlUtilitiesTest.m | 4 +--- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/Frameworks/SnoizeMIDI/SMShowControlUtilities.m b/Frameworks/SnoizeMIDI/SMShowControlUtilities.m index 31028089..3a0402bc 100644 --- a/Frameworks/SnoizeMIDI/SMShowControlUtilities.m +++ b/Frameworks/SnoizeMIDI/SMShowControlUtilities.m @@ -47,24 +47,6 @@ SMTimecode parseTimecodeData(NSData *timecodeData) { } NSArray *parseCueItemsData(NSData *cueItemsData) { - NSMutableArray *result = [[NSMutableArray alloc] init]; - NSUInteger length = cueItemsData.length; - - const Byte *bytes = cueItemsData.bytes; - - NSUInteger startIndex = 0; - for (NSUInteger i = 0; i < length; i++) { - Byte currentByte = *(bytes + i); - NSUInteger copyLength = (currentByte != 0x00 ? i - startIndex + 1: i - startIndex); - - if ((currentByte == 0x0 || i == length - 1) && copyLength > 0) { - NSString *cueItemString = [[NSString alloc] initWithBytes:bytes + startIndex length:copyLength encoding:NSASCIIStringEncoding]; - [result addObject:cueItemString]; - [cueItemString release]; - - startIndex = i + 1; - } - } - - return result; + NSString *cueItemString = [[NSString alloc] initWithData:cueItemsData encoding:NSASCIIStringEncoding]; + return cueItemString.length > 0 ? [cueItemString componentsSeparatedByString:@"\0"] : @[]; } diff --git a/Frameworks/SnoizeMIDI/SnoizeMIDITests/SMShowControlUtilitiesTest.m b/Frameworks/SnoizeMIDI/SnoizeMIDITests/SMShowControlUtilitiesTest.m index 3d4b01e7..c3b9267a 100644 --- a/Frameworks/SnoizeMIDI/SnoizeMIDITests/SMShowControlUtilitiesTest.m +++ b/Frameworks/SnoizeMIDI/SnoizeMIDITests/SMShowControlUtilitiesTest.m @@ -95,12 +95,10 @@ - (void)testParseCueListWithFullPathOfOneNumberCues { } - (void)testParseCueListWithoutEntries { - Byte bytes[] = { 0xF7 }; - NSData *testData = [[NSData alloc] initWithBytes:bytes length:sizeof bytes]; + NSData *testData = [NSData data]; NSArray *cues = parseCueItemsData(testData); - // TODO This is failing, returning 1 not 0 XCTAssertEqual([cues count], 0); }