1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-30 04:50:08 +00:00

Added a few more tests. All passing.

This commit is contained in:
Thomas Harte 2016-12-20 21:46:34 -05:00
parent 03579f33f1
commit 6a0c7f22ee

View File

@ -169,7 +169,7 @@
XCTAssert(total_length == Storage::Time(1), @"Total track length should still be 1");
}
- (void)testMultiReplace
- (void)testMultiTrimBothSideReplace
{
std::shared_ptr<Storage::Disk::Track> patchableTrack = self.fourSegmentPatchedTrack;
Storage::Disk::PCMPatchedTrack *patchable = static_cast<Storage::Disk::PCMPatchedTrack *>(patchableTrack.get());
@ -195,4 +195,56 @@
XCTAssert(total_length == Storage::Time(1), @"Total track length should still be 1");
}
- (void)testMultiTrimRightReplace
{
std::shared_ptr<Storage::Disk::Track> patchableTrack = self.fourSegmentPatchedTrack;
Storage::Disk::PCMPatchedTrack *patchable = static_cast<Storage::Disk::PCMPatchedTrack *>(patchableTrack.get());
Storage::Disk::PCMSegment segment;
segment.data = {0x00};
segment.number_of_bits = 1;
segment.length_of_a_bit.length = 3;
segment.length_of_a_bit.clock_rate = 8;
patchable->add_segment(Storage::Time(1, 8), segment);
Storage::Time total_length;
std::vector<Storage::Disk::Track::Event> events;
while(1)
{
events.push_back(patchableTrack->get_next_event());
total_length += events.back().length;
if(events.back().type == Storage::Disk::Track::Event::IndexHole) break;
}
XCTAssert(events.size() == 21, @"Should still be 17 total events");
XCTAssert(events[4].length == Storage::Time(13, 32), @"Should have added a 13/32 gap after the fourth event");
XCTAssert(total_length == Storage::Time(1), @"Total track length should still be 1");
}
- (void)testMultiTrimLeftReplace
{
std::shared_ptr<Storage::Disk::Track> patchableTrack = self.fourSegmentPatchedTrack;
Storage::Disk::PCMPatchedTrack *patchable = static_cast<Storage::Disk::PCMPatchedTrack *>(patchableTrack.get());
Storage::Disk::PCMSegment segment;
segment.data = {0x00};
segment.number_of_bits = 1;
segment.length_of_a_bit.length = 3;
segment.length_of_a_bit.clock_rate = 8;
patchable->add_segment(Storage::Time(1, 4), segment);
Storage::Time total_length;
std::vector<Storage::Disk::Track::Event> events;
while(1)
{
events.push_back(patchableTrack->get_next_event());
total_length += events.back().length;
if(events.back().type == Storage::Disk::Track::Event::IndexHole) break;
}
XCTAssert(events.size() == 21, @"Should still be 17 total events");
XCTAssert(events[8].length == Storage::Time(13, 32), @"Should have added a 13/32 gap after the eighth event");
XCTAssert(total_length == Storage::Time(1), @"Total track length should still be 1");
}
@end