explain
[ghsmtp.git] / CDB-test.cpp
blob96fa875f19f4bad6a8c3c998c33d3dfec06c9786
1 #include "CDB.hpp"
3 #include "osutil.hpp"
5 #include <glog/logging.h>
7 #include <cstdio>
8 #include <fstream>
9 #include <iostream>
10 #include <string>
12 using namespace std::string_literals;
14 int main(int argc, char* argv[])
16 auto const config_dir = osutil::get_config_dir();
18 auto const no_database = config_dir / "unable-to-open-database";
19 CDB no_db{no_database};
20 CHECK(!no_db.contains("foo"));
22 CDB accept_dom;
23 auto const accept_dom_path = config_dir / "accept_domains";
25 CHECK(accept_dom.open(accept_dom_path.c_str()));
27 // Ug, should not need c_str() here:
28 std::ifstream in(accept_dom_path.c_str(), std::ios::in | std::ios::binary);
30 if (!in.is_open())
31 std::perror(
32 ("error while opening file "s + accept_dom_path.string()).c_str());
34 std::string line;
35 getline(in, line);
36 if (in.bad())
37 perror(("error while reading file "s + accept_dom_path.string()).c_str());
38 in.close();
40 CHECK(accept_dom.contains(line));