mirror of
git://github.com/lxc/lxc
synced 2025-09-04 01:49:29 +00:00
tests: add unit tests for lxc_string_in_array()
Signed-off-by: Christian Brauner <cbrauner@suse.de>
This commit is contained in:
@@ -32,7 +32,8 @@ noinst_HEADERS = \
|
|||||||
start.h \
|
start.h \
|
||||||
state.h \
|
state.h \
|
||||||
utils.h \
|
utils.h \
|
||||||
criu.h
|
criu.h \
|
||||||
|
../tests/lxctest.h
|
||||||
|
|
||||||
if IS_BIONIC
|
if IS_BIONIC
|
||||||
noinst_HEADERS += \
|
noinst_HEADERS += \
|
||||||
|
@@ -2,8 +2,6 @@ if ENABLE_TESTS
|
|||||||
|
|
||||||
LDADD = ../lxc/liblxc.so
|
LDADD = ../lxc/liblxc.so
|
||||||
|
|
||||||
noinst_HEADERS += lxctest.h
|
|
||||||
|
|
||||||
lxc_test_containertests_SOURCES = containertests.c
|
lxc_test_containertests_SOURCES = containertests.c
|
||||||
lxc_test_locktests_SOURCES = locktests.c
|
lxc_test_locktests_SOURCES = locktests.c
|
||||||
lxc_test_startone_SOURCES = startone.c
|
lxc_test_startone_SOURCES = startone.c
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "lxctest.h"
|
#include "lxctest.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
void test_string_replace(void)
|
void test_lxc_string_replace(void)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
@@ -65,9 +65,25 @@ void test_string_replace(void)
|
|||||||
free(s);
|
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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
test_string_replace();
|
test_lxc_string_replace();
|
||||||
|
test_lxc_string_in_array();
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user