NAWA 0.9
Web Application Framework for C++
email.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019-2022 Tobias Flaig.
3 *
4 * This file is part of nawa.
5 *
6 * nawa is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License,
8 * version 3, as published by the Free Software Foundation.
9 *
10 * nawa is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with nawa. If not, see <https://www.gnu.org/licenses/>.
17 */
18
24#include <catch2/catch.hpp>
26
27using namespace nawa;
28using namespace std;
29
30TEST_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