&sectionHeader('Unit Tests for Basic Functions (50 points)');
$subtotal = 0;
@SOURCE = ();
@LINK = ();
$subtotal = &runTest('001', 'track_create and track_destroy');
$subtotal += &runTest('002', 'track_add and track_get (matching timestamps)');
$subtotal += &runTest('003', 'track_add with nonincreasing timestamps');
$subtotal += &runTest('004', 'track_size');
$subtotal += &runTest('005', 'track_length (non-empty)');
$subtotal += &runTest('006', 'track_length (empty track)');
$subtotal += &runTest('007', 'track_get interpolated points');
$subtotal += &runTest('008', 'track_get out of bounds (too early)');
$subtotal += &runTest('009', 'track_for_each');
$subtotal = $subtotal * 50 / 9;
$total += floor($subtotal);
&sectionResults('Unit Tests for Basic Functions (50 points)', $subtotal, 9, $checkpoint );
$testCount += 9;

&sectionHeader('Unit Tests for track_merge (25 points)');
$subtotal = 0;
@SOURCE = ();
@LINK = ();
$subtotal = &runTest('010', 'Disjoint tracks');
$subtotal += &runTest('011', 'Overlap but distinct timestamps');
$subtotal += &runTest('012', 'Duplicate trackpoints');
$subtotal += &runTest('013', 'Conflicting trackpoints');
$subtotal = $subtotal * 25 / 4;
my $merge_subtotal = $subtotal;
$total += floor($subtotal);
&sectionResults('Unit Tests for track_merge (25 points)', $subtotal, 4, $checkpoint );
$testCount += 4;

&sectionHeader('Valgrind for Unit Tests (25 points; not awarded to do-nothing submissions)');
$subtotal = 0;
@SOURCE = ();
@LINK = ();
$subtotal = &runTest('014', 'track_add and track_get');
$subtotal += &runTest('015', 'track_get interpolated points');
$subtotal += &runTest('016', 'track_get out of bounds (too early)');
if ($merge_subtotal > 0) {
$subtotal += &runTest('017', 'track_merge: disjoint tracks');
}
else {
skipTest('017', 'track_merge: disjoint tracks');
}
if ($merge_subtotal > 0) {
$subtotal += &runTest('018', 'track_merge: overlap but distinct timestamps');
}
else {
skipTest('018', 'track_merge: overlap but distinct timestamps');
}
if ($merge_subtotal > 0) {
$subtotal += &runTest('019', 'track_merge: duplicate trackpoints');
}
else {
skipTest('019', 'track_merge: duplicate trackpoints');
}
if ($merge_subtotal > 0) {
$subtotal += &runTest('020', 'track_merge: conflicting trackpoints');
}
else {
skipTest('020', 'track_merge: conflicting trackpoints');
}
$subtotal = $subtotal * 25 / 7;
$subtotal = $total > 20 ? $subtotal : 0;
$total += floor($subtotal);
&sectionResults('Valgrind for Unit Tests (25 points; not awarded to do-nothing submissions)', $subtotal, 7, $checkpoint );
$testCount += 7;

&sectionHeader('Unit Tests for track_closest_approach');
$subtotal = 0;
@SOURCE = ();
@LINK = ();
$subtotal = &runTest('021', 'track_closest_approach');
$subtotal += &runTest('022', 'valgrind');
$checkpoint = $total;
$total = 0;
$testCount = 0;
$total += floor($subtotal);
&sectionResults('Unit Tests for track_closest_approach', $subtotal, 2, $checkpoint );
$testCount += 2;

&sectionHeader('GPS Executable');
$subtotal = 0;
@SOURCE = ();
@LINK = ();
$subtotal = &runTest('023', '-combine');
$subtotal += &runTest('024', '-closest');
$subtotal += &runTest('025', '-combine with valgrind');
$subtotal += &runTest('026', '-closest with valgrind');
$total += floor($subtotal);
&sectionResults('GPS Executable', $subtotal, 4, $checkpoint );
$testCount += 4;

&sectionHeader('Invalid Inputs');
$subtotal = 0;
@SOURCE = ();
@LINK = ();
$subtotal = &runTest('027', 'No arguments');
$subtotal += &runTest('028', 'Missing filename');
$subtotal += &runTest('029', 'File not found');
$subtotal += &runTest('030', 'Latitude out of range');
$subtotal += &runTest('031', 'Invalid longitude');
$subtotal += &runTest('032', 'Missing timestamp');
$subtotal += &runTest('033', 'Extra whitespace');
$subtotal += &runTest('034', 'EOF after longitude');
$total += floor($subtotal);
&sectionResults('Invalid Inputs', $subtotal, 8, $checkpoint );
$testCount += 8;

&sectionHeader('Timing');
$subtotal = 0;
@SOURCE = ();
@LINK = ();
$subtotal = &runTest('035', 'track_merge');
$total += floor($subtotal);
&sectionResults('Timing', $subtotal, 1, $checkpoint );
$testCount += 1;

