API for mailbox parsing
[ghsmtp.git] / SRS-test.cpp
blobc67553200cfa1263e6a497c2fc395547e3c7bd20
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 char const* alias = "♥.digilicious.com";
27 char const* alias2 = "xn--g6h.digilicious.com";
29 auto const fwd = srs.forward(sender, alias);
30 auto const fwd2 = srs.forward(fwd.c_str(), alias2);
31 auto const rev = srs.reverse(fwd.c_str());
33 LOG(INFO) << "sender == " << sender;
34 LOG(INFO) << "alias == " << alias;
35 LOG(INFO) << " fwd == " << fwd;
36 LOG(INFO) << " fwd2 == " << fwd2;
37 LOG(INFO) << " rev == " << rev;
39 check_mbx(sender);
40 check_mbx(fwd);
41 check_mbx(fwd2);
42 check_mbx(rev);
44 CHECK_EQ(rev, sender);