Browse Source

- added some tests to testsuite for payload

master
parent
commit
f039de433d
1 changed files with 38 additions and 10 deletions
  1. +38
    -10
      test/test_payload.cpp

+ 38
- 10
test/test_payload.cpp View File

@ -1,29 +1,57 @@
#define BOOST_TEST_MODULE TestPayload
#include <boost/test/unit_test.hpp>
#include <string>
#include <iostream>
namespace utf = boost::unit_test;
#include "payload.hpp"
#include <string>
using namespace std;
bool check_constructor(string dir) {
try {
Payload p( dir );
return true;
} catch (exception &e) {
return false;
}
try {
Payload p( dir );
return true;
} catch (exception &e) {
return false;
}
}
bool check_dir(string dir) {
bool check_validation(string dir) {
list<string> log;
Payload p( dir );
return p.validate( log);
}
bool check_relative_paths() {
Payload p( "../testbags/bag_minimal_ok/" );
list<string> results = p.get_all_relative_paths();
list<string> expected {
"../testbags/bag_minimal_ok/data/1.txt",
"../testbags/bag_minimal_ok/data/3.dat",
"../testbags/bag_minimal_ok/data/subdir/2.dat",
"../testbags/bag_minimal_ok/data/subdir/2.md5",
};
results.sort();
expected.sort();
list<string>::iterator i;
list<string>::iterator j;
bool is_valid = true;
for (i=results.begin(), j=expected.begin(); i!=results.end() && j!=expected.end(); i++, j++) {
if ((*i) != (*j)) {
cout << "Expected: "<< (*j) << " Result:"<< (*i) << endl;
is_valid = false;
break;
}
}
return is_valid;
}
BOOST_AUTO_TEST_CASE(constructor1) {BOOST_TEST(check_constructor(""));};
BOOST_AUTO_TEST_CASE(constructor2) {BOOST_TEST(check_constructor("./"));};
BOOST_AUTO_TEST_CASE(constructor3) {BOOST_TEST(check_constructor("/tmp/"));};
BOOST_AUTO_TEST_CASE(check_dir_ok) {BOOST_TEST(check_dir("../testbags/bag_minimal_ok/data"));};
BOOST_AUTO_TEST_CASE(check_dir_buggy) {BOOST_TEST(check_dir("../testbags/1008_buggy/data"));};
BOOST_AUTO_TEST_CASE(check_validation_ok) {BOOST_TEST(check_validation("../testbags/bag_minimal_ok/"));};
BOOST_AUTO_TEST_CASE(check_validation_buggy) {BOOST_TEST(check_validation("../testbags/1008_buggy/"));};
BOOST_AUTO_TEST_CASE(check_rel_paths) { BOOST_TEST(check_relative_paths()); };
// vim: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab

Loading…
Cancel
Save