static void test_type(const char *type) { CVariant *cv; GVariant *gv; GBytes *cb, *gb; const void *cd, *gd; test_generate(type, &cv, &gv); cb = test_cv_get_data_as_bytes(cv); gb = g_variant_get_data_as_bytes(gv); if (g_bytes_compare(cb, gb)) { fprintf(stderr, "FAILED: %s\n", type); cd = g_bytes_get_data(cb, NULL); gd = g_bytes_get_data(gb, NULL); fprintf(stderr, "Buffers: %p:%zu %p:%zu\n", cd, g_bytes_get_size(cb), gd, g_bytes_get_size(gb)); test_print_cv(cv); assert(0); } test_compare(cv, gv); g_bytes_unref(gb); g_bytes_unref(cb); g_variant_unref(gv); c_variant_free(cv); }
int main(void) { int nerrors=0; nerrors += test_simple()<0 ?1:0; nerrors += test_data()<0 ?1:0; nerrors += test_generate()<0 ?1:0; if (nerrors) goto error; printf("All image tests passed.\n"); return 0; error: printf("***** %d IMAGE TEST%s FAILED! *****\n",nerrors, 1 == nerrors ? "" : "S"); return 1; }
int main(int argc, char **argv) { CRYPTO_library_init(); bio_err = BIO_new_fp(stderr, BIO_NOCLOSE); bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); if (!test_generate() || !test_verify(fips_sig, sizeof(fips_sig), 1) || !test_verify(fips_sig_negative, sizeof(fips_sig_negative), -1) || !test_verify(fips_sig_extra, sizeof(fips_sig_extra), -1) || !test_verify(fips_sig_bad_length, sizeof(fips_sig_bad_length), -1) || !test_verify(fips_sig_bad_r, sizeof(fips_sig_bad_r), 0)) { BIO_print_errors(bio_err); BIO_free(bio_err); BIO_free(bio_out); return 1; } BIO_free(bio_err); BIO_free(bio_out); printf("PASS\n"); return 0; }
int main(int argc, char *argv[], char *envp[]) { #define OUTPUT_SIZE 1024 #define IMPULSE_TEST_H_LENGTH 12 static const double impulse_test_H[IMPULSE_TEST_H_LENGTH] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 }; /************************************************************************* Impulse tests: Test decim, interp, and resamp in "filter" mode, using an impulse input. If the routines are working correctly, they should output the given coefficients (which, in this case, is just a sequence--to make the output easy to verify), possibly including leading and/or trailing zeros. *************************************************************************/ /* test interp in filter mode (decim_factor = 1) using impulse */ test_function(INTERP_FUNCTION, IMPULSE_TEST, 1, 1, IMPULSE_TEST_H_LENGTH + 1, impulse_test_H, IMPULSE_TEST_H_LENGTH, "interp_filter_impulse.txt"); /* test decim in filter mode (interp_factor = 1) using impulse */ test_function(DECIM_FUNCTION, IMPULSE_TEST, 1, 1, IMPULSE_TEST_H_LENGTH + 1, impulse_test_H, IMPULSE_TEST_H_LENGTH, "decim_filter_impulse.txt"); /* test resamp in filter mode (decim_factor = interp_factor = 1) using impulse */ test_function(RESAMP_FUNCTION, IMPULSE_TEST, 1, 1, IMPULSE_TEST_H_LENGTH + 1, impulse_test_H, IMPULSE_TEST_H_LENGTH, "resamp_filter_impulse.txt"); /************************************************************************* Sine tests: Test decim, interp, and resamp in various modes using a sine input. *************************************************************************/ /* test sine generator (which is used below) */ test_generate(); /*** test decim ***/ /* test decim as filter (decim_factor = 1) */ test_function(DECIM_FUNCTION, SINE_TEST, 1, 1, OUTPUT_SIZE, interp21_H, INTERP21_H_LENGTH, "decim_filter_sine.txt"); /* test decim as decimator (decim_factor = 21) */ test_function(DECIM_FUNCTION, SINE_TEST, 1, 21, 21 * OUTPUT_SIZE, interp21_H, INTERP21_H_LENGTH, "decim_decim21_sine.txt"); /*** test interp ***/ /* test interp as filter (interp_factor = 1) */ test_function(INTERP_FUNCTION, SINE_TEST, 1, 1, OUTPUT_SIZE, interp21_H, INTERP21_H_LENGTH, "interp_filter_sine.txt"); /* test interp as interpolator (interp_factor = 21) */ test_function(INTERP_FUNCTION, SINE_TEST, 21, 1, 49, interp21_H, INTERP21_H_LENGTH, "interp_interp21_sine.txt"); /* test interp as interpolator (interp_factor = 25) */ test_function(INTERP_FUNCTION, SINE_TEST, 25, 1, 41, interp25_H, INTERP25_H_LENGTH, "interp_interp25_sine.txt"); /*** test resamp ***/ /* test resamp as filter (decim_factor = interp_factor = 1) */ test_function(RESAMP_FUNCTION, SINE_TEST, 1, 1, OUTPUT_SIZE, interp21_H, INTERP21_H_LENGTH, "resamp_filter_sine.txt"); /* test resamp as decimator (interp_factor = decim_factor = 1) */ test_function(RESAMP_FUNCTION, SINE_TEST, 1, 21, 21 * OUTPUT_SIZE, interp21_H, INTERP21_H_LENGTH, "resamp_decim21_sine.txt"); /* test resamp as interpolator (interp_factor = 21, decim_factor = 1) */ test_function(RESAMP_FUNCTION, SINE_TEST, 21, 1, 49, interp21_H, INTERP21_H_LENGTH, "resamp_interp21_sine.txt"); /* test resamp as interpolator (interp_factor = 25, decim_factor = 1) */ test_function(RESAMP_FUNCTION, TRUE, 25, 1, 41, interp25_H, INTERP25_H_LENGTH, "resamp_interp25_sine.txt"); /* test resamp as resampler by decreasing rate */ /* (interp_factor = 21, decim_factor = 25, ratio = 21/25 = 0.84) */ test_function(RESAMP_FUNCTION, SINE_TEST, 21, 25, OUTPUT_SIZE, interp21_H, INTERP21_H_LENGTH, "resamp_resamp21_25_sine.txt"); /* test resamp as resampler by increasing rate */ /* (interp_factor = 25, decim_factor = 21, ratio = 25/21 ~= 1.19) */ test_function(RESAMP_FUNCTION, SINE_TEST, 25, 21, OUTPUT_SIZE, interp25_H, INTERP25_H_LENGTH, "resamp_resamp25_21_sine.txt"); return 0; }