Add unit test for argvsplit

pull/81/head
Dan Kegel 2015-09-10 16:35:06 -07:00
parent 938bb9e694
commit 41cb57e9cd
2 changed files with 40 additions and 1 deletions

View File

@ -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

View File

@ -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();
}