Browse Source

reorganize test configs: 1:1 mapping with test files

- Move all configs from tests/configs/ to tests/
- Rename configs to match test filenames (test_NAME.toml)
- Remove unused configs (earth_mars_simple, simple_root_transition, interplanetary_transfer)
- Combine earth_circular and mars_circular into test_orbital_period.toml
- Duplicate earth_circular.toml as test_energy.toml
- Remove invalid parent test case from test_invalid_parent_assignment.cpp
- Update all test files to reference new config paths
- Delete tests/configs/ directory
main
cinnaboot 6 months ago
parent
commit
f79ae5ac84
  1. 50
      tests/configs/earth_mars_simple.toml
  2. 54
      tests/configs/interplanetary_transfer.toml
  3. 27
      tests/configs/mars_circular.toml
  4. 2
      tests/test_energy.cpp
  5. 0
      tests/test_energy.toml
  6. 6
      tests/test_hyperbolic_orbit.cpp
  7. 0
      tests/test_hyperbolic_orbit.toml
  8. 49
      tests/test_invalid_parent_assignment.cpp
  9. 0
      tests/test_invalid_parent_assignment.toml
  10. 10
      tests/test_maneuver_planning.cpp
  11. 0
      tests/test_maneuver_planning.toml
  12. 12
      tests/test_maneuvers.cpp
  13. 0
      tests/test_maneuvers.toml
  14. 8
      tests/test_moon_orbits.cpp
  15. 0
      tests/test_moon_orbits.toml
  16. 8
      tests/test_orbital_period.cpp
  17. 21
      tests/test_orbital_period.toml
  18. 4
      tests/test_parabolic_orbit.cpp
  19. 0
      tests/test_parabolic_orbit.toml
  20. 4
      tests/test_root_body_transitions.cpp
  21. 0
      tests/test_root_body_transitions.toml
  22. 4
      tests/test_soi_transition.cpp
  23. 0
      tests/test_soi_transition.toml

50
tests/configs/earth_mars_simple.toml

@ -1,50 +0,0 @@
[[bodies]]
name = "Sun"
mass = 1.989e30
radius = 6.96e8
parent_index = -1
color = { r = 1.0, g = 1.0, b = 0.0 }
orbit = {
semi_major_axis = 0.0,
eccentricity = 0.0,
true_anomaly = 0.0
}
[[bodies]]
name = "Earth"
mass = 5.972e24
radius = 6.371e6
parent_index = 0
color = { r = 0.0, g = 0.5, b = 1.0 }
orbit = {
semi_major_axis = 1.496e11,
eccentricity = 0.0,
true_anomaly = 0.0
}
[[bodies]]
name = "Mars"
mass = 6.39e23
radius = 3.3895e6
parent_index = 0
color = { r = 0.8, g = 0.3, b = 0.1 }
orbit = {
semi_major_axis = 2.279e11,
eccentricity = 0.0,
true_anomaly = 0.0
}
[[bodies]]
name = "Spacecraft"
mass = 1.0
radius = 1000.0
# Position at LEO altitude: Earth position + (Earth radius + 200km altitude)
# Earth: 1.496e11, LEO offset: 6.571e6, Total: 1.49606571e11
parent_index = 1
color = { r = 1.0, g = 0.0, b = 0.5 }
orbit = {
# Semi-major axis: Earth radius + 200km LEO altitude
semi_major_axis = 6.571e6,
eccentricity = 0.0,
true_anomaly = 0.0
}

54
tests/configs/interplanetary_transfer.toml

