zeek/testing/btest/language/time.zeek
Robin Sommer 789cb376fd GH-239: Rename bro to zeek, bro-config to zeek-config, and bro-path-dev to zeek-path-dev.
This also installs symlinks from "zeek" and "bro-config" to a wrapper
script that prints a deprecation warning.

The btests pass, but this is still WIP. broctl renaming is still
missing.

#239
2019-05-01 21:43:45 +00:00

33 lines
768 B
Text

# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
function test_case(msg: string, expect: bool)
{
print fmt("%s (%s)", msg, expect ? "PASS" : "FAIL");
}
event zeek_init()
{
local t1: time = current_time();
local t2: time = t1 + 3 sec;
local t3: time = t2 - 10 sec;
local t4: time = t1;
local t5: time = double_to_time(1234567890);
local t6 = current_time();
# Type inference test
test_case( "type inference", type_name(t6) == "time" );
# Operator tests
test_case( "add interval", t1 < t2 );
test_case( "subtract interval", t1 > t3 );
test_case( "inequality", t1 != t3 );
test_case( "equality", t1 == t4 );
test_case( "subtract time", t2 - t1 == 3sec);
test_case( "size operator", |t5| == 1234567890.0 );
}