Exemplo n.º 1
0
Arquivo: edns.c Projeto: idtek/knot
int main(int argc, char *argv[])
{
	plan(TEST_COUNT);
	int done = 0;

	knot_rrset_t opt_rr;
	int ret = knot_edns_init(&opt_rr, E_MAX_PLD, E_RCODE, E_VERSION, NULL);

	ok(ret == KNOT_EOK, "OPT RR: init");
	done++;

	/* Check initialized values (no NSID yet). */
	bool success = check_header(&opt_rr, E_MAX_PLD, E_VERSION, 0, E_RCODE,
	                            "OPT RR: check header", &done);
	if (!success) {
		skip_block(remaining(done), "OPT RR not initialized properly");
		goto exit;
	}

	/* Setters */
	success = test_setters(&opt_rr, &done);

	if (!success) {
		skip_block(remaining(done), "OPT RR: setters error");
		goto exit;
	}

	/* Getters
	   Note: NULL parameters are not supported, so no test for that. */
	success = test_getters(&opt_rr, &done);

	if (!success) {
		skip_block(remaining(done), "OPT RR: getters error");
		goto exit;
	}

	/* EDNS client subnet */
	test_client_subnet();
exit:
	knot_rrset_clear(&opt_rr, NULL);

	return 0;
}
Exemplo n.º 2
0
int main(int argc, char** argv)
{
    fill_getter_map();
    fill_data();
    test_getters();

    std::cout << "Running the real test..." << std::endl;

    int int_var;
    int* opt_int_var;
    float float_var;
    float* opt_float_var;
    getter_list_t* getter_list = build_getter_list(argv[1], argv[2]);
    if (getter_list)
    {
        if (getter_list->_type == eInt)
        {
            if (getter_list->_optional == eOptional)
            {
                opt_int_var = (int*)getter_list->_getter(&d, getter_list->_next);
                if (opt_int_var)
                {
                    std::cout << argv[1] << " = " << *opt_int_var << std::endl;
                }
                else
                {
                    std::cout << argv[1] << " = NULL" << std::endl;
                }
            }
            else if (getter_list->_optional == eMandatory)
            {
                int_var = *(int*)getter_list->_getter(&d, getter_list->_next);
                std::cout << argv[1] << " = " << int_var << std::endl;
            }
            else
            {
                std::cout << argv[1] << " is unknown to be optional or mandatory" << std::endl;
            }
        }
        else if (getter_list->_type == eFloat)
        {
            if (getter_list->_optional == eOptional)
            {
                opt_float_var = (float*)getter_list->_getter(&d, getter_list->_next);
                if (opt_float_var)
                {
                    std::cout << argv[1] << " = " << *opt_float_var << std::endl;
                }
                else
                {
                    std::cout << argv[1] << " = NULL" << std::endl;
                }
            }
            else if (getter_list->_optional == eMandatory)
            {
                float_var = *(float*)getter_list->_getter(&d, getter_list->_next);
                std::cout << argv[1] << " = " << float_var << std::endl;
            }
            else
            {
                std::cout << argv[1] << " is unknown to be optional or mandatory" << std::endl;
            }
        }
    }

    return 0;
}