-
Notifications
You must be signed in to change notification settings - Fork 2
/
smtp-tests.cpp
38 lines (27 loc) · 1.08 KB
/
smtp-tests.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
/**
Copyright 2011-2019 Red Anchor Trading Co. Ltd.
Distributed under the Boost Software License, Version 1.0.
See <http://www.boost.org/LICENSE_1_0.txt>
*/
#include "fost-inet-test.hpp"
#include <fost/mime.hpp>
using namespace fostlib;
FSL_TEST_SUITE(smtp);
FSL_TEST_FUNCTION(email_address_without_name) {
fostlib::json e1("test@example.com");
fostlib::email_address a1 = fostlib::coerce<fostlib::email_address>(e1);
FSL_CHECK(not a1.name());
FSL_CHECK_EQ(a1.email(), "test@example.com");
}
FSL_TEST_FUNCTION(email_address_with_name) {
fostlib::json e1("Test account<test@example.com>");
fostlib::email_address a1 = fostlib::coerce<fostlib::email_address>(e1);
FSL_CHECK(a1.name());
FSL_CHECK_EQ(a1.name().value(), "Test account");
FSL_CHECK_EQ(a1.email(), "test@example.com");
fostlib::json e2("Test account <test@example.com>");
fostlib::email_address a2 = fostlib::coerce<fostlib::email_address>(e2);
FSL_CHECK(a2.name());
FSL_CHECK_EQ(a2.name().value(), "Test account");
FSL_CHECK_EQ(a2.email(), "test@example.com");
}