star-wf

First-passage time of brownian motion
git clone git://git.meso-star.fr/star-wf.git
Log | Files | Refs | README | LICENSE

commit 84e35d25d679a5a7c2e5f7c9b5b76a9e9d347ee6
parent cfb2372a7778aff29e3231fb1e99d3e2f9e44788
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed,  6 Mar 2024 16:28:43 +0100

Testing the H3d function

At present, only API calls are actually tested. Returned values are not
validated.

Diffstat:
MMakefile | 37+++++++++++++++++++++++++++++++++++--
Asrc/test_swf_H3d.c | 48++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile @@ -95,9 +95,9 @@ uninstall: ################################################################################ # Miscellaneous targets ################################################################################ -all: build_library #build_tests +all: build_library build_tests -clean: #clean_test +clean: clean_test rm -f $(OBJ) $(TEST_OBJ) $(LIBNAME) rm -f .config .test libswf.o swf.pc swf-local.pc @@ -106,3 +106,36 @@ distclean: clean lint: shellcheck -o all make.sh + +################################################################################ +# Tests +################################################################################ +TEST_SRC = src/test_swf_H3d.c +TEST_OBJ = $(TEST_SRC:.c=.o) +TEST_DEP = $(TEST_SRC:.c=.d) + +PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) +SWF_CFLAGS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags swf-local.pc) +SWF_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs swf-local.pc) + +test: build_tests + @$(SHELL) make.sh run_test $(TEST_SRC) + +build_tests: build_library $(TEST_DEP) .test + @$(MAKE) -fMakefile -f.test $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) test_bin + +.test: Makefile make.sh + @$(SHELL) make.sh config_test $(TEST_SRC) > $@ + +clean_test: + $(SHELL) make.sh clean_test $(TEST_SRC) file.txt + +$(TEST_DEP): config.mk swf-local.pc + @$(CC) $(CFLAGS_EXE) $(SWF_CFLAGS) $(RSYS_CFLAGS) \ + -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(TEST_OBJ): config.mk swf-local.pc + $(CC) $(CFLAGS_EXE) $(SWF_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@ + +test_swf_H3d: config.mk swf-local.pc $(LIBNAME) + $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(SWF_LIBS) $(RSYS_LIBS) diff --git a/src/test_swf_H3d.c b/src/test_swf_H3d.c @@ -0,0 +1,48 @@ +/* Copyright (C) 2024 |Méso|Star> (contact@meso-star.com) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "swf.h" +#include <rsys/rsys.h> + +/******************************************************************************* + * Helper functions + ******************************************************************************/ +static void +check_tabulation(void) +{ + struct swf_H_tabulate_args args = SWF_H_TABULATE_ARGS_DEFAULT; + struct swf_tabulation* tab = NULL; + + CHK(swf_H3d_tabulate(NULL, &tab) == RES_BAD_ARG); + CHK(swf_H3d_tabulate(&args, NULL) == RES_BAD_ARG); + CHK(swf_H3d_tabulate(&args, &tab) == RES_OK); + + CHK(swf_tabulation_ref_get(NULL) == RES_BAD_ARG); + CHK(swf_tabulation_ref_get(tab) == RES_OK); + CHK(swf_tabulation_ref_put(NULL) == RES_BAD_ARG); + CHK(swf_tabulation_ref_put(tab) == RES_OK); + CHK(swf_tabulation_ref_put(tab) == RES_OK); +} + +/******************************************************************************* + * The test + ******************************************************************************/ +int +main(int argc, char** argv) +{ + (void)argc, (void)argv; + check_tabulation(); + return 0; +}