fix(mdns): don't hardcode mDNS instance name (#3084)
This commit is contained in:
parent
f048510ef7
commit
88ce5077b0
6 changed files with 71 additions and 5 deletions
26
tests/unit/test_network.cpp
Normal file
26
tests/unit/test_network.cpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* @file tests/unit/test_network.cpp
|
||||
* @brief Test src/network.*
|
||||
*/
|
||||
#include <src/network.h>
|
||||
|
||||
#include "../tests_common.h"
|
||||
|
||||
struct MdnsInstanceNameTest: testing::TestWithParam<std::tuple<std::string, std::string>> {};
|
||||
|
||||
TEST_P(MdnsInstanceNameTest, Run) {
|
||||
auto [input, expected] = GetParam();
|
||||
ASSERT_EQ(net::mdns_instance_name(input), expected);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
MdnsInstanceNameTests,
|
||||
MdnsInstanceNameTest,
|
||||
testing::Values(
|
||||
std::make_tuple("shortname-123", "shortname-123"),
|
||||
std::make_tuple("space 123", "space-123"),
|
||||
std::make_tuple("hostname.domain.test", "hostname"),
|
||||
std::make_tuple("&", "Sunshine"),
|
||||
std::make_tuple("", "Sunshine"),
|
||||
std::make_tuple("😁", "Sunshine"),
|
||||
std::make_tuple(std::string(128, 'a'), std::string(63, 'a'))));
|
||||
Loading…
Add table
Add a link
Reference in a new issue