NAWA  0.8
Web Application Framework for C++
email.cpp
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2019-2021 Tobias Flaig.
8  *
9  * This file is part of nawa.
10  *
11  * nawa is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License,
13  * version 3, as published by the Free Software Foundation.
14  *
15  * nawa is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with nawa. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
24 #include <catch2/catch.hpp>
25 #include <nawa/mail/EmailAddress.h>
26 
27 using namespace nawa;
28 using namespace std;
29 
30 TEST_CASE("nawa::mail::EmailAddress class", "[unit][email][emailaddress]") {
31  SECTION("Validity check") {
32  CHECK_FALSE(mail::EmailAddress("hello world@example.com").isValid());
33  CHECK(mail::EmailAddress("test@bärlin.xy").isValid());
34  }
35  SECTION("Correct representation") {
36  mail::EmailAddress ea1("John Doe", "john.doe@example.com");
37  mail::EmailAddress ea2("john.doe@example.com");
38  mail::EmailAddress ea3("test@bärlin.xy");
39  CHECK(ea1.get() == "John Doe <john.doe@example.com>");
40  CHECK(ea1.get(true) == "John Doe <john.doe@example.com>");
41  CHECK(ea1.get(false) == "<john.doe@example.com>");
42  CHECK(ea2.get(false) == "<john.doe@example.com>");
43  CHECK(ea2.get(true) == "<john.doe@example.com>");
44  CHECK(ea3.get() == "<test@xn--brlin-gra.xy>");
45  CHECK(ea3.get(false, false) == "<test@bärlin.xy>");
46  }
47 }
Structure representing an email address.
TEST_CASE("nawa::mail::EmailAddress class", "[unit][email][emailaddress]")
Definition: email.cpp:30
Definition: AppInit.h:31