00001 #include "config.h"
00002
00003 #include <iostream>
00004 #include <string>
00005 #include <cassert>
00006
00007 #ifdef HAVE_UNISTD_H
00008 #include <unistd.h>
00009 #endif
00010
00011 #include <errno.h>
00012
00013 #include "asserts.h"
00014 #include "types.h"
00015 #include "error.h"
00016 #include "estring.h"
00017 #include "fs.h"
00018 #include "tstamp.h"
00019 #include "rconfig.h"
00020 #include "test-rconfig-setup.h"
00021
00022 #define ERR_OUT(e) std::cerr << e;
00023
00024
00025 void test(void)
00026 {
00027 char const * argv[256] = { 0 };
00028 int argc = 0;
00029
00030
00031 argv[argc++] = "<program>";
00032 argv[argc++] = "--archive";
00033
00034 config.default_file("./test-rconfig.dir/global-vault-2.dir/file-1.conf");
00035 config.default_logdir("./test-rconfig.dir/log.dir");
00036 std::cerr << std::endl;
00037 std::cerr << " You should see an error message here:" << std::endl;
00038 std::cerr << "-----------------------------------------" << std::endl;
00039 try {
00040 config.init(argc, argv);
00041 }
00042 catch(error e) {
00043 ERR_OUT(e);
00044 assert(0);
00045
00046 }
00047 catch(...) {
00048 assert(0);
00049 }
00050 std::cerr << "-----------------------------------------" << std::endl;
00051 std::cerr << std::endl;
00052
00053 assert(config.vaults().size() == 3);
00054 assert(config.vaults()[0]
00055 == "./test-rconfig.dir/global-vault-2.dir/vaults/1");
00056 assert(config.vaults()[1]
00057 == "./test-rconfig.dir/global-vault-2.dir/vaults/3");
00058 assert(config.vaults()[2]
00059 == "./test-rconfig.dir/global-vault-2.dir/vaults/4");
00060 }
00061
00062 int main(int argc, char const * argv[])
00063 {
00064 cleanup();
00065 setup();
00066 try {
00067 test();
00068 }
00069 catch(error e) {
00070 std::cerr << e;
00071 assert(0);
00072 }
00073 catch(...) {
00074 std::cerr << err_unknown;
00075 assert(0);
00076 }
00077 cleanup();
00078 return(0);
00079 }
00080