@@ -302,14 +302,7 @@ void show_options(const char* name, const vector<string>& values)
302302};
303303int test (Settings& settings)
304304{
305- const FwiWeather wx_test{settings.get_test_weather ()};
306305 const auto output_directory{settings.output_directory };
307- const auto num_hours{settings.hours };
308- const ptr<const FwiWeather> wx{&wx_test};
309- const auto constant_fuel_name{settings.fuel_name };
310- const auto constant_slope{settings.slope };
311- const auto constant_aspect{settings.aspect };
312- const auto test_all{settings.test_all };
313306 static const AspectSize ASPECT_INCREMENT = 90 ;
314307 static const SlopeSize SLOPE_INCREMENT = 60 ;
315308 static const int WS_INCREMENT = 5 ;
@@ -344,24 +337,20 @@ int test(Settings& settings)
344337 settings.save_points = false ;
345338 // make sure all tests run regardless of how long it takes
346339 settings.maximum_time_seconds = numeric_limits<size_t >::max ();
347- const auto hours = INVALID_TIME == num_hours ? DEFAULT_HOURS : num_hours;
348- const auto ffmc = (fs::Ffmc::Invalid () == wx->ffmc ) ? DEFAULT_FFMC : wx->ffmc ;
349- const auto dmc = (fs::Dmc::Invalid () == wx->dmc ) ? DEFAULT_DMC : wx->dmc ;
350- const auto dc = (fs::Dc::Invalid () == wx->dc ) ? DEFAULT_DC : wx->dc ;
351- // HACK: need to compare value and not object
352- const auto wind_direction = (fs::Direction::Invalid ().value == wx->wind .direction .value )
353- ? DEFAULT_WIND_DIRECTION
354- : wx->wind .direction ;
355- const auto wind_speed =
356- (fs::Speed::Invalid ().value == wx->wind .speed .value ) ? DEFAULT_WIND_SPEED : wx->wind .speed ;
357- const auto wind = fs::Wind{wind_speed, wind_direction};
358- const auto slope = (INVALID_SLOPE == constant_slope) ? DEFAULT_SLOPE : constant_slope;
359- const auto aspect = (INVALID_ASPECT == constant_aspect) ? DEFAULT_ASPECT : constant_aspect;
360- const auto fixed_fuel_name = simplify_fuel_name (constant_fuel_name);
340+ const auto hours{settings.hours .value_or (DEFAULT_HOURS)};
341+ const auto ffmc{settings.ffmc .value_or (DEFAULT_FFMC)};
342+ const auto dmc{settings.dmc .value_or (DEFAULT_DMC)};
343+ const auto dc{settings.dc .value_or (DEFAULT_DC)};
344+ const Direction wind_direction{settings.wind_direction .value_or (DEFAULT_WIND_DIRECTION.value )};
345+ const Speed wind_speed{settings.wind_speed .value_or (DEFAULT_WIND_SPEED.value )};
346+ const Wind wind{wind_speed, wind_direction};
347+ const auto slope{settings.slope .value_or (DEFAULT_SLOPE)};
348+ const auto aspect{settings.aspect .value_or (DEFAULT_ASPECT)};
349+ const auto fixed_fuel_name = simplify_fuel_name (settings.fuel_name .value_or (" " ));
361350 const auto fuel = (fixed_fuel_name.empty () ? DEFAULT_FUEL_NAME : fixed_fuel_name);
362351 try
363352 {
364- if (test_all)
353+ if (settings. test_all . value_or ( false ) )
365354 {
366355 size_t result = 0 ;
367356 // generate all options first so we can say how many there are at start
@@ -378,7 +367,7 @@ int test(Settings& settings)
378367 fuel_names.emplace_back (fuel);
379368 }
380369 auto slopes = vector<SlopeSize>();
381- if (INVALID_SLOPE == constant_slope )
370+ if (!settings. slope . has_value () )
382371 {
383372 for (SlopeSize slope = 0 ; slope <= 100 ; slope += SLOPE_INCREMENT)
384373 {
@@ -387,10 +376,10 @@ int test(Settings& settings)
387376 }
388377 else
389378 {
390- slopes.emplace_back (constant_slope );
379+ slopes.emplace_back (slope );
391380 }
392381 auto aspects = vector<AspectSize>();
393- if (INVALID_ASPECT == constant_aspect )
382+ if (!settings. aspect . has_value () )
394383 {
395384 for (AspectSize aspect = 0 ; aspect < 360 ; aspect += ASPECT_INCREMENT)
396385 {
@@ -399,10 +388,10 @@ int test(Settings& settings)
399388 }
400389 else
401390 {
402- aspects.emplace_back (constant_aspect );
391+ aspects.emplace_back (aspect );
403392 }
404393 auto wind_directions = vector<DirectionSize>();
405- if (fs::Direction::Invalid () == wx-> wind . direction )
394+ if (!settings. wind_direction . has_value () )
406395 {
407396 for (auto wind_direction = 0 ; wind_direction < 360 ; wind_direction += WD_INCREMENT)
408397 {
@@ -411,10 +400,10 @@ int test(Settings& settings)
411400 }
412401 else
413402 {
414- wind_directions.emplace_back (static_cast <int >(wx-> wind . direction . asDegreesSize () ));
403+ wind_directions.emplace_back (static_cast <int >(wind_direction. value ));
415404 }
416405 auto wind_speeds = vector<int >();
417- if (fs::Speed::Invalid () == wx-> wind . speed )
406+ if (!settings. wind_speed . has_value () )
418407 {
419408 for (auto wind_speed = 0 ; wind_speed <= MAX_WIND; wind_speed += WS_INCREMENT)
420409 {
@@ -423,7 +412,7 @@ int test(Settings& settings)
423412 }
424413 else
425414 {
426- wind_speeds.emplace_back (static_cast <int >(wx-> wind . speed .value ));
415+ wind_speeds.emplace_back (static_cast <int >(wind_speed .value ));
427416 }
428417 size_t values = 1 ;
429418 values *= fuel_names.size ();
0 commit comments