コード例 #1
0
ファイル: TestUnitsFormatter.cpp プロジェクト: Advi42/XCSoar
static void
TestRelativeAltitude()
{
  TCHAR buffer[256];

  // Test FormatRelativeAltitude()
  FormatRelativeAltitude(buffer, 1234, Unit::METER);
  ok1(StringIsEqual(buffer, _T("+1234 m")));

  FormatRelativeAltitude(buffer, Units::ToSysUnit(1234, Unit::FEET),
                         Unit::FEET);
  ok1(StringIsEqual(buffer, _T("+1234 ft")));

  FormatRelativeAltitude(buffer, -1234, Unit::METER);
  ok1(StringIsEqual(buffer, _T("-1234 m")));

  FormatRelativeAltitude(buffer, Units::ToSysUnit(-1234, Unit::FEET),
                         Unit::FEET);
  ok1(StringIsEqual(buffer, _T("-1234 ft")));

  FormatRelativeAltitude(buffer, 1234, Unit::METER, false);
  ok1(StringIsEqual(buffer, _T("+1234")));

  FormatRelativeAltitude(buffer, -1234, Unit::METER, false);
  ok1(StringIsEqual(buffer, _T("-1234")));
}
コード例 #2
0
ファイル: UserUnits.cpp プロジェクト: MindMil/XCSoar
void
FormatRelativeUserAltitude(fixed value, TCHAR *buffer, bool include_unit)
{
  FormatRelativeAltitude(buffer, value, Units::GetUserAltitudeUnit(),
                         include_unit);
}