aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2019-10-15 12:33:13 +0200
committerAnders Broman <a.broman58@gmail.com>2019-10-16 07:41:11 +0000
commit03719942232965069a1fc67d262ab32ab9b7ca2a (patch)
treeb672b96618416e452b23e283da9b1d419f87f0b7 /test
parent3a9933c52fdbc6c941ded112eeadc71c786f8f64 (diff)
wslua: Improve parameter check in ProtoField.new()
Improve paremeter check in ProtoField.new() when using ftypes.CHAR: - Check valid base types and give an error when not supported instead of terminate in a g_error() (base.DEC is not supported). - Give an error if used with base.UNIT_STRING instead of silently remove the flags. - Support base.RANGE_STRING instead of removing the flag. Support using base.NONE with a valuestring. Add ftypes.CHAR to the list of supported types. Change-Id: I0e3f9698074c807f5da0de23ccd1be7446271135 Reviewed-on: https://code.wireshark.org/review/34783 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/lua/protofield.lua21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/lua/protofield.lua b/test/lua/protofield.lua
index 6b6110ddff..2fcfafb2fd 100644
--- a/test/lua/protofield.lua
+++ b/test/lua/protofield.lua
@@ -30,7 +30,7 @@ local function setFailed(name)
end
-- expected number of runs
-local taptests = { [OTHER]=32 }
+local taptests = { [OTHER]=38 }
local function getResults()
print("\n-----------------------------\n")
for k,v in pairs(taptests) do
@@ -72,6 +72,25 @@ test_proto.fields.time_field = ProtoField.uint16("test.time", "Time", base.UNIT_
test_proto.fields.dist_field = ProtoField.uint16("test.dist", "Distance", base.UNIT_STRING, {" km"})
test_proto.fields.filtered_field = ProtoField.uint16("test.filtered", "Filtered Field", base.DEC)
+-- Field type: CHAR
+success = pcall(ProtoField.new, "char", "test.char0", ftypes.CHAR)
+test("ProtoField-char", success)
+
+success = pcall(ProtoField.new, "char base NONE without valuestring", "test.char1", ftypes.CHAR, nil, base.NONE)
+test("ProtoField-char-without-valuestring", not success)
+
+success = pcall(ProtoField.new, "char base NONE with valuestring", "test.char2", ftypes.CHAR, {1, "Value"}, base.NONE)
+test("ProtoField-char-with-valuestring", success)
+
+success = pcall(ProtoField.new, "char base DEC", "test.char3", ftypes.CHAR, nil, base.DEC)
+test("ProtoField-char-base-dec", not success)
+
+success = pcall(ProtoField.new, "char base UNIT_STRING", "test.char4", ftypes.CHAR, {" m"}, base.UNIT_STRING)
+test("ProtoField-char-unit-string", not success)
+
+success = pcall(ProtoField.new, "char base RANGE_STRING", "test.char5", ftypes.CHAR, {{1, 2, "Value"}}, base.RANGE_STRING)
+test("ProtoField-char-range-string", success)
+
-- Field name: empty, illegal, incompatible
success = pcall(ProtoField.int8, nil, "empty field name 1")
test("ProtoField-empty-field-name-1", not success)