mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Implemented a nearly generic Queue in scriptland.
This commit is contained in:
parent
257b460b18
commit
5b81cfe7e2
4 changed files with 224 additions and 0 deletions
35
testing/btest/scripts/base/utils/queue.test
Normal file
35
testing/btest/scripts/base/utils/queue.test
Normal file
|
@ -0,0 +1,35 @@
|
|||
# @TEST-EXEC: bro -b %INPUT > output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
||||
# This is loaded by default
|
||||
@load base/utils/queue
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local q = Queue::init([$max_len=2]);
|
||||
Queue::push(q, 1);
|
||||
Queue::push(q, 2);
|
||||
Queue::push(q, 3);
|
||||
Queue::push(q, 4);
|
||||
local test1 = Queue::get_cnt_vector(q);
|
||||
for ( i in test1 )
|
||||
print fmt("This is a get_cnt_vector test: %d", test1[i]);
|
||||
|
||||
local test2 = Queue::get_str_vector(q);
|
||||
for ( i in test2 )
|
||||
print fmt("This is a get_str_vector test: %s", test2[i]);
|
||||
|
||||
local test_val = Queue::pop(q);
|
||||
print fmt("Testing pop: %s", test_val);
|
||||
print fmt("Length after pop: %d", Queue::len(q));
|
||||
|
||||
local q2 = Queue::init([]);
|
||||
Queue::push(q2, "test 1");
|
||||
Queue::push(q2, "test 2");
|
||||
Queue::push(q2, "test 2");
|
||||
Queue::push(q2, "test 1");
|
||||
print fmt("Size of q2: %d", Queue::len(q2));
|
||||
local test3: vector of string = Queue::get_str_vector(q2);
|
||||
for ( i in test3 )
|
||||
print fmt("String queue value: %s", test3[i]);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue