File: test_utils.h

package info (click to toggle)
fplll 5.5.0-1.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,984 kB
  • sloc: cpp: 21,104; javascript: 1,284; sh: 1,050; makefile: 198; perl: 46; python: 42
file content (31 lines) | stat: -rw-r--r-- 716 bytes parent folder | download | duplicates (2)
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
#ifndef TEST_UTILS_H
#define TEST_UTILS_H 

#include <fplll/fplll.h>
using namespace std;
using namespace fplll;

/**
   @brief Read T from `input_filename`.

   @param X T (T is usually a ZZ_mat<ZT> or a vector<Z_NR<ZT>>
   @param input_filename
   @return zero if the file is correctly read, 1 otherwise.
*/
template <class T> int read_file(T &X, const char *input_filename) {
  int status = 0;
  ifstream is;
  is.exceptions(std::ifstream::failbit | std::ifstream::badbit);
  try {
    is.open(input_filename);
    is >> X;
    is.close();
  }
  catch (const ifstream::failure&) {
    status = 1;
    cerr << "Error by reading " << input_filename << "." << endl;
  }

  return status;
}
#endif /* TEST_UTILS_H */