#include "sphlite_c_api.h" #include #include static int fail(const char *message) { fprintf(stderr, "%s\n", message); return 1; } int main(void) { char path[1024]; int ierr; int major = 0; int minor = 0; int patch = 0; int count = 0; int step = 0; double time = 0.0; if (sphlite_get_particle_count(NULL) != -1) { return fail("null particle count pointer did not return -1"); } if (sphlite_get_last_error(NULL, path, (int)sizeof(path)) != -1) { return fail("null last-error code pointer did not return -1"); } ierr = sphlite_initialize(); if (ierr != 0) return fail("initialize failed"); ierr = sphlite_get_version(&major, &minor, &patch); if (ierr != 0) return fail("get_version failed"); if (major != 0 || minor != 1 || patch != 0) return fail("unexpected version"); snprintf(path, sizeof(path), "%s/minimal_particles.inp", SPHLITE_TEST_DATA_DIR); ierr = sphlite_read_inp(path); if (ierr != 0) return fail("read_inp failed"); ierr = sphlite_build_model(); if (ierr != 0) return fail("build_model failed"); ierr = sphlite_get_particle_count(&count); if (ierr != 0 || count != 4) return fail("particle count mismatch"); 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_finalize(); if (ierr != 0) return fail("finalize failed"); return 0; }