2016-12-17 22:05:49 +00:00
|
|
|
//
|
|
|
|
// PCMPatchedTrackTests.m
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 17/12/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "PCMPatchedTrackTests.h"
|
|
|
|
|
|
|
|
#include "PCMTrack.hpp"
|
|
|
|
#include "PCMPatchedTrack.hpp"
|
|
|
|
|
|
|
|
@implementation PCMPatchedTrackTests
|
|
|
|
|
2016-12-17 23:17:22 +00:00
|
|
|
- (std::shared_ptr<Storage::Disk::Track>)togglingTrack
|
2016-12-17 22:05:49 +00:00
|
|
|
{
|
|
|
|
Storage::Disk::PCMSegment segment;
|
|
|
|
segment.data = { 0xff, 0xff, 0xff, 0xff };
|
|
|
|
segment.number_of_bits = 32;
|
2016-12-17 23:17:22 +00:00
|
|
|
return std::shared_ptr<Storage::Disk::Track>(new Storage::Disk::PCMTrack(segment));
|
2016-12-17 22:05:49 +00:00
|
|
|
}
|
|
|
|
|
2016-12-17 23:17:22 +00:00
|
|
|
- (std::shared_ptr<Storage::Disk::Track>)patchableTogglingTrack
|
2016-12-17 22:05:49 +00:00
|
|
|
{
|
2016-12-17 23:17:22 +00:00
|
|
|
std::shared_ptr<Storage::Disk::Track> track = self.togglingTrack;
|
|
|
|
return std::shared_ptr<Storage::Disk::Track>(new Storage::Disk::PCMPatchedTrack(track));
|
|
|
|
}
|
2016-12-17 22:05:49 +00:00
|
|
|
|
2016-12-17 23:17:22 +00:00
|
|
|
- (void)assertOneThirtyTwosForTrack:(std::shared_ptr<Storage::Disk::Track>)track
|
|
|
|
{
|
2016-12-17 22:05:49 +00:00
|
|
|
// Confirm that there are now flux transitions (just the first five will do)
|
|
|
|
// located 1/32nd of a rotation apart.
|
|
|
|
int c = 5;
|
|
|
|
while(c--)
|
|
|
|
{
|
2016-12-17 23:17:22 +00:00
|
|
|
Storage::Disk::Track::Event event = track->get_next_event();
|
2016-12-17 22:05:49 +00:00
|
|
|
Storage::Time simplified_time = event.length.simplify();
|
|
|
|
XCTAssert(simplified_time.length == 1 && simplified_time.clock_rate == 32, "flux transitions should be 1/32nd of a track apart");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-17 23:17:22 +00:00
|
|
|
- (void)testUnpatchedRawTrack
|
|
|
|
{
|
|
|
|
[self assertOneThirtyTwosForTrack:self.togglingTrack];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)testUnpatchedTrack
|
|
|
|
{
|
|
|
|
[self assertOneThirtyTwosForTrack:self.patchableTogglingTrack];
|
|
|
|
}
|
|
|
|
|
2016-12-17 22:05:49 +00:00
|
|
|
@end
|