Cryptography Reference
In-Depth Information
CHAPTER 18
Do It Yourself:
Test LINT
90% of the time is spent in 10% of the code.
—Robert Sedgewick, Algorithms
W E HAVE ALREADY DISCUSSED THE topic of testing in Chapter 13, where we subjected
the basic arithmetic functions of the first part of the topic to extensive static and
dynamic tests. We now require a similar treatment for the validation of the C++
class LINT , and furthermore, we still must provide tests of the number-theoretic C
functions.
The approach of the static tests can be carried over directly to the LINT class,
where the tool PC-lint (see [Gimp]) used for the static analysis of C functions will
stand us here in good stead as well, since we can use it for checking the syntactic
correctness and (within certain bounds) the semantic plausibility of the LINT class
and its elements.
We are also interested in the functional aspects of our class implementation:
We must demonstrate that the methods contained in LINT return correct results.
The process that we used earlier, where the results of equivalent or mutually
inverse operations were used to establish correctness, can also, of course, be
used on C++ functions. In the following example this process is embodied in
the function testdist() , which links addition and multiplication by way of the
distributive law. Even here one can see how much less syntactic complication
is needed in comparison with the test functions in C. The test function consists
principally of two lines of code!
#include <stdio.h>
#include <stdlib.h>
#include "flintpp.h"
void report_error (LINT&, LINT&, LINT&, int);
void testdist (int);
#define MAXTESTLEN CLINTMAXBIT
#define CLINTRNDLN (ulrand64_l()% (MAXTESTLEN + 1))
 
Search WWH ::




Custom Search