1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Added two more passing tests and one that crashes.

This commit is contained in:
Thomas Harte 2016-12-20 19:25:58 -05:00
parent 823ab9bc34
commit c180340474

View File

@ -56,9 +56,8 @@
- (void)testSingleSplice
{
std::shared_ptr<Storage::Disk::Track> patchableTrack = self.patchableTogglingTrack;
Storage::Disk::PCMPatchedTrack *patchable = dynamic_cast<Storage::Disk::PCMPatchedTrack *>(patchableTrack.get());
if(patchable)
{
Storage::Disk::PCMPatchedTrack *patchable = static_cast<Storage::Disk::PCMPatchedTrack *>(patchableTrack.get());
// add a single one, at 1/32 length at 3/128. So that should shift the location of the second flux transition
Storage::Disk::PCMSegment one_segment;
one_segment.data = {0xff};
@ -66,7 +65,6 @@
one_segment.length_of_a_bit.length = 1;
one_segment.length_of_a_bit.clock_rate = 32;
patchable->add_segment(Storage::Time(3, 128), one_segment);
}
Storage::Time total_length;
std::vector<Storage::Disk::Track::Event> events;
@ -84,4 +82,85 @@
XCTAssert(total_length == Storage::Time(1), @"Total track length should still be 1");
}
- (void)testLeftReplace
{
std::shared_ptr<Storage::Disk::Track> patchableTrack = self.patchableTogglingTrack;
Storage::Disk::PCMPatchedTrack *patchable = static_cast<Storage::Disk::PCMPatchedTrack *>(patchableTrack.get());
Storage::Disk::PCMSegment zero_segment;
zero_segment.data = {0x00};
zero_segment.number_of_bits = 8;
zero_segment.length_of_a_bit.length = 1;
zero_segment.length_of_a_bit.clock_rate = 16;
patchable->add_segment(Storage::Time(0), zero_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() == 17, @"Should still be 17 total events");
XCTAssert(events[0].length == Storage::Time(33, 64), @"First event should not occur until 33/64");
XCTAssert(total_length == Storage::Time(1), @"Total track length should still be 1");
}
- (void)testRightReplace
{
std::shared_ptr<Storage::Disk::Track> patchableTrack = self.patchableTogglingTrack;
Storage::Disk::PCMPatchedTrack *patchable = static_cast<Storage::Disk::PCMPatchedTrack *>(patchableTrack.get());
Storage::Disk::PCMSegment zero_segment;
zero_segment.data = {0x00};
zero_segment.number_of_bits = 8;
zero_segment.length_of_a_bit.length = 1;
zero_segment.length_of_a_bit.clock_rate = 16;
patchable->add_segment(Storage::Time(1, 2), zero_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() == 17, @"Should still be 17 total events");
XCTAssert(events[16].length == Storage::Time(33, 64), @"Final event should take 33/64");
XCTAssert(total_length == Storage::Time(1), @"Total track length should still be 1");
}
- (void)testMultiReplace
{
std::shared_ptr<Storage::Disk::Track> patchableTrack = self.patchableTogglingTrack;
Storage::Disk::PCMPatchedTrack *patchable = static_cast<Storage::Disk::PCMPatchedTrack *>(patchableTrack.get());
for(int c = 0; c < 4; c++)
{
Storage::Disk::PCMSegment segment;
segment.data = {0xff};
segment.number_of_bits = 8;
segment.length_of_a_bit.length = 1;
segment.length_of_a_bit.clock_rate = 32;
patchable->add_segment(Storage::Time(c, 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() == 17, @"Should still be 17 total events");
XCTAssert(events[16].length == Storage::Time(33, 64), @"Final event should take 33/64");
XCTAssert(total_length == Storage::Time(1), @"Total track length should still be 1");
}
@end