summaryrefslogtreecommitdiff
path: root/tests/catalog.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/catalog.c')
-rw-r--r--tests/catalog.c39
1 files changed, 12 insertions, 27 deletions
diff --git a/tests/catalog.c b/tests/catalog.c
index d357175..5e5a430 100644
--- a/tests/catalog.c
+++ b/tests/catalog.c
@@ -28,7 +28,7 @@ TEST_MSGS[] = {
static int
test_i18n_init(void) {
- int rc = 0;
+ int rc = -1;
test_start("i18n_init()");
@@ -39,19 +39,18 @@ test_i18n_init(void) {
if (setenv(NLSPATH_KEY, "src/%N.en.cat", should_overwrite)) {
logerr("setenv(\"%s\", \"src/%%N.en.cat\", 1): %s\n",
NLSPATH_KEY, strerror(errno));
- rc = -1;
goto out;
}
if (i18n_init()) {
logerr("i18n_init()\n");
- rc = -1;
goto out;
}
test_ok();
}
+ rc = 0;
out:
if (i18n_destroy()) {
logerr("i18n_destroy()\n");
@@ -62,7 +61,7 @@ out:
static int
test_s_print_msgs(void) {
- int rc = 0;
+ int rc = -1;
test_start("s_print_msgs()");
FILE *file = NULL;
@@ -74,13 +73,11 @@ test_s_print_msgs(void) {
file = fopen(FNAME, "w");
if (!file) {
perror("fopen(FNAME, \"w\")");
- rc = -1;
goto out;
}
if (s_print_msgs(TEST_MSGS, file, MSG_X_FIRST, MSG_X_LAST)) {
logerr("print_msgs(TEST_MSGS, file, MSG_X_FIRST, MSG_X_LAST)\n");
- rc = -1;
goto out;
}
@@ -88,13 +85,11 @@ test_s_print_msgs(void) {
file = NULL;
if (ret) {
logerr("fclose(file): %s\n", strerror(errno));
- rc = -1;
goto out;
}
if (slurp_for_tests(FNAME, &str)) {
logerr("slurp_for_tests(FNAME, &str)\n");
- rc = -1;
goto out;
}
@@ -118,13 +113,11 @@ test_s_print_msgs(void) {
file = fopen(FNAME, "w");
if (!file) {
logerr("fopen(FNAME, \"w\"): %s\n", strerror(errno));
- rc = -1;
goto out;
}
if (s_print_msgs(TEST_MSGS, file, MSG_X_FIRST, MSG_X_FIRST)) {
logerr("s_print_msgs(TEST_MSGS, file, MSG_X_FIRST, MSG_X_FIRST)\n");
- rc = -1;
goto out;
}
@@ -132,13 +125,11 @@ test_s_print_msgs(void) {
file = NULL;
if (ret) {
logerr("fclose(file): %s\n", strerror(errno));
- rc = -1;
goto out;
}
if (slurp_for_tests(FNAME, &str)) {
logerr("slurp_for_tests(FNAME, &str)\n");
- rc = -1;
goto out;
}
@@ -153,6 +144,7 @@ test_s_print_msgs(void) {
test_ok();
}
+ rc = 0;
out:
if (str) {
free(str);
@@ -168,7 +160,7 @@ out:
static int
test_s(void) {
- int rc = 0;
+ int rc = -1;
test_start("_()");
FILE *file = NULL;
@@ -180,7 +172,6 @@ test_s(void) {
file = fopen(FNAME, "w");
if (!file) {
perror("fopen(FNAME, \"w\")");
- rc = -1;
goto out;
}
@@ -191,6 +182,7 @@ test_s(void) {
test_ok();
}
+ rc = 0;
out:
if (str) {
free(str);
@@ -206,7 +198,7 @@ out:
static int
test_i18n_destroy(void) {
- int rc = 0;
+ int rc = -1;
test_start("i18n_destroy()");
@@ -215,20 +207,20 @@ test_i18n_destroy(void) {
if (i18n_destroy()) {
logerr("i18n_destroy()\n");
- rc = -1;
goto out;
}
test_ok();
}
+ rc = 0;
out:
return rc;
}
static int
test_s_print_msg(void) {
- int rc = 0;
+ int rc = -1;
test_start("s_print_msg()");
FILE *file = NULL;
@@ -240,13 +232,11 @@ test_s_print_msg(void) {
file = fopen(FNAME, "w");
if (!file) {
logerr("fopen(FNAME, \"w\"): %s\n");
- rc = -1;
goto out;
}
if (s_print_msg(TEST_MSGS, file, MSG_STANDALONE)) {
logerr("s_print_msg(TEST_MSGS, file, MSG_STANDALONE)\n");
- rc = -1;
goto out;
}
@@ -254,13 +244,11 @@ test_s_print_msg(void) {
file = NULL;
if (ret) {
logerr("fopen(file): %s\n", strerror(errno));
- rc = -1;
goto out;
}
if (slurp_for_tests(FNAME, &str)) {
logerr("slurp_for_tests(FNAME, &str)\n");
- rc = -1;
goto out;
}
@@ -275,6 +263,7 @@ test_s_print_msg(void) {
test_ok();
}
+ rc = 0;
out:
if (str) {
free(str);
@@ -290,38 +279,34 @@ out:
int
main(void) {
- int rc = 0;
+ int rc = -1;
if (test_i18n_init()) {
logerr("test_i18n_init()\n");
- rc = -1;
goto out;
}
if (test_i18n_destroy()) {
logerr("test_i18n_destroy()\n");
- rc = -1;
goto out;
}
if (test_s()) {
logerr("test_s()\n");
- rc = -1;
goto out;
}
if (test_s_print_msgs()) {
logerr("test_s_print_msgs()\n");
- rc = -1;
goto out;
}
if (test_s_print_msg()) {
logerr("test_s_print_msg()\n");
- rc = -1;
goto out;
}
+ rc = 0;
out:
return !!rc;
}