Skip to content

Commit

Permalink
Fix testParseCueListWithoutEntries, simplify parseCueItemsData
Browse files Browse the repository at this point in the history
  • Loading branch information
krevis committed Jan 21, 2019
1 parent 71ec5b0 commit 2fd9c1a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
22 changes: 2 additions & 20 deletions Frameworks/SnoizeMIDI/SMShowControlUtilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"] : @[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 2fd9c1a

Please sign in to comment.