PALISADE Lattice Crypto Library
1.11.9
A lattice crypto library for software engineers by software engineers.
src
core
include
testdefs.h
1
// @file testdefs.h -- common unit test definitions
2
// @author TPOC: contact@palisade-crypto.org
3
//
4
// @copyright Copyright (c) 2019, New Jersey Institute of Technology (NJIT)
5
// All rights reserved.
6
// Redistribution and use in source and binary forms, with or without
7
// modification, are permitted provided that the following conditions are met:
8
// 1. Redistributions of source code must retain the above copyright notice,
9
// this list of conditions and the following disclaimer.
10
// 2. Redistributions in binary form must reproduce the above copyright notice,
11
// this list of conditions and the following disclaimer in the documentation
12
// and/or other materials provided with the distribution. THIS SOFTWARE IS
13
// PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
14
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
16
// EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
17
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
24
#ifndef TESTDEFS_H_
25
#define TESTDEFS_H_
26
27
#include "config_core.h"
28
29
// COMMON TESTING DEFINITIONS
30
extern
bool
TestB2;
31
extern
bool
TestB4;
32
#ifdef WITH_NTL
33
extern
bool
TestB6;
34
#endif
35
extern
bool
TestNative;
36
37
// macros for unit testing
38
#ifdef WITH_NTL
39
#define RUN_BIG_BACKENDS_INT(FUNCTION, MESSAGE) \
40
{ \
41
if (TestB2) { \
42
using T = M2Integer; \
43
FUNCTION<T>("BE2 " MESSAGE); \
44
} \
45
if (TestB4) { \
46
using T = M4Integer; \
47
FUNCTION<T>("BE4 " MESSAGE); \
48
} \
49
if (TestB6) { \
50
using T = M6Integer; \
51
FUNCTION<T>("BE6 " MESSAGE); \
52
} \
53
}
54
#define RUN_BIG_BACKENDS(FUNCTION, MESSAGE) \
55
{ \
56
if (TestB2) { \
57
using V = M2Vector; \
58
FUNCTION<V>("BE2 " MESSAGE); \
59
} \
60
if (TestB4) { \
61
using V = M4Vector; \
62
FUNCTION<V>("BE4 " MESSAGE); \
63
} \
64
if (TestB6) { \
65
using V = M6Vector; \
66
FUNCTION<V>("BE6 " MESSAGE); \
67
} \
68
}
69
#else
70
#define RUN_BIG_BACKENDS_INT(FUNCTION, MESSAGE) \
71
{ \
72
if (TestB2) { \
73
using T = M2Integer; \
74
FUNCTION<T>("BE2 " MESSAGE); \
75
} \
76
if (TestB4) { \
77
using T = M4Integer; \
78
FUNCTION<T>("BE4 " MESSAGE); \
79
} \
80
}
81
#define RUN_BIG_BACKENDS(FUNCTION, MESSAGE) \
82
{ \
83
if (TestB2) { \
84
using V = M2Vector; \
85
FUNCTION<V>("BE2 " MESSAGE); \
86
} \
87
if (TestB4) { \
88
using V = M4Vector; \
89
FUNCTION<V>("BE4 " MESSAGE); \
90
} \
91
}
92
#endif
93
94
#define RUN_NATIVE_BACKENDS_INT(FUNCTION, MESSAGE) \
95
{ \
96
if (TestNative) { \
97
{ \
98
using T = NativeInteger; \
99
FUNCTION<T>("Native " MESSAGE); \
100
} \
101
} \
102
}
103
104
#define RUN_NATIVE_BACKENDS(FUNCTION, MESSAGE) \
105
{ \
106
if (TestNative) { \
107
{ \
108
using V = NativeVector; \
109
FUNCTION<V>("Native " MESSAGE); \
110
} \
111
} \
112
}
113
114
#define RUN_ALL_BACKENDS(FUNCTION, MESSAGE) \
115
{ \
116
RUN_BIG_BACKENDS(FUNCTION, MESSAGE) \
117
RUN_NATIVE_BACKENDS(FUNCTION, MESSAGE) \
118
}
119
120
#define RUN_ALL_BACKENDS_INT(FUNCTION, MESSAGE) \
121
{ \
122
RUN_BIG_BACKENDS_INT(FUNCTION, MESSAGE) \
123
RUN_NATIVE_BACKENDS_INT(FUNCTION, MESSAGE) \
124
}
125
#endif
/* TESTDEFS_H_ */
Generated on Fri Dec 2 2022 21:02:06 for PALISADE Lattice Crypto Library by
1.8.13