forked from gadial/ECC
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.h
112 lines (99 loc) · 2.84 KB
/
tests.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* File: tests.h
* Author: gadial
*
* Created on November 15, 2009, 10:59 AM
*/
#ifndef _TESTS_H
#define _TESTS_H
#include <cppunit/extensions/HelperMacros.h>
#include "primes.h"
#include "ecprime.h"
#include "hcp.h"
#include "zp_int.h"
class PrimesTest : public CppUnit::TestFixture{
CPPUNIT_TEST_SUITE( PrimesTest );
CPPUNIT_TEST( test_is_odd );
CPPUNIT_TEST( test_small_primes );
CPPUNIT_TEST( test_legendre_symbol );
CPPUNIT_TEST( test_rand );
CPPUNIT_TEST( test_square_root );
CPPUNIT_TEST( test_generate_prime_for_discriminant );
CPPUNIT_TEST( test_is_near_prime );
CPPUNIT_TEST( test_extended_cornacchia );
CPPUNIT_TEST_SUITE_END();
private:
RandomNumberGenerator gen;
mpz_class p,q;
public:
void setUp();
void tearDown();
void test_is_odd();
void test_legendre_symbol();
void test_rand();
void test_square_root();
void test_small_primes();
void test_generate_prime_for_discriminant();
void test_is_near_prime();
void test_extended_cornacchia();
};
class EllipticCurveTest : public CppUnit::TestFixture{
CPPUNIT_TEST_SUITE( EllipticCurveTest );
CPPUNIT_TEST( test_doubling_vs_addition );
CPPUNIT_TEST( test_get_point );
CPPUNIT_TEST( test_repeated_doubling );
CPPUNIT_TEST( test_point_multiplication );
CPPUNIT_TEST( test_check_order );
CPPUNIT_TEST( test_coordinate_compressed_form );
CPPUNIT_TEST_SUITE_END();
private:
RandomNumberGenerator gen;
ECPrime random_curve;
public:
void setUp();
void tearDown();
void test_get_point();
void test_doubling_vs_addition();
void test_repeated_doubling();
void test_point_multiplication();
void test_check_order();
void test_coordinate_compressed_form();
};
class PolynomialTest : public CppUnit::TestFixture{
CPPUNIT_TEST_SUITE( PolynomialTest );
CPPUNIT_TEST( test_input_output );
CPPUNIT_TEST( test_addition_substraction );
CPPUNIT_TEST( test_multiplication );
CPPUNIT_TEST( test_divisons );
CPPUNIT_TEST( test_evaluations );
CPPUNIT_TEST( test_root_finding );
CPPUNIT_TEST_SUITE_END();
private:
#define ROOTS_ARRAY_LENGTH 8
RandomNumberGenerator gen;
mpz_class p;
NumberArray random_roots;
public:
void setUp();
void tearDown();
void test_input_output();
void test_addition_substraction();
void test_multiplication();
void test_divisons();
void test_evaluations();
void test_root_finding();
};
class ZpIntTest : public CppUnit::TestFixture{
CPPUNIT_TEST_SUITE( ZpIntTest );
CPPUNIT_TEST( test_arithmetic );
CPPUNIT_TEST_SUITE_END();
private:
#define NUMBER_ARRAY_LENGTH 100
RandomNumberGenerator gen;
zp_int numbers[NUMBER_ARRAY_LENGTH];
public:
void setUp();
void tearDown();
void test_arithmetic();
};
#endif /* _TESTS_H */