Beispiel #1
0
bool test_erase(Waypoints& waypoints, unsigned id)
{
    waypoints.optimise();
    const Waypoint* wp;
    wp = waypoints.lookup_id(id);
    if (wp== NULL) {
        return false;
    }
    waypoints.erase(*wp);
    waypoints.optimise();

    wp = waypoints.lookup_id(id);
    if (wp!= NULL) {
        return false;
    }
    return true;
}
Beispiel #2
0
unsigned test_copy(Waypoints& waypoints)
{
    const Waypoint *r = waypoints.lookup_id(5);
    if (!r) {
        return false;
    }
    unsigned size_old = waypoints.size();
    Waypoint wp = *r;
    wp.id = waypoints.size()+1;
    waypoints.append(wp);
    waypoints.optimise();
    unsigned size_new = waypoints.size();
    return (size_new == size_old+1);
}
Beispiel #3
0
bool test_replace(Waypoints& waypoints, unsigned id)
{
    const Waypoint* wp;
    wp = waypoints.lookup_id(id);
    if (wp== NULL) {
        return false;
    }
    tstring oldName = wp->Name;

    Waypoint copy = *wp;
    copy.Name= "Fred";
    waypoints.replace(*wp,copy);
    waypoints.optimise();

    wp = waypoints.lookup_id(id);
    if (wp== NULL) {
        return false;
    }
    return (wp->Name != oldName) && (wp->Name == "Fred");
}
Beispiel #4
0
static bool
TestWaypointFile(const TCHAR* filename, Waypoints &way_points, unsigned num_wps)
{
    WaypointReader f(filename, 0);
    if (!ok1(!f.Error())) {
        skip(3, 0, "opening waypoint file failed");
        return false;
    }

    NullOperationEnvironment operation;
    if(!ok1(f.Parse(way_points, operation))) {
        skip(2, 0, "parsing waypoint file failed");
        return false;
    }

    way_points.optimise();

    ok1(!way_points.empty());
    ok1(way_points.size() == num_wps);

    return true;
}
Beispiel #5
0
static bool
TestWayPointFile(const TCHAR* filename, Waypoints &way_points, unsigned num_wps)
{
  WayPointFile *f = WayPointFile::create(filename, 0);
  if (!ok1(f != NULL)) {
    skip(3, 0, "opening waypoint file failed");
    return false;
  }

  if(!ok1(f->Parse(way_points, NULL))) {
    delete f;
    skip(2, 0, "parsing waypoint file failed");
  }

  delete f;

  way_points.optimise();

  ok1(!way_points.empty());
  ok1(way_points.size() == num_wps);

  return true;
}
Beispiel #6
0
/** 
 * Initialises waypoints with random and non-random waypoints
 * for testing
 *
 * @param waypoints waypoints class to add waypoints to
 */
bool setup_waypoints(Waypoints &waypoints, const unsigned n) 
{

  Waypoint wp = waypoints.create(GeoPoint(Angle::degrees(fixed_zero),
                                          Angle::degrees(fixed_zero)));
  wp.Flags.Airport = true;
  wp.Altitude = fixed(0.25);
  waypoints.append(wp);

  wp = waypoints.create(GeoPoint(Angle::degrees(fixed_zero), 
                                 Angle::degrees(fixed_one)));
  wp.Flags.Airport = true;
  wp.Altitude = fixed(0.25);
  waypoints.append(wp);

  wp = waypoints.create(GeoPoint(Angle::degrees(fixed_one), 
                                 Angle::degrees(fixed_one)));
  wp.Name = _T("Hello");
  wp.Flags.Airport = true;
  wp.Altitude = fixed_half;
  waypoints.append(wp);

  wp = waypoints.create(GeoPoint(Angle::degrees(fixed(0.8)), 
                                 Angle::degrees(fixed(0.5))));
  wp.Name = _T("Unk");
  wp.Flags.Airport = true;
  wp.Altitude = fixed(0.25);
  waypoints.append(wp);

  wp = waypoints.create(GeoPoint(Angle::degrees(fixed_one), 
                                 Angle::degrees(fixed_zero)));
  wp.Flags.Airport = true;
  wp.Altitude = fixed(0.25);
  waypoints.append(wp);

  wp = waypoints.create(GeoPoint(Angle::degrees(fixed_zero), 
                                 Angle::degrees(fixed(0.23))));
  wp.Flags.Airport = true;
  wp.Altitude = fixed(0.25);
  waypoints.append(wp);

  for (unsigned i=0; i<(unsigned)std::max((int)n-6,0); i++) {
    int x = rand()%1200-100;
    int y = rand()%1200-100;
    double z = rand()% std::max(terrain_height,1);
    wp = waypoints.create(GeoPoint(Angle::degrees(fixed(x/1000.0)), 
                                   Angle::degrees(fixed(y/1000.0))));
    wp.Flags.Airport = false;
    wp.Altitude = fixed(z);
    waypoints.append(wp);
  }
  waypoints.optimise();

  if (verbose) {
    std::ofstream fin("results/res-wp-in.txt");
    for (unsigned i=1; i<=waypoints.size(); i++) {
      Waypoints::WaypointTree::const_iterator it = waypoints.find_id(i);
      if (it != waypoints.end()) {
#ifdef DO_PRINT
        fin << it->get_waypoint();
#endif
      }
    }
  }
  return true;
}