zeek/testing/btest/bifs/haversine_distance.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

30 lines
888 B
Text

#
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
function test(la1: double, lo1: double, la2: double, lo2: double)
{
print fmt("%.4e", haversine_distance(la1, lo1, la2, lo2));
}
event zeek_init()
{
# Test two arbitrary locations.
test(37.866798, -122.253601, 48.25, 11.65);
# Swap the order of locations to verify the distance doesn't change.
test(48.25, 11.65, 37.866798, -122.253601);
# Distance of one second of latitude (crossing the equator).
test(.0001388889, 0, -.0001388889, 0);
# Distance of one second of longitude (crossing the prime meridian).
test(38, 0.000138999, 38, -0.000138999);
# Distance of one minute of longitude (test extreme longitude values).
test(38, 180, 38, -179.98333);
# Two locations on opposite ends of the Earth.
test(45, -90, -45, 90);
# Same, but verify that extreme latitude values work.
test(90, 0, -90, 0);
}