diff options
author | EuAndreh <eu@euandre.org> | 2024-05-24 22:08:02 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-05-24 22:10:24 -0300 |
commit | 8ebb7b875a0bc5a417ce62238afcc79c366b5fa1 (patch) | |
tree | 13a37aaad7f11831196edfbdede27083eb0bd4fe /tests | |
parent | src/i18n.c: Remove leading empty string in MSGS[] (diff) | |
download | pindaiba-8ebb7b875a0bc5a417ce62238afcc79c366b5fa1.tar.gz pindaiba-8ebb7b875a0bc5a417ce62238afcc79c366b5fa1.tar.xz |
src/catalog.h: Do bounds checking on calls to s()
Diffstat (limited to 'tests')
-rw-r--r-- | tests/catalog.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/catalog.c b/tests/catalog.c index 197d06b..fbccfe5 100644 --- a/tests/catalog.c +++ b/tests/catalog.c @@ -8,16 +8,17 @@ static const char *const FNAME = __FILE__ ".txt"; enum TEST_MSGCATALOG_ID { - MSG_X_FIRST = 1, + MSG_X_FIRST, MSG_X_1, MSG_X_2, MSG_X_LAST, MSG_STANDALONE, }; +#define TEST_MSGS_LEN 6U + static const char *const -TEST_MSGS[] = { - "", +TEST_MSGS[TEST_MSGS_LEN] = { [MSG_X_FIRST]="First line\n", [MSG_X_1]="a second\n", [MSG_X_2]="a third\n", @@ -27,10 +28,10 @@ TEST_MSGS[] = { }; static int -test_i18n_init(void) { +test_i18n_init_msgs(void) { int rc = -1; - test_start("i18n_init()"); + test_start("i18n_init_msgs()"); { testing("simple call without touching the environment"); @@ -41,10 +42,11 @@ test_i18n_init(void) { goto out; } - if (i18n_init()) { - logerr("i18n_init()"); + if (i18n_init_msgs(TEST_MSGS)) { + logerr("i18n_init_msgs()"); goto out; } + assert(msgs_length == TEST_MSGS_LEN - 1U); test_ok(); } @@ -280,8 +282,8 @@ int main(void) { int rc = -1; - if (test_i18n_init()) { - logerr("test_i18n_init()"); + if (test_i18n_init_msgs()) { + logerr("test_i18n_init_msgs()"); goto out; } |