From 6a0c7f22eeaf48a4e75ebc842d8d8f0905773206 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 20 Dec 2016 21:46:34 -0500 Subject: [PATCH] Added a few more tests. All passing. --- .../Clock SignalTests/PCMPatchedTrackTests.mm | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/OSBindings/Mac/Clock SignalTests/PCMPatchedTrackTests.mm b/OSBindings/Mac/Clock SignalTests/PCMPatchedTrackTests.mm index 41120fedf..900eb2554 100644 --- a/OSBindings/Mac/Clock SignalTests/PCMPatchedTrackTests.mm +++ b/OSBindings/Mac/Clock SignalTests/PCMPatchedTrackTests.mm @@ -169,7 +169,7 @@ XCTAssert(total_length == Storage::Time(1), @"Total track length should still be 1"); } -- (void)testMultiReplace +- (void)testMultiTrimBothSideReplace { std::shared_ptr patchableTrack = self.fourSegmentPatchedTrack; Storage::Disk::PCMPatchedTrack *patchable = static_cast(patchableTrack.get()); @@ -195,4 +195,56 @@ XCTAssert(total_length == Storage::Time(1), @"Total track length should still be 1"); } +- (void)testMultiTrimRightReplace +{ + std::shared_ptr patchableTrack = self.fourSegmentPatchedTrack; + Storage::Disk::PCMPatchedTrack *patchable = static_cast(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 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 patchableTrack = self.fourSegmentPatchedTrack; + Storage::Disk::PCMPatchedTrack *patchable = static_cast(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 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