Add unit test for argvsplit
parent
938bb9e694
commit
41cb57e9cd
|
@ -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
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#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();
|
||||
}
|
Loading…
Reference in New Issue