commit 9377f60fb37a662908093b216f971f07c0dd1945
parent 2a64412c3415a221afe26aca9b85a922c89070f8
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 5 Feb 2026 15:26:19 +0100
Test loading an empty mixture file
Diffstat:
1 file changed, 27 insertions(+), 0 deletions(-)
diff --git a/src/test_sln_mixture.c b/src/test_sln_mixture.c
@@ -128,6 +128,32 @@ test_api
}
static void
+test_empty_file
+ (struct sln_device* sln,
+ struct shtr_isotope_metadata* molparam)
+{
+ struct sln_mixture_load_args args = SLN_MIXTURE_LOAD_ARGS_NULL;
+ struct sln_mixture* mixture = NULL;
+ struct sln_molecule molecule = SLN_MOLECULE_NULL;
+
+ FILE* fp = NULL;
+
+ CHK(fp = tmpfile());
+
+ args.filename = "tmpfile";
+ args.molparam = molparam;
+ args.file = fp;
+
+ /* An empty file is valid */
+ CHK(sln_mixture_load(sln, &args, &mixture) == RES_OK);
+ CHK(sln_mixture_get_molecule_count(mixture) == 0);
+ CHK(sln_mixture_get_molecule(mixture, 0, &molecule) == RES_BAD_ARG);
+ CHK(sln_mixture_ref_put(mixture) == RES_OK);
+
+ CHK(fclose(fp) == 0);
+}
+
+static void
test_invalid_molecule
(struct sln_device* sln,
struct shtr_isotope_metadata* molparam)
@@ -266,6 +292,7 @@ main(void)
molparam = load_isotope_metadata(shtr);
test_api(sln, molparam);
+ test_empty_file(sln, molparam);
test_invalid_molecule(sln, molparam);
CHK(sln_device_ref_put(sln) == RES_OK);