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
|
// $Id: import10.cc 2845 2009-09-01 09:33:31Z rafi $
// Checks whether or not the import of import9 worked.
// Relies on test6.csv
#include <typeinfo>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <iostream>
#include <key.h>
#include <crypt.h>
#include <structs.h>
#include <record.h>
#include <partdec.h>
#include <file.h>
// Keep them define's here, since tests.h only defines the default if they are
// not predefined
#define ROUNDS 200
#define NAME "\"Test name %d"
#define HOST "Test host %d\""
#define UNAME "Test \"username %d"
#define PW "Test \"password\" %d"
#define COMMENT "Test \"\"comment %d\"\""
#include "tests.h"
#include "testpaths.h"
int main (int, char**) {
#ifndef TESTS_VERBOSE
int stdout_redir_fd = open("/dev/null", O_WRONLY | O_APPEND);
dup2(stdout_redir_fd,STDOUT_FILENO);
#endif
std::cout << std::endl;
std::cout << " ==> Check if import9 worked... " << std::endl;
try {
YAPET::Key key ("test6");
YAPET::File file ("test6.pet", key, false);
std::list<YAPET::PartDec> list = file.read (key);
if (list.size() != ROUNDS) {
std::cout << std::endl;
std::cout << " ==> no" << std::endl;
return 1;
}
std::list<YAPET::PartDec>::iterator it = list.begin();
for (int i = 0; it != list.end(); i++) {
check_record (*it, key, i);
it++;
}
} catch (std::exception& ex) {
std::cout << std::endl;
std::cout << " ==> no" << std::endl;
std::cout << typeid (ex).name() << ": " << ex.what() << std::endl;
return 1;
}
std::cout << std::endl;
std::cout << " ==> yes" << std::endl;
return 0;
}
|