Пример #1
0
void test_all_values(void) {
    char *test_argv[] = {
        "",
#ifdef HAVE_IPV6
        "-6",
#endif
        "-a", host1,
        "-b", host2,
        "-p", "6",
        "-q", "8",
    };
#ifdef HAVE_IPV6
    int test_argc = 10;
#else
    int test_argc = 9;
#endif

    tca_options *result = evaluate_options(test_argc, test_argv);

#ifdef HAVE_IPV6
    g_assert(result->use_ipv6 == true);
#else
    g_assert(result->use_ipv6 == false);
#endif
    g_assert_cmpstr(result->connection_endpoints[0]->address_str, ==, host1);
    g_assert_cmpstr(result->connection_endpoints[1]->address_str, ==, host2);
    g_assert(result->connection_endpoints[0]->port == 6);
    g_assert(result->connection_endpoints[1]->port == 8);
}
Пример #2
0
static rc_t capture_arguments_and_options( Args * args, context *ctx )
{
    evaluate_options( args, ctx );
    change_extension( &(ctx->dependency_file), DEPENDENCY_EXTENSION );

    return 0;
}
Пример #3
0
void test_help(void) {
    if (g_test_subprocess()) {
        char *test_argv[] = { "", "-h" };
        evaluate_options(2, test_argv);
    }

    g_test_trap_subprocess(NULL, 0, 0);
    g_test_trap_assert_passed();
    g_test_trap_assert_stdout(usage_text(""));
}
Пример #4
0
void test_wrong_option(void) {
    if (g_test_subprocess()) {
        char *test_argv[] = { "", "--nonex-option" };
        evaluate_options(2, test_argv);
    }

    g_test_trap_subprocess(NULL, 0, 0);
    g_test_trap_assert_failed();
    g_test_trap_assert_stderr("*Unrecognised option*");
}
Пример #5
0
void test_no_options(void) {
    if (g_test_subprocess()) {
        char *test_argv[] = { "" };
        evaluate_options(1, test_argv);
    }

    g_test_trap_subprocess(NULL, 0, 0);
    g_test_trap_assert_failed();
    g_test_trap_assert_stderr(
            "*Both ports are required for forwarding.\n\nUsage*");
}
Пример #6
0
void test_wrong_port2(void) {
    if (g_test_subprocess()) {
        char *test_argv[] = {
            "",
            "-p", "6",
            "-q", "DEF",
        };
        int test_argc = 5;
        evaluate_options(test_argc, test_argv);
    }

    g_test_trap_subprocess(NULL, 0, 0);
    g_test_trap_assert_failed();
    g_test_trap_assert_stderr("*Second port invalid*");
}
Пример #7
0
void test_default_values(void) {
    char *test_argv[] = {
        "",
        "-p", "6",
        "-q", "8",
    };
    int test_argc = 5;
    tca_options *result = evaluate_options(test_argc, test_argv);
    g_assert(result->use_ipv6 == false);
    g_assert_cmpstr(
            result->connection_endpoints[0]->address_str,
            ==,
            "0.0.0.0");
    g_assert_cmpstr(
            result->connection_endpoints[1]->address_str,
            ==,
            "0.0.0.0");
    g_assert(result->connection_endpoints[0]->port == 6);
    g_assert(result->connection_endpoints[1]->port == 8);
}