mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 09:08:20 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/gh-839-fix-optional-subrecord-table-indices'
* origin/topic/jsiwek/gh-839-fix-optional-subrecord-table-indices: GH-839: Fix use of &optional sub-records within table/set indices
This commit is contained in:
commit
7393e13d67
5 changed files with 61 additions and 1 deletions
4
CHANGES
4
CHANGES
|
@ -1,3 +1,7 @@
|
|||
4.1.0-dev.669 | 2021-06-01 09:39:30 -0700
|
||||
|
||||
* GH-839: Fix use of &optional sub-records within table/set indices (Jon Siwek, Corelight)
|
||||
|
||||
4.1.0-dev.666 | 2021-05-26 10:51:51 -0700
|
||||
|
||||
* Ensure SessionAdapter members are initialized (Tim Wojtulewicz, Corelight)
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
4.1.0-dev.666
|
||||
4.1.0-dev.669
|
||||
|
|
|
@ -509,6 +509,9 @@ int CompositeHash::SingleTypeKeySize(Type* bt, const Val* v,
|
|||
|
||||
case TYPE_RECORD:
|
||||
{
|
||||
if ( ! v )
|
||||
return (optional && ! calc_static_size) ? sz : 0;
|
||||
|
||||
const RecordVal* rv = v ? v->AsRecordVal() : nullptr;
|
||||
RecordType* rt = bt->AsRecordType();
|
||||
int num_fields = rt->NumFields();
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
2, {
|
||||
[subrec=[str=hi]],
|
||||
[subrec=<uninitialized>]
|
||||
}
|
||||
T
|
||||
T
|
||||
T
|
||||
T
|
||||
T
|
||||
0, {
|
||||
|
||||
}
|
||||
T
|
||||
T
|
||||
T
|
||||
T
|
||||
T
|
35
testing/btest/language/table-optional-subrecord-index.zeek
Normal file
35
testing/btest/language/table-optional-subrecord-index.zeek
Normal file
|
@ -0,0 +1,35 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
# @TEST-DOC: Check functionality of a table/set index consisting of optional sub-records.
|
||||
|
||||
type SubRec: record {
|
||||
str: string;
|
||||
};
|
||||
|
||||
type Rec: record {
|
||||
subrec: SubRec &optional;
|
||||
};
|
||||
|
||||
global myset: set[Rec] = set();
|
||||
|
||||
local i = Rec();
|
||||
local j = Rec($subrec=SubRec($str="hi"));
|
||||
add myset[i];
|
||||
add myset[j];
|
||||
print |myset|, myset;
|
||||
|
||||
# All membership tests below are expected to evaluate to true.
|
||||
print i in myset;
|
||||
print j in myset;
|
||||
print Rec() in myset;
|
||||
print Rec($subrec=SubRec($str="hi")) in myset;
|
||||
print Rec($subrec=SubRec($str="no")) !in myset;
|
||||
|
||||
delete myset[i];
|
||||
delete myset[j];
|
||||
print |myset|, myset;
|
||||
print i !in myset;
|
||||
print j !in myset;
|
||||
print Rec() !in myset;
|
||||
print Rec($subrec=SubRec($str="hi")) !in myset;
|
||||
print Rec($subrec=SubRec($str="no")) !in myset;
|
Loading…
Add table
Add a link
Reference in a new issue