~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/freebl/mpi/tests/mptest-2.c

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Simple test driver for MPI library
 
3
 *
 
4
 * Test 2: Basic addition and subtraction test
 
5
 *
 
6
 * The contents of this file are subject to the Mozilla Public
 
7
 * License Version 1.1 (the "License"); you may not use this file
 
8
 * except in compliance with the License. You may obtain a copy of
 
9
 * the License at http://www.mozilla.org/MPL/
 
10
 *
 
11
 * Software distributed under the License is distributed on an "AS
 
12
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
13
 * implied. See the License for the specific language governing
 
14
 * rights and limitations under the License.
 
15
 *
 
16
 * The Original Code is the MPI Arbitrary Precision Integer Arithmetic
 
17
 * library.
 
18
 *
 
19
 * The Initial Developer of the Original Code is Michael J. Fromberger.
 
20
 * Portions created by Michael J. Fromberger are 
 
21
 * Copyright (C) 1998, 1999, 2000 Michael J. Fromberger. 
 
22
 * All Rights Reserved.
 
23
 *
 
24
 * Contributor(s):
 
25
 *
 
26
 * Alternatively, the contents of this file may be used under the
 
27
 * terms of the GNU General Public License Version 2 or later (the
 
28
 * "GPL"), in which case the provisions of the GPL are applicable
 
29
 * instead of those above.  If you wish to allow use of your
 
30
 * version of this file only under the terms of the GPL and not to
 
31
 * allow others to use your version of this file under the MPL,
 
32
 * indicate your decision by deleting the provisions above and
 
33
 * replace them with the notice and other provisions required by
 
34
 * the GPL.  If you do not delete the provisions above, a recipient
 
35
 * may use your version of this file under either the MPL or the GPL.
 
36
 *
 
37
 *  $Id: mptest-2.c,v 1.1 2000/07/14 00:44:42 nelsonb%netscape.com Exp $
 
38
 */
 
39
 
 
40
#include <stdio.h>
 
41
#include <stdlib.h>
 
42
#include <string.h>
 
43
#include <ctype.h>
 
44
#include <limits.h>
 
45
 
 
46
#include "mpi.h"
 
47
 
 
48
int main(int argc, char *argv[])
 
49
{
 
50
  mp_int a, b, c;
 
51
 
 
52
  if(argc < 3) {
 
53
    fprintf(stderr, "Usage: %s <a> <b>\n", argv[0]);
 
54
    return 1;
 
55
  }
 
56
 
 
57
  printf("Test 2: Basic addition and subtraction\n\n");
 
58
 
 
59
  mp_init(&a);
 
60
  mp_init(&b);
 
61
 
 
62
  mp_read_radix(&a, argv[1], 10);
 
63
  mp_read_radix(&b, argv[2], 10);
 
64
  printf("a = "); mp_print(&a, stdout); fputc('\n', stdout);
 
65
  printf("b = "); mp_print(&b, stdout); fputc('\n', stdout);
 
66
  
 
67
  mp_init(&c);
 
68
  printf("c = a + b\n");
 
69
 
 
70
  mp_add(&a, &b, &c);
 
71
  printf("c = "); mp_print(&c, stdout); fputc('\n', stdout);
 
72
  
 
73
  printf("c = a - b\n");
 
74
  
 
75
  mp_sub(&a, &b, &c);
 
76
  printf("c = "); mp_print(&c, stdout); fputc('\n', stdout);  
 
77
 
 
78
  mp_clear(&c);
 
79
  mp_clear(&b);
 
80
  mp_clear(&a);
 
81
 
 
82
  return 0;
 
83
}