Skip to content
Snippets Groups Projects
Commit e650fbf4 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Ported nettype.js from exec/bench to exec/tests

parent cbae5ab7
No related branches found
No related tags found
No related merge requests found
load('sbbsdefs.js');
function nettype(t)
{
switch(Number(t)) {
case NET_NONE: return "none";
case NET_UNKNOWN: return "unknown";
case NET_INTERNET: return "Internet";
case NET_QWK: return "QWKnet";
case NET_FIDO: return "FidoNet";
}
return format("???(%s)", t);
}
var test = [];
test[NET_NONE] = [
null,
undefined,
"",
" ",
"-",
" user@addr",
"user @host.name",
"user name@host.name",
];
test[NET_UNKNOWN] = [
"@user",
"user@addr ",
];
test[NET_INTERNET] = [
"user@192.168.1.2",
"user.name@1.2.3.4",
"user@host.name",
"user.name@host.name.tld",
];
test[NET_FIDO] = [
"user@1",
"user@1/2",
"user@1:2/3",
"user@1:2/3.4",
"user name @ 1:2/3",
];
test[NET_QWK] = [
"1@VERT",
"digital man@VERT",
"digital man @ VERT",
];
for(var t in test) {
for(var i in test[t]) {
var type = netaddr_type(test[t][i]);
if(type != t)
throw new Error(format("'%s'", test[t][i]) + ' = ' + nettype(type) + ' != ' + nettype(t));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment