Harden API wrapper error paths and water bindings

This commit is contained in:
Codex
2026-07-02 23:47:53 +08:00
parent b38b18d409
commit a750dc9e39
5 changed files with 124 additions and 37 deletions
+13
View File
@@ -58,9 +58,16 @@ int main(void)
&min_density, &max_density) != -1) {
return fail("null water summary mass pointer did not return -1");
}
if (sphlite_get_water_summary(&water_mass, NULL, &max_pressure,
&min_density, &max_density) != -1) {
return fail("null water summary momentum pointer did not return -1");
}
if (sphlite_get_water_dt_limits(NULL, &dt_accel, &dt_viscous) != -1) {
return fail("null water dt pointer did not return -1");
}
if (sphlite_get_water_dt_limits(&dt_cfl, &dt_accel, NULL) != -1) {
return fail("null water dt viscous pointer did not return -1");
}
ierr = sphlite_initialize();
if (ierr != 0) return fail("initialize failed");
@@ -102,11 +109,17 @@ int main(void)
x, v, a, rho, pressure, internal_energy, temperature, h, &count) != -1) {
return fail("null particle-state array did not return -1");
}
if (sphlite_get_particle_state(4, ids, phase, status, material_id, section_id,
x, v, a, rho, pressure, internal_energy, temperature, h, NULL) != -1) {
return fail("null particle-state count did not return -1");
}
ierr = sphlite_advance_explicit(1.0e-6);
if (ierr != 0) return fail("advance explicit failed");
ierr = sphlite_get_current_time(&time, &step);
if (ierr != 0 || step != 1 || time <= 0.0) return fail("time query failed");
ierr = sphlite_advance_explicit(-1.0e-6);
if (ierr != 1) return fail("Fortran argument error was not returned to C");
ierr = sphlite_set_output_directory(SPHLITE_TEST_WORK_DIR);
if (ierr != 0) return fail("set output directory failed");