30 lines
742 B
C++
30 lines
742 B
C++
|
|
#include "driver-util.hpp"
|
|
#include "luastack.hpp"
|
|
|
|
namespace drv {
|
|
|
|
void split_host_port(std::string_view target, UmmString &host, UmmString &port) {
|
|
size_t lastcolon = target.rfind(':');
|
|
if (lastcolon == std::string_view::npos) {
|
|
host = ""; port = ""; return;
|
|
}
|
|
host = target.substr(0, lastcolon);
|
|
port = target.substr(lastcolon + 1);
|
|
if ((host == "") || (port == "")) {
|
|
host = ""; port = ""; return;
|
|
}
|
|
}
|
|
|
|
} // namespace drv
|
|
|
|
LuaDefine(unittests_driverutil, "", "some unit tests") {
|
|
// Test split_host_port
|
|
UmmString host, port;
|
|
drv::split_host_port("stanford.edu:80", host, port);
|
|
LuaAssertStrEq(L, host, "stanford.edu");
|
|
LuaAssertStrEq(L, port, "80");
|
|
|
|
return 0;
|
|
}
|