forked from andreasbuhr/cppcoro
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathipv4_endpoint_tests.cpp
More file actions
33 lines (25 loc) · 1.11 KB
/
Copy pathipv4_endpoint_tests.cpp
File metadata and controls
33 lines (25 loc) · 1.11 KB
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
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) Lewis Baker
// Licenced under MIT license. See LICENSE.txt for details.
///////////////////////////////////////////////////////////////////////////////
#include <cppcoro/net/ipv4_endpoint.hpp>
#include "doctest/cppcoro_doctest.h"
TEST_SUITE_BEGIN("ip_endpoint");
using namespace cppcoro::net;
TEST_CASE("to_string")
{
CHECK(ipv4_endpoint{ ipv4_address{ 192, 168, 2, 254 }, 80 }.to_string() == "192.168.2.254:80");
}
TEST_CASE("from_string")
{
CHECK(ipv4_endpoint::from_string("") == std::nullopt);
CHECK(ipv4_endpoint::from_string(" ") == std::nullopt);
CHECK(ipv4_endpoint::from_string("100") == std::nullopt);
CHECK(ipv4_endpoint::from_string("100.10.200.20") == std::nullopt);
CHECK(ipv4_endpoint::from_string("100.10.200.20:") == std::nullopt);
CHECK(ipv4_endpoint::from_string("100.10.200.20::80") == std::nullopt);
CHECK(ipv4_endpoint::from_string("100.10.200.20 80") == std::nullopt);
CHECK(ipv4_endpoint::from_string("192.168.2.254:80") ==
ipv4_endpoint{ ipv4_address{ 192, 168, 2, 254 }, 80 });
}
TEST_SUITE_END();