From 07347dcaa361607a924178eff787177e8cca6d68 Mon Sep 17 00:00:00 2001 From: jakob Date: Wed, 12 Apr 2017 16:54:36 -0400 Subject: Expanded tests for the command-line interface. --- test/test_cli.c | 24 +++++++++++++++++++++++- test/test_cli.h | 2 ++ test/test_run.c | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test_cli.c b/test/test_cli.c index 5a5f0db..00cc84e 100644 --- a/test/test_cli.c +++ b/test/test_cli.c @@ -22,11 +22,33 @@ #include "minunit.h" #include "cli.h" +#include "crypto.h" + +extern int tests_run; char *test_out_path(void) { - char *argv[4] = {"nekopack", "-o", "/tmp", "a.xp3"}; + char *argv[] = {"nekopack", "-o", "/tmp", "a.xp3"}; struct params p = parse_args(4, argv); mu_assert("Trailing slash not appended to path", !strcmp(p.out, "/tmp/")); + params_free(p); + return NULL; +} + + +char *test_vararg_index(void) { + char *argv[] = {"nekopack", "-l", "a.xp3"}; + struct params p = parse_args(3, argv); + mu_assert("Invalid vararg index", !strcmp("a.xp3", argv[p.vararg_index])); + params_free(p); + return NULL; +} + + +char *test_game_id(void) { + char *argv[] = {"nekopack", "-g", "nekopara_volume_1", "a.xp3"}; + struct params p = parse_args(4, argv); + mu_assert("Incorrect game ID", p.game == NEKOPARA_VOLUME_1); + params_free(p); return NULL; } diff --git a/test/test_cli.h b/test/test_cli.h index e580236..f16c50b 100644 --- a/test/test_cli.h +++ b/test/test_cli.h @@ -20,3 +20,5 @@ #pragma once char *test_out_path(void); +char *test_vararg_index(void); +char *test_game_id(void); diff --git a/test/test_run.c b/test/test_run.c index 04099d4..b63bcb5 100644 --- a/test/test_run.c +++ b/test/test_run.c @@ -33,6 +33,8 @@ int tests_run = 0; static char *run_all_tests(void) { mu_run_test(test_out_path); + mu_run_test(test_vararg_index); + mu_run_test(test_game_id); mu_run_test(test_derive_initial); mu_run_test(test_derive_primary); mu_run_test(test_stream_obj); -- cgit v1.3