From a0807733be25c2988ff936a679327ceba5644696 Mon Sep 17 00:00:00 2001 From: Marco Pracucci Date: Mon, 3 Jun 2024 11:05:20 +0200 Subject: [PATCH] Improved tests Signed-off-by: Marco Pracucci --- model/labels/regexp.go | 3 +-- model/labels/regexp_test.go | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/model/labels/regexp.go b/model/labels/regexp.go index 9a9d846fd1..11fadc687c 100644 --- a/model/labels/regexp.go +++ b/model/labels/regexp.go @@ -389,9 +389,8 @@ func optimizeConcatRegex(r *syntax.Regexp) (prefix, suffix string, contains []st } // If contains any literal which is not a prefix/suffix, we keep track of - // all the ones which are case sensitive. + // all the ones which are case-sensitive. for i := 1; i < len(sub)-1; i++ { - // TODO if it's case insensitive we should return an contains list or is it safe to keep searching for case sensitive ones? if sub[i].Op == syntax.OpLiteral && (sub[i].Flags&syntax.FoldCase) == 0 { contains = append(contains, string(sub[i].Rune)) } diff --git a/model/labels/regexp_test.go b/model/labels/regexp_test.go index 0a75841c98..400b5721b7 100644 --- a/model/labels/regexp_test.go +++ b/model/labels/regexp_test.go @@ -84,11 +84,12 @@ var ( // Concat of literals and wildcards. ".*-.*-.*-.*-.*", "(.+)-(.+)-(.+)-(.+)-(.+)", - "((.*))-((.*))-((.*))-((.*))-((.*))", + "((.*))(?i:f)((.*))o((.*))o((.*))", + "((.*))f((.*))(?i:o)((.*))o((.*))", } values = []string{ "foo", " foo bar", "bar", "buzz\nbar", "bar foo", "bfoo", "\n", "\nfoo", "foo\n", "hello foo world", "hello foo\n world", "", - "FOO", "Foo", "OO", "Oo", "\nfoo\n", strings.Repeat("f", 20), "prometheus", "prometheus_api_v1", "prometheus_api_v1_foo", + "FOO", "Foo", "fOo", "foO", "OO", "Oo", "\nfoo\n", strings.Repeat("f", 20), "prometheus", "prometheus_api_v1", "prometheus_api_v1_foo", "10.0.1.20", "10.0.2.10", "10.0.3.30", "10.0.4.40", "foofoo0", "foofoo", "😀foo0",