static void TestBasic() { // Test ReadString() PolarInfo polar; ParsePolar(polar, "318, 100, 80, -0.606, 120, -0.99, 160, -1.918"); ok1(equals(fixed(polar.reference_mass), 318)); ok1(equals(fixed(polar.max_ballast), 100)); ok1(equals(fixed(polar.shape[0].v), 22.2222222)); ok1(equals(fixed(polar.shape[0].w), -0.606)); ok1(equals(fixed(polar.shape[1].v), 33.3333333)); ok1(equals(fixed(polar.shape[1].w), -0.99)); ok1(equals(fixed(polar.shape[2].v), 44.4444444)); ok1(equals(fixed(polar.shape[2].w), -1.918)); ok1(equals(fixed(polar.wing_area), 0.0)); ParsePolar(polar, "318, 100, 80, -0.606, 120, -0.99, 160, -1.918, 9.8"); ok1(equals(fixed(polar.reference_mass), 318)); ok1(equals(fixed(polar.max_ballast), 100)); ok1(equals(fixed(polar.shape[0].v), 22.2222222)); ok1(equals(fixed(polar.shape[0].w), -0.606)); ok1(equals(fixed(polar.shape[1].v), 33.3333333)); ok1(equals(fixed(polar.shape[1].w), -0.99)); ok1(equals(fixed(polar.shape[2].v), 44.4444444)); ok1(equals(fixed(polar.shape[2].w), -1.918)); ok1(equals(fixed(polar.wing_area), 9.8)); // Test GetString() char polar_string[255]; FormatPolar(polar, polar_string, 255); ok(strcmp("318,100,80.000,-0.606,120.000,-0.990,160.000,-1.918,9.800", polar_string) == 0, "GetString()"); }
bool PolarGlue::LoadFromFile(PolarInfo &polar, NLineReader &reader) { const char *line; while ((line = reader.ReadLine()) != nullptr) if (ParsePolar(polar, line)) return true; return false; }
bool PolarGlue::LoadFromProfile(PolarInfo &polar) { const char *polar_string = Profile::Get(ProfileKeys::Polar); if (polar_string != nullptr && !StringIsEmpty(polar_string) && ParsePolar(polar, polar_string)) { return true; } return LoadFromOldProfile(polar); }