From 742f17fb15bc7f7eb0ff55328cd11ce570239986 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Tue, 18 Feb 2025 10:08:57 +0100 Subject: [PATCH] Baseline handling of leading/trailing spaces in `to_count`/`to_int`. Currently `to_count` reports an error for trailing spaces (but not for leading ones) while `to_int` silently accepts them. This patch adds baselines capture the current behavior. --- testing/btest/Baseline/bifs.to_count/err | 3 ++- testing/btest/Baseline/bifs.to_count/out | 2 ++ testing/btest/Baseline/bifs.to_int/out | 2 ++ testing/btest/bifs/to_count.zeek | 3 +++ testing/btest/bifs/to_int.zeek | 3 +++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/testing/btest/Baseline/bifs.to_count/err b/testing/btest/Baseline/bifs.to_count/err index ab7985d22b..74d4bfa3f1 100644 --- a/testing/btest/Baseline/bifs.to_count/err +++ b/testing/btest/Baseline/bifs.to_count/err @@ -1,4 +1,5 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. error in <...>/to_count.zeek, line 8: bad conversion to count (int_to_count(a) and -2) error in <...>/to_count.zeek, line 20: bad conversion to count (to_count() and ) -error in <...>/to_count.zeek, line 22: bad conversion to count (to_count(not a count) and not a count) +error in <...>/to_count.zeek, line 24: bad conversion to count (to_count(206 ) and 206 ) +error in <...>/to_count.zeek, line 25: bad conversion to count (to_count(not a count) and not a count) diff --git a/testing/btest/Baseline/bifs.to_count/out b/testing/btest/Baseline/bifs.to_count/out index 0c99f6e402..5175a96dd3 100644 --- a/testing/btest/Baseline/bifs.to_count/out +++ b/testing/btest/Baseline/bifs.to_count/out @@ -6,6 +6,8 @@ 7 0 18446744073709551611 +205 +0 0 123 9223372036854775808 and 9223372036854775808 are the same diff --git a/testing/btest/Baseline/bifs.to_int/out b/testing/btest/Baseline/bifs.to_int/out index c0c6d56ef5..7ba7c89957 100644 --- a/testing/btest/Baseline/bifs.to_int/out +++ b/testing/btest/Baseline/bifs.to_int/out @@ -3,6 +3,8 @@ -1 4294967296 0 +205 +206 3 4 -3 diff --git a/testing/btest/bifs/to_count.zeek b/testing/btest/bifs/to_count.zeek index 2c20e0e7cb..1e1ed72c2e 100644 --- a/testing/btest/bifs/to_count.zeek +++ b/testing/btest/bifs/to_count.zeek @@ -19,6 +19,9 @@ event zeek_init() print to_count("7"); print to_count(""); print to_count("-5"); + # We automatically trim leading, but not trailing whitespace. + print to_count(" 205"); # Okay. + print to_count("206 "); # Error. print to_count("not a count"); local e: port = 123/tcp; diff --git a/testing/btest/bifs/to_int.zeek b/testing/btest/bifs/to_int.zeek index 3ad5eac7ae..82d789dcea 100644 --- a/testing/btest/bifs/to_int.zeek +++ b/testing/btest/bifs/to_int.zeek @@ -8,6 +8,9 @@ event zeek_init() print to_int("-1"); print to_int("4294967296"); print to_int("not an int"); + # We automatically trim leading, but not trailing whitespace. + print to_int(" 205"); # Okay. + print to_int("206 "); # Error. local a: double = 3.14; print double_to_int(a);