예제 #1
0
 /**
  * Test calculating the gap between sector times
  */
 public function testCalculatingGapBetweenSectors()
 {
     // Init new laps with times that cause floating point precision
     // problems
     $lap = new Lap();
     $lap->setSectorTimes(array(41.9237, 42.9237, 43.9237));
     $lap2 = new Lap();
     $lap2->setSectorTimes(array(41.9361, 42.936, 43.9362));
     // Validate gap sector 1
     $this->assertSame(0.0124, $lap->getSectorGap($lap2, 1));
     $this->assertSame(-0.0124, $lap2->getSectorGap($lap, 1));
     // Validate gap sector 2
     $this->assertSame(0.0123, $lap->getSectorGap($lap2, 2));
     $this->assertSame(-0.0123, $lap2->getSectorGap($lap, 2));
     // Validate gap sector 3
     $this->assertSame(0.0125, $lap->getSectorGap($lap2, 3));
     $this->assertSame(-0.0125, $lap2->getSectorGap($lap, 3));
     // Unset sector times of lap 2
     $lap2->setSectorTimes(array());
     // Validate
     $this->assertNull($lap->getSectorGap($lap2, 3));
 }