zeek/testing/btest/bifs/join_string.bro
Johanna Amann 551a7d7394 Make join_string_vec work with vectors containing empty elements.
Without this patch, this scenario results in a segmentation fault.

I opted to keep the separator present for non-existing elements. Hence,
a vector a, [empty], b with separator "|" will result in
a||b
2015-10-22 13:08:47 -07:00

25 lines
622 B
Text

#
# @TEST-EXEC: bro -b %INPUT >out
# @TEST-EXEC: btest-diff out
event bro_init()
{
local a: string_array = {
[1] = "this", [2] = "is", [3] = "a", [4] = "test"
};
local b: string_array = { [1] = "mytest" };
local c: string_vec = vector( "this", "is", "another", "test" );
local d: string_vec = vector( "Test" );
local e: string_vec = vector();
e[3] = "hi";
e[5] = "there";
print join_string_array(" * ", a);
print join_string_array("", a);
print join_string_array("x", b);
print join_string_vec(c, "__");
print join_string_vec(c, "");
print join_string_vec(d, "-");
print join_string_vec(e, ".");
}