-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSRS-test.cpp
49 lines (35 loc) · 1.06 KB
/
SRS-test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "SRS.hpp"
#include "Mailbox.hpp"
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <fmt/format.h>
#include <fmt/ostream.h>
void check_mbx(std::string_view mbx)
{
if (!Mailbox::validate(mbx))
LOG(ERROR) << "invalid mailbox: " << mbx;
}
int main(int argc, char* argv[])
{
std::ios::sync_with_stdio(false);
google::ParseCommandLineFlags(&argc, &argv, true);
SRS srs;
char const* sender = "[email protected]";
// libsrs seems to choke on Unicode in the domain
// char const* alias = "♥.digilicious.com";
char const* alias = "xn--g6h.digilicious.com";
char const* alias2 = "xn--g6h.example.com";
LOG(INFO) << "sender == " << sender;
LOG(INFO) << "alias == " << alias;
auto const fwd = srs.forward(sender, alias);
LOG(INFO) << " fwd == " << fwd;
auto const fwd2 = srs.forward(fwd.c_str(), alias2);
LOG(INFO) << " fwd2 == " << fwd2;
auto const rev = srs.reverse(fwd.c_str());
LOG(INFO) << " rev == " << rev;
check_mbx(sender);
check_mbx(fwd);
check_mbx(fwd2);
check_mbx(rev);
CHECK_EQ(rev, sender);
}