Improve tests for to_port and type_name BIFs

This commit is contained in:
Daniel Thayer 2012-05-31 15:19:11 -05:00
parent 5f16a29aea
commit 2c62b98b5b
4 changed files with 37 additions and 19 deletions

View file

@ -1,6 +1,7 @@
123/tcp 123/tcp
123/udp 123/udp
123/icmp 123/icmp
0/unknown
256/tcp 256/tcp
256/udp 256/udp
256/icmp 256/icmp

View file

@ -1,5 +1,6 @@
string string
count count
int
double double
bool bool
time time
@ -18,3 +19,8 @@ set[string]
table[count] of string table[count] of string
table[string] of count table[string] of count
record { c:count; s:string; } record { c:count; s:string; }
function(aa:int; bb:int;) : bool
function() : any
function() : void
file of string
event()

View file

@ -7,6 +7,7 @@ event bro_init()
print to_port("123/tcp"); print to_port("123/tcp");
print to_port("123/udp"); print to_port("123/udp");
print to_port("123/icmp"); print to_port("123/icmp");
print to_port("not a port");
local a: transport_proto = tcp; local a: transport_proto = tcp;
local b: transport_proto = udp; local b: transport_proto = udp;

View file

@ -13,24 +13,29 @@ event bro_init()
{ {
local a = "foo"; local a = "foo";
local b = 3; local b = 3;
local c = 3.14; local c = -3;
local d = T; local d = 3.14;
local e = current_time(); local e = T;
local f = 5hr; local f = current_time();
local g = /^foo|bar/; local g = 5hr;
local h = Blue; local h = /^foo|bar/;
local i = 123/tcp; local i = Blue;
local j = 192.168.0.2; local j = 123/tcp;
local k = [fe80::1]; local k = 192.168.0.2;
local l = 192.168.0.0/16; local l = [fe80::1];
local m = [fe80:1234::]/32; local m = 192.168.0.0/16;
local n = vector( 1, 2, 3); local n = [fe80:1234::]/32;
local o = vector( "bro", "test"); local o = vector( 1, 2, 3);
local p = set( 1, 2, 3); local p: vector of string = vector( "bro", "test" );
local q = set( "this", "test"); local q = set( 1, 2, 3);
local r: table[count] of string = { [1] = "test", [2] = "bro" }; local r = set( "this", "test");
local s: table[string] of count = { ["a"] = 5, ["b"] = 3 }; local s: table[count] of string = { [1] = "test", [2] = "bro" };
local t: myrecord = [ $c = 2, $s = "another test" ]; local t: table[string] of count = { ["a"] = 5, ["b"] = 3 };
local u: myrecord = [ $c = 2, $s = "another test" ];
local v = function(aa: int, bb: int): bool { return aa < bb; };
local w = function(): any { };
local x = function() { };
local y = open("deleteme");
print type_name(a); print type_name(a);
print type_name(b); print type_name(b);
@ -52,5 +57,10 @@ event bro_init()
print type_name(r); print type_name(r);
print type_name(s); print type_name(s);
print type_name(t); print type_name(t);
print type_name(u);
print type_name(v);
print type_name(w);
print type_name(x);
print type_name(y);
print type_name(bro_init);
} }