@ -1,54 +0,0 @@
# Interplanetary Transfer Test Configuration
# Sun + Earth + Mars + Probe
# Probe will transition: Earth -> Sun -> Mars
[[bodies]]
name = "Sun"
mass = 1.989e30
radius = 6.96e8
parent_index = -1
color = { r = 1.0, g = 1.0, b = 0.0 }
orbit = {
semi_major_axis = 0.0,
eccentricity = 0.0,
true_anomaly = 0.0
}
[[bodies]]
name = "Earth"
mass = 5.972e24
radius = 6.371e6
parent_index = 0
color = { r = 0.0, g = 0.5, b = 1.0 }
orbit = {
semi_major_axis = 1.496e11,
eccentricity = 0.0,
true_anomaly = 0.0
}
[[bodies]]
name = "Mars"
mass = 6.39e23
radius = 3.3895e6
parent_index = 0
color = { r = 0.8, g = 0.3, b = 0.1 }
orbit = {
semi_major_axis = 2.279e11,
eccentricity = 0.0,
true_anomaly = 0.0
}
[[bodies]]
name = "Probe"
mass = 1.0e3
radius = 1.0e1
# Start at Earth's position, moving toward Mars
# The probe will escape Earth's SOI and transition to Sun, then to Mars
parent_index = 0 # Start orbiting Sun
color = { r = 0.0, g = 1.0, b = 0.0 }
orbit = {
# Use elliptical transfer orbit with semi_major_axis halfway between Earth and Mars
semi_major_axis = 1.888e11,
eccentricity = 0.3,
true_anomaly = 0.0
}

27
tests/configs/mars_circular.toml

@ -1,27 +0,0 @@
# Test Configuration: Sun + Mars (circular orbit)
# Mars at 1.5 AU with circular orbit
# Expected orbital period: ~687 days
[[bodies]]
name = "Sun"
mass = 1.989e30
radius = 6.96e8
parent_index = -1
color = { r = 1.0, g = 1.0, b = 0.0 }
orbit = {
semi_major_axis = 0.0,
eccentricity = 0.0,
true_anomaly = 0.0
}
[[bodies]]
name = "Mars"
mass = 6.39e23
radius = 3.3895e6
parent_index = 0
color = { r = 0.8, g = 0.3, b = 0.1 }
orbit = {
semi_major_axis = 2.244e11,
eccentricity = 0.0,
true_anomaly = 0.0
}

2
tests/test_energy.cpp

@ -12,7 +12,7 @@ TEST_CASE("Energy conservation - Earth circular orbit", "[energy][rk4]") {
SimulationState* sim = create_simulation(10, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/earth_circular.toml"));
REQUIRE(load_system_config(sim, "tests/test_energy.toml"));
double initial_energy = calculate_system_total_energy(sim);

0
tests/configs/earth_circular.toml → tests/test_energy.toml

6
tests/test_hyperbolic_orbit.cpp

@ -14,7 +14,7 @@ TEST_CASE("Hyperbolic orbit - energy and escape trajectory", "[hyperbolic][energ
SimulationState* sim = create_simulation(10, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/hyperbolic_comet.toml"));
REQUIRE(load_system_config(sim, "tests/test_hyperbolic_orbit.toml"));
const int COMET_INDEX = 1;
const int SUN_INDEX = 0;
@ -113,7 +113,7 @@ TEST_CASE("Hyperbolic orbit initial conditions", "[hyperbolic][initial]") {
SimulationState* sim = create_simulation(10, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/hyperbolic_comet.toml"));
REQUIRE(load_system_config(sim, "tests/test_hyperbolic_orbit.toml"));
const int COMET_INDEX = 1;
const int SUN_INDEX = 0;
@ -176,7 +176,7 @@ TEST_CASE("Hyperbolic orbit asymptotic velocity", "[hyperbolic][asymptotic]") {
SimulationState* sim = create_simulation(10, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/hyperbolic_comet.toml"));
REQUIRE(load_system_config(sim, "tests/test_hyperbolic_orbit.toml"));
const int COMET_INDEX = 1;
const int SUN_INDEX = 0;

0
tests/configs/hyperbolic_comet.toml → tests/test_hyperbolic_orbit.toml

49
tests/test_invalid_parent_assignment.cpp

@ -4,59 +4,12 @@
#include "../src/config_loader.h"
#include <cmath>
TEST_CASE("Invalid parent: massive bodies never become children of small bodies",
"[init][parent][hierarchy]") {
const double TIME_STEP = 60.0;
const double MASS_THRESHOLD_RATIO = 1000.0;
SimulationState* sim = create_simulation(10, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/earth_mars_simple.toml"));
for (int i = 0; i < sim->body_count; i++) {
if (sim->bodies[i].parent_index >= 0) {
int parent_idx = sim->bodies[i].parent_index;
double parent_mass = sim->bodies[parent_idx].mass;
double child_mass = sim->bodies[i].mass;
double mass_ratio = parent_mass / child_mass;
INFO("Body " << i << " (" << sim->bodies[i].name
<< ") parent " << parent_idx << " (" << sim->bodies[parent_idx].name
<< "): mass ratio = " << mass_ratio);
REQUIRE(mass_ratio >= 1.0);
if (strcmp(sim->bodies[parent_idx].name, "Spacecraft") != 0 &&
strcmp(sim->bodies[i].name, "Spacecraft") != 0) {
REQUIRE(mass_ratio >= MASS_THRESHOLD_RATIO);
}
}
}
for (int step = 0; step < 100; step++) {
update_simulation(sim);
for (int i = 0; i < sim->body_count; i++) {
if (sim->bodies[i].parent_index >= 0) {
int parent_idx = sim->bodies[i].parent_index;
double parent_mass = sim->bodies[parent_idx].mass;
double child_mass = sim->bodies[i].mass;
if (child_mass > 1e20) {
REQUIRE(parent_mass > child_mass);
}
}
}
}
destroy_simulation(sim);
}
TEST_CASE("Mutual SOI: similar mass planets within SOI boundary",
"[init][soi][mutual][edge_case]") {
const double TIME_STEP = 60.0;
SimulationState* sim = create_simulation(10, 0, 0, TIME_STEP);
REQUIRE_FALSE(load_system_config(sim, "tests/configs/mutual_soi_close.toml"));
REQUIRE_FALSE(load_system_config(sim, "tests/test_invalid_parent_assignment.toml"));
destroy_simulation(sim);
}

0
tests/configs/mutual_soi_close.toml → tests/test_invalid_parent_assignment.toml

10
tests/test_maneuver_planning.cpp

@ -11,7 +11,7 @@ TEST_CASE("Maneuver loading from config", "[maneuver][config]") {
SimulationState* sim = create_simulation(10, 10, 100, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/maneuver_sequence.toml"));
REQUIRE(load_system_config(sim, "tests/test_maneuver_planning.toml"));
REQUIRE(sim->maneuver_count == 2);
REQUIRE(std::string(sim->maneuvers[0].name) == "orbit_raise_1");
@ -28,7 +28,7 @@ TEST_CASE("Time-based trigger executes at correct time", "[maneuver][trigger][ti
SimulationState* sim = create_simulation(10, 10, 100, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/maneuver_sequence.toml"));
REQUIRE(load_system_config(sim, "tests/test_maneuver_planning.toml"));
REQUIRE(sim->maneuver_count == 2);
REQUIRE(!sim->maneuvers[0].executed);
@ -55,7 +55,7 @@ TEST_CASE("True anomaly trigger executes at correct angle", "[maneuver][trigger]
SimulationState* sim = create_simulation(10, 10, 100, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/maneuver_sequence.toml"));
REQUIRE(load_system_config(sim, "tests/test_maneuver_planning.toml"));
REQUIRE(sim->maneuver_count == 2);
REQUIRE(!sim->maneuvers[1].executed);
@ -98,7 +98,7 @@ TEST_CASE("Maneuvers only execute once", "[maneuver][execution]") {
SimulationState* sim = create_simulation(10, 10, 100, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/maneuver_sequence.toml"));
REQUIRE(load_system_config(sim, "tests/test_maneuver_planning.toml"));
const double MAX_TIME = 10000.0;
while (sim->time < MAX_TIME) {
@ -125,7 +125,7 @@ TEST_CASE("Duplicate maneuver names fail config load", "[maneuver][config][error
SimulationState* sim = create_simulation(10, 10, 100, TIME_STEP);
bool result = load_system_config(sim, "tests/configs/maneuver_sequence.toml");
bool result = load_system_config(sim, "tests/test_maneuver_planning.toml");
REQUIRE(result);
REQUIRE(sim->maneuver_count == 2);

0
tests/configs/maneuver_sequence.toml → tests/test_maneuver_planning.toml

12
tests/test_maneuvers.cpp

@ -12,7 +12,7 @@ TEST_CASE("Spacecraft loading from config", "[spacecraft][config]") {
SimulationState* sim = create_simulation(10, 10, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/spacecraft_test.toml"));
REQUIRE(load_system_config(sim, "tests/test_maneuvers.toml"));
REQUIRE(sim->craft_count == 1);
REQUIRE(std::string(sim->spacecraft[0].name) == "LEO_Satellite");
@ -26,7 +26,7 @@ TEST_CASE("Prograde burn increases orbital energy", "[spacecraft][burn][prograde
SimulationState* sim = create_simulation(10, 10, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/spacecraft_test.toml"));
REQUIRE(load_system_config(sim, "tests/test_maneuvers.toml"));
Spacecraft* craft = &sim->spacecraft[0];
CelestialBody* earth = &sim->bodies[1];
@ -56,7 +56,7 @@ TEST_CASE("Retrograde burn decreases orbital energy", "[spacecraft][burn][retrog
SimulationState* sim = create_simulation(10, 10, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/spacecraft_test.toml"));
REQUIRE(load_system_config(sim, "tests/test_maneuvers.toml"));
Spacecraft* craft = &sim->spacecraft[0];
CelestialBody* earth = &sim->bodies[1];
@ -86,7 +86,7 @@ TEST_CASE("Normal burn changes orbital plane", "[spacecraft][burn][normal]") {
SimulationState* sim = create_simulation(10, 10, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/spacecraft_test.toml"));
REQUIRE(load_system_config(sim, "tests/test_maneuvers.toml"));
Spacecraft* craft = &sim->spacecraft[0];
@ -111,7 +111,7 @@ TEST_CASE("Custom burn applies arbitrary delta-v", "[spacecraft][burn][custom]")
SimulationState* sim = create_simulation(10, 10, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/spacecraft_test.toml"));
REQUIRE(load_system_config(sim, "tests/test_maneuvers.toml"));
Spacecraft* craft = &sim->spacecraft[0];
@ -134,7 +134,7 @@ TEST_CASE("Spacecraft propagation maintains stability", "[spacecraft][propagatio
SimulationState* sim = create_simulation(10, 10, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/spacecraft_test.toml"));
REQUIRE(load_system_config(sim, "tests/test_maneuvers.toml"));
Spacecraft* craft = &sim->spacecraft[0];
CelestialBody* earth = &sim->bodies[1];

0
tests/configs/spacecraft_test.toml → tests/test_maneuvers.toml

8
tests/test_moon_orbits.cpp

@ -15,7 +15,7 @@ TEST_CASE("Moon orbital stability around Earth", "[moon][earth]") {
SimulationState* sim = create_simulation(20, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/solar_system.toml"));
REQUIRE(load_system_config(sim, "tests/test_moon_orbits.toml"));
const int EARTH_INDEX = 2;
const int MOON_INDEX = 8;
@ -100,7 +100,7 @@ TEST_CASE("Galilean moons orbital stability around Jupiter", "[moon][jupiter]")
SimulationState* sim = create_simulation(20, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/solar_system.toml"));
REQUIRE(load_system_config(sim, "tests/test_moon_orbits.toml"));
const int JUPITER_INDEX = 4;
const int IO_INDEX = 9;
@ -164,7 +164,7 @@ TEST_CASE("Titan orbital stability around Saturn", "[moon][saturn]") {
SimulationState* sim = create_simulation(20, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/solar_system.toml"));
REQUIRE(load_system_config(sim, "tests/test_moon_orbits.toml"));
const int SATURN_INDEX = 5;
const int TITAN_INDEX = 13;
@ -218,7 +218,7 @@ TEST_CASE("Combined solar system with all moons - parent stability", "[moon][int
SimulationState* sim = create_simulation(20, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/solar_system.toml"));
REQUIRE(load_system_config(sim, "tests/test_moon_orbits.toml"));
struct ParentChange {
double time_days;

0
tests/configs/solar_system.toml → tests/test_moon_orbits.toml

8
tests/test_orbital_period.cpp

@ -13,7 +13,7 @@ TEST_CASE("Orbital period - Earth (RK4)", "[period][rk4]") {
SimulationState* sim = create_simulation(10, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/earth_circular.toml"));
REQUIRE(load_system_config(sim, "tests/test_orbital_period.toml"));
OrbitTracker* tracker = create_orbit_tracker(1);
@ -46,14 +46,14 @@ TEST_CASE("Orbital period - Mars (RK4)", "[period][rk4]") {
SimulationState* sim = create_simulation(10, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/mars_circular.toml"));
REQUIRE(load_system_config(sim, "tests/test_orbital_period.toml"));
OrbitTracker* tracker = create_orbit_tracker(1);
OrbitTracker* tracker = create_orbit_tracker(2);
double max_time = MAX_SIMULATION_DAYS * SECONDS_PER_DAY;
while (sim->time < max_time && !tracker->orbit_completed) {
update_simulation(sim);
update_orbit_tracker(tracker, &sim->bodies[1], &sim->bodies[0], sim->time);
update_orbit_tracker(tracker, &sim->bodies[2], &sim->bodies[0], sim->time);
}
REQUIRE(tracker->orbit_completed);

21
tests/configs/simple_root_transition.toml → tests/test_orbital_period.toml

@ -1,6 +1,6 @@
# Simple Root Body Transition Test
# Sun + Earth + Mars + Probe
# Probe positioned to force transitions: Earth -> Sun -> Mars
# Test Configuration: Sun + Earth + Mars (circular orbits)
# Earth at 1 AU, Mars at 1.5 AU with circular orbits
# Expected orbital periods: Earth ~365 days, Mars ~687 days
[[bodies]]
name = "Sun"
@ -33,20 +33,7 @@ radius = 3.3895e6
parent_index = 0
color = { r = 0.8, g = 0.3, b = 0.1 }
orbit = {
semi_major_axis = 2.279e11,
semi_major_axis = 2.244e11,
eccentricity = 0.0,
true_anomaly = 0.0
}
# Probe starts near Earth, in Earth's SOI
[[bodies]]
name = "Probe"
mass = 1.0e3
radius = 1.0e1
parent_index = 1
color = { r = 1.0, g = 0.0, b = 1.0 }
orbit = {
semi_major_axis = 5.0e8,
eccentricity = 0.2,
true_anomaly = 0.0
}

4
tests/test_parabolic_orbit.cpp

@ -14,7 +14,7 @@ TEST_CASE("Parabolic orbit - energy and escape trajectory", "[parabolic][energy]
SimulationState* sim = create_simulation(10, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/parabolic_comet.toml"));
REQUIRE(load_system_config(sim, "tests/test_parabolic_orbit.toml"));
const int COMET_INDEX = 1;
const int SUN_INDEX = 0;
@ -106,7 +106,7 @@ TEST_CASE("Parabolic orbit initial conditions", "[parabolic][initial]") {
SimulationState* sim = create_simulation(10, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/parabolic_comet.toml"));
REQUIRE(load_system_config(sim, "tests/test_parabolic_orbit.toml"));
const int COMET_INDEX = 1;
const int SUN_INDEX = 0;

0
tests/configs/parabolic_comet.toml → tests/test_parabolic_orbit.toml

4
tests/test_root_body_transitions.cpp

@ -25,7 +25,7 @@ TEST_CASE("Root body transition - Earth to Sun", "[root][transition]") {
SimulationState* sim = create_simulation(10, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/manual_root_transition.toml"));
REQUIRE(load_system_config(sim, "tests/test_root_body_transitions.toml"));
const int PROBE_INDEX = 3;
const int SUN_INDEX = 0;
@ -99,7 +99,7 @@ TEST_CASE("Root body round-trip - Earth -> Sun -> Mars -> Sun", "[root][round-tr
SimulationState* sim = create_simulation(10, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/manual_root_transition.toml"));
REQUIRE(load_system_config(sim, "tests/test_root_body_transitions.toml"));
const int PROBE_INDEX = 3;
const int SUN_INDEX = 0;

0
tests/configs/manual_root_transition.toml → tests/test_root_body_transitions.toml

4
tests/test_soi_transition.cpp

@ -24,7 +24,7 @@ TEST_CASE("SOI transition - Sun to Mars", "[soi][transition]") {
SimulationState* sim = create_simulation(10, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/soi_transition.toml"));
REQUIRE(load_system_config(sim, "tests/test_soi_transition.toml"));
const int SMALL_BODY_INDEX = 2;
const int MARS_INDEX = 1;
@ -102,7 +102,7 @@ TEST_CASE("SOI transition - verify SOI radii", "[soi][radii]") {
SimulationState* sim = create_simulation(10, 0, 0, TIME_STEP);
REQUIRE(load_system_config(sim, "tests/configs/soi_transition.toml"));
REQUIRE(load_system_config(sim, "tests/test_soi_transition.toml"));
const int MARS_INDEX = 1;

0
tests/configs/soi_transition.toml → tests/test_soi_transition.toml

Loading…
Cancel
Save