print error-message instead of error-code

This commit is contained in:
Steffen Jaeckel 2019-01-17 12:42:58 +01:00
parent 5aada1b936
commit 71b2d2ad49

View File

@ -661,7 +661,7 @@ int main(void)
(rand() & 1) ? 0 : LTM_PRIME_2MSB_ON, myrng, (rand() & 1) ? 0 : LTM_PRIME_2MSB_ON, myrng,
NULL); NULL);
if (err != MP_OKAY) { if (err != MP_OKAY) {
printf("failed with err code %d\n", err); printf("\nfailed with error: %s\n", mp_error_to_string(err));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (mp_count_bits(&a) != ix) { if (mp_count_bits(&a) != ix) {
@ -690,7 +690,7 @@ int main(void)
err = mp_prime_is_prime(&a, 8, &cnt); err = mp_prime_is_prime(&a, 8, &cnt);
/* small problem */ /* small problem */
if (err != MP_OKAY) { if (err != MP_OKAY) {
printf("failed with err code %d\n", err); printf("\nfailed with error: %s\n", mp_error_to_string(err));
printf("prime tested was: "); printf("prime tested was: ");
mp_fwrite(&a,16,stdout); mp_fwrite(&a,16,stdout);
putchar('\n'); putchar('\n');
@ -711,7 +711,7 @@ int main(void)
&a, 8, ix, ((rand() & 1) ? 0 : LTM_PRIME_2MSB_ON) | LTM_PRIME_SAFE, &a, 8, ix, ((rand() & 1) ? 0 : LTM_PRIME_2MSB_ON) | LTM_PRIME_SAFE,
myrng, NULL); myrng, NULL);
if (err != MP_OKAY) { if (err != MP_OKAY) {
printf("failed with err code %d\n", err); printf("\nfailed with error: %s\n", mp_error_to_string(err));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (mp_count_bits(&a) != ix) { if (mp_count_bits(&a) != ix) {
@ -724,7 +724,7 @@ int main(void)
err = mp_prime_is_prime(&b, 8, &cnt); err = mp_prime_is_prime(&b, 8, &cnt);
/* small problem */ /* small problem */
if (err != MP_OKAY) { if (err != MP_OKAY) {
printf("\nfailed with err code %d\n", err); printf("\nfailed with error: %s\n", mp_error_to_string(err));
} }
/* large problem */ /* large problem */
if (cnt != MP_YES) { if (cnt != MP_YES) {
@ -734,7 +734,7 @@ int main(void)
printf("prime tested was: "); printf("prime tested was: ");
mp_fwrite(&a,16,stdout); mp_fwrite(&a,16,stdout);
putchar('\n'); putchar('\n');
printf("(prime-1)/2 tested was: "); printf("sub tested was: ");
mp_fwrite(&b,16,stdout); mp_fwrite(&b,16,stdout);
putchar('\n'); putchar('\n');
return EXIT_FAILURE; return EXIT_FAILURE;
@ -747,7 +747,7 @@ int main(void)
16); 16);
err = mp_prime_strong_lucas_selfridge(&a, &cnt); err = mp_prime_strong_lucas_selfridge(&a, &cnt);
if (err != MP_OKAY) { if (err != MP_OKAY) {
printf("mp_prime_strong_lucas_selfridge failed with err code %d\n", err); printf("\nmp_prime_strong_lucas_selfridge failed with error: %s\n", mp_error_to_string(err));
printf("prime tested was: "); printf("prime tested was: ");
mp_fwrite(&a,16,stdout); mp_fwrite(&a,16,stdout);
putchar('\n'); putchar('\n');