removed
[ghsmtp.git] / SRS-test.cpp
blob719cb1eefe42be2652267ba1316002167b0f383e
1 #include "SRS.hpp"
3 #include "Mailbox.hpp"
5 #include <gflags/gflags.h>
7 #include <glog/logging.h>
9 #include <fmt/format.h>
10 #include <fmt/ostream.h>
12 void check_mbx(std::string_view mbx)
14 if (!Mailbox::validate(mbx))
15 LOG(ERROR) << "invalid mailbox: " << mbx;
18 int main(int argc, char* argv[])
20 std::ios::sync_with_stdio(false);
21 google::ParseCommandLineFlags(&argc, &argv, true);
23 SRS srs;
25 char const* sender = "gene@digilicious.com";
26 // libsrs seems to choke on Unicode in the domain
27 // char const* alias = "♥.digilicious.com";
28 char const* alias = "xn--g6h.digilicious.com";
29 char const* alias2 = "xn--g6h.example.com";
31 LOG(INFO) << "sender == " << sender;
32 LOG(INFO) << "alias == " << alias;
34 auto const fwd = srs.forward(sender, alias);
35 LOG(INFO) << " fwd == " << fwd;
37 auto const fwd2 = srs.forward(fwd.c_str(), alias2);
38 LOG(INFO) << " fwd2 == " << fwd2;
40 auto const rev = srs.reverse(fwd.c_str());
41 LOG(INFO) << " rev == " << rev;
43 check_mbx(sender);
44 check_mbx(fwd);
45 check_mbx(fwd2);
46 check_mbx(rev);
48 CHECK_EQ(rev, sender);