2
0
mirror of git://github.com/lxc/lxc synced 2025-08-31 16:57:57 +00:00

tests: add unit tests for lxc_string_in_array()

Signed-off-by: Christian Brauner <cbrauner@suse.de>
This commit is contained in:
Christian Brauner
2016-08-14 22:42:17 +02:00
parent bed0d08fe7
commit 29c57e4ef6
3 changed files with 20 additions and 5 deletions

View File

@@ -32,7 +32,8 @@ noinst_HEADERS = \
start.h \
state.h \
utils.h \
criu.h
criu.h \
../tests/lxctest.h
if IS_BIONIC
noinst_HEADERS += \

View File

@@ -2,8 +2,6 @@ if ENABLE_TESTS
LDADD = ../lxc/liblxc.so
noinst_HEADERS += lxctest.h
lxc_test_containertests_SOURCES = containertests.c
lxc_test_locktests_SOURCES = locktests.c
lxc_test_startone_SOURCES = startone.c

View File

@@ -28,7 +28,7 @@
#include "lxctest.h"
#include "utils.h"
void test_string_replace(void)
void test_lxc_string_replace(void)
{
char *s;
@@ -65,9 +65,25 @@ void test_string_replace(void)
free(s);
}
void test_lxc_string_in_array(void)
{
lxc_test_assert_abort(lxc_string_in_array("", (const char *[]){"", NULL}));
lxc_test_assert_abort(!lxc_string_in_array("A", (const char *[]){"", NULL}));
lxc_test_assert_abort(!lxc_string_in_array("AAA", (const char *[]){"", "3472", "jshH", NULL}));
lxc_test_assert_abort(lxc_string_in_array("A", (const char *[]){"A", NULL}));
lxc_test_assert_abort(lxc_string_in_array("A", (const char *[]){"A", "B", "C", NULL}));
lxc_test_assert_abort(lxc_string_in_array("A", (const char *[]){"B", "A", "C", NULL}));
lxc_test_assert_abort(lxc_string_in_array("ABC", (const char *[]){"ASD", "ATR", "ABC", NULL}));
lxc_test_assert_abort(lxc_string_in_array("GHJ", (const char *[]){"AZIU", "WRT567B", "879C", "GHJ", "IUZ89", NULL}));
lxc_test_assert_abort(lxc_string_in_array("XYZ", (const char *[]){"BERTA", "ARQWE(9", "C8Zhkd", "7U", "XYZ", "UOIZ9", "=)()", NULL}));
}
int main(int argc, char *argv[])
{
test_string_replace();
test_lxc_string_replace();
test_lxc_string_in_array();
exit(EXIT_SUCCESS);
}