improve trivial tests

This commit is contained in:
Steffen Jaeckel 2016-06-02 09:40:05 +02:00
parent 1c3aa803c4
commit 0b9e9b5b08
1 changed files with 20 additions and 0 deletions

View File

@ -184,7 +184,9 @@ int main(void)
#if LTM_DEMO_TEST_VS_MTEST == 0
// trivial stuff
// a: 0->5
mp_set_int(&a, 5);
// a: 5-> b: -5
mp_neg(&a, &b);
if (mp_cmp(&a, &b) != MP_GT) {
return EXIT_FAILURE;
@ -192,16 +194,34 @@ int main(void)
if (mp_cmp(&b, &a) != MP_LT) {
return EXIT_FAILURE;
}
// a: 5-> a: -5
mp_neg(&a, &a);
if (mp_cmp(&b, &a) != MP_EQ) {
return EXIT_FAILURE;
}
// a: -5-> b: 5
mp_abs(&a, &b);
if (mp_isneg(&b) != MP_NO) {
return EXIT_FAILURE;
}
// a: -5-> b: -4
mp_add_d(&a, 1, &b);
if (mp_isneg(&b) != MP_YES) {
return EXIT_FAILURE;
}
if (mp_get_int(&b) != 4) {
return EXIT_FAILURE;
}
// a: -5-> b: 1
mp_add_d(&a, 6, &b);
if (mp_get_int(&b) != 1) {
return EXIT_FAILURE;
}
// a: -5-> a: 1
mp_add_d(&a, 6, &a);
if (mp_get_int(&a) != 1) {
return EXIT_FAILURE;
}
mp_set_int(&a, 0);