5 #include <glog/logging.h>
7 int main(int argc
, char const* argv
[])
9 std::string
const d
{"example.com."};
11 CHECK(Domain::match(d
, "EXAMPLE.COM"));
12 CHECK(Domain::match(d
, "example.com."));
14 CHECK(!Domain::match(d
, "example.co"));
15 CHECK(!Domain::match(d
, "example.com.."));
16 CHECK(!Domain::match(d
, ""));
17 CHECK(!Domain::match(d
, "."));
19 std::string
const d3
{""};
21 CHECK(Domain::match(d3
, ""));
22 CHECK(Domain::match(d3
, "."));
24 CHECK(!Domain::match(d3
, "example.com"));
26 Domain
const dom
{"example.com"};
27 CHECK_EQ(dom
, Domain("EXAMPLE.COM"));
29 Domain
const dom2
{"黒川.日本"};
30 Domain
const dom3
{"xn--5rtw95l.xn--wgv71a"};
33 Domain
const poop1
{"💩.la"};
34 Domain
const poop2
{"xn--ls8h.la"};
35 CHECK_EQ(poop1
, poop2
);
37 Domain
const norm0
{"hi⒌com"}; // non-ascii "dot" before "com"
38 Domain
const norm1
{"hi5.com"};
40 CHECK_EQ(norm0
, norm1
);
42 CHECK(Domain::validate("hi⒌com"));
43 CHECK(Domain::validate("hi5.com"));
46 // CHECK(!Domain::validate("$?%^&*("));
49 Domain
const junk
{"$?%^&*("};
51 // LOG(FATAL) << "should have thrown";
53 catch (std::exception
const& ex
) {
54 std::cout
<< ex
.what() << '\n';
58 Domain
const ip_addr
{"[127.0.0.1]"};
59 CHECK(ip_addr
.is_address_literal());
61 catch (std::exception
const& ex
) {
62 LOG(FATAL
) << "should not throw " << ex
.what();
66 Domain
const ip_addr
{"127.0.0.1"};
67 CHECK(ip_addr
.is_address_literal());
69 catch (std::exception
const& ex
) {
70 LOG(FATAL
) << "should not throw " << ex
.what();
73 Domain
const mixed_case
{"ExAmPle.COM"};
74 CHECK_EQ(mixed_case
.ascii(), "example.com");
76 for (auto arg
{1}; arg
< argc
; ++arg
) {
77 Domain
const a
{argv
[arg
]};
78 std::cout
<< a
<< '\n';