From b1e37119da439b52a2c1f1aca4df2fdc80462f97 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Thu, 30 Oct 2025 11:04:23 -0700 Subject: Remove the regexes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wow it doesn't look good for regex goos: linux goarch: amd64 pkg: roseh.moe/pkg/ccl cpu: AMD Ryzen 9 5900X 12-Core Processor │ baseline.txt │ regexn't.txt │ │ sec/op │ sec/op vs base │ Lex-24 8.625µ ± 1% 1.429µ ± 0% -83.43% (p=0.000 n=20) Parse-24 18.305µ ± 0% 8.856µ ± 0% -51.62% (p=0.000 n=20) geomean 12.57µ 3.557µ -71.69% --- ccl_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'ccl_test.go') diff --git a/ccl_test.go b/ccl_test.go index 628009d..938af09 100644 --- a/ccl_test.go +++ b/ccl_test.go @@ -259,6 +259,10 @@ can just span multiple lines"`, desc: "StringUnicode", msg: `string: '\u2014'`, want: message{String: "—"}, + }, { + desc: "StringBigUnicode", + msg: `string: '\U0001f600'`, + want: message{String: "😀"}, }, { desc: "StringOctal", msg: `string: '\033'`, @@ -357,6 +361,7 @@ func TestUnmarshal_Invalid(t *testing.T) { type message struct { Int int64 `ccl:"int"` Int8 int8 `ccl:"int8"` + Float float64 `ccl:"float"` String string `ccl:"string"` Msg nestedMessage `ccl:"msg"` Repeated []int64 `ccl:"repeated"` @@ -371,12 +376,33 @@ func TestUnmarshal_Invalid(t *testing.T) { }{{ desc: "BadNum", msg: `int: .`, + }, { + desc: "WeirdNum", + msg: `float:1e+`, + }, { + desc: "BadHex", + msg: `int:0xgg`, }, { desc: "BadStringEscape", msg: `string: '\g'`, }, { desc: "BadDoubleStringEscape", msg: `string: "\g"`, + }, { + desc: "StringBadReturnEscape", + msg: "string:'\\\r'", + }, { + desc: "StringShortHex", + msg: `string:"\x1"`, + }, { + desc: "StringBadHex", + msg: `string:"\xgg"`, + }, { + desc: "StringShortUnicode", + msg: `string:"\u001"`, + }, { + desc: "StringBadUnicode", + msg: `string:"\ugggg"`, }, { desc: "UnterminatedString", msg: `string: '`, -- cgit v1.3.1