Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /*
2 * Simple test driver for MPI library
3 *
4 * Test 2: Basic addition and subtraction test
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <ctype.h>
14 #include <limits.h>
16 #include "mpi.h"
18 int main(int argc, char *argv[])
19 {
20 mp_int a, b, c;
22 if(argc < 3) {
23 fprintf(stderr, "Usage: %s <a> <b>\n", argv[0]);
24 return 1;
25 }
27 printf("Test 2: Basic addition and subtraction\n\n");
29 mp_init(&a);
30 mp_init(&b);
32 mp_read_radix(&a, argv[1], 10);
33 mp_read_radix(&b, argv[2], 10);
34 printf("a = "); mp_print(&a, stdout); fputc('\n', stdout);
35 printf("b = "); mp_print(&b, stdout); fputc('\n', stdout);
37 mp_init(&c);
38 printf("c = a + b\n");
40 mp_add(&a, &b, &c);
41 printf("c = "); mp_print(&c, stdout); fputc('\n', stdout);
43 printf("c = a - b\n");
45 mp_sub(&a, &b, &c);
46 printf("c = "); mp_print(&c, stdout); fputc('\n', stdout);
48 mp_clear(&c);
49 mp_clear(&b);
50 mp_clear(&a);
52 return 0;
53 }