diff --git a/Makefile.am b/Makefile.am index 35c1ad7..bed3f3d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -72,5 +72,10 @@ noinst_HEADERS = getopt_long.h dist_doc_DATA = README.md AUTHORS -check: pkgconf +EXTRA_PROGRAMS = unit_tests +unit_tests_SOURCES = libpkgconf/tests/argvsplit-test.c +unit_tests_LDADD = libpkgconf.la + +check: pkgconf unit_tests + ./unit_tests $(SHELL) tests/run.sh ./pkgconf diff --git a/libpkgconf/tests/argvsplit-test.c b/libpkgconf/tests/argvsplit-test.c new file mode 100644 index 0000000..81ab12c --- /dev/null +++ b/libpkgconf/tests/argvsplit-test.c @@ -0,0 +1,34 @@ +#include +#include + +#include "../libpkgconf.h" + +void test_simple() +{ + int argc; + char **argv; + + pkgconf_argv_split("A B", &argc, &argv); + assert(argc == 2); + assert(!strcmp(argv[0], "A")); + assert(!strcmp(argv[1], "B")); + pkgconf_argv_free(argv); +} + +void test_escaped() +{ + int argc; + char **argv; + + pkgconf_argv_split("A\\ B", &argc, &argv); + assert(argc == 1); + assert(!strcmp(argv[0], "A\\ B")); + pkgconf_argv_free(argv); +} + +int main(int argc, char **argv) +{ + (void) argc; (void) argv; + test_simple(); + test_escaped(); +}