From 529f6b4856a7b68cd499f60e02419fc762299bf2 Mon Sep 17 00:00:00 2001 From: czechbol Date: Wed, 28 Aug 2024 16:35:01 +0200 Subject: [PATCH] add test case for len function Signed-off-by: czechbol --- testutils/g115_samples.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/testutils/g115_samples.go b/testutils/g115_samples.go index 028b36f2d0..be6313ddce 100644 --- a/testutils/g115_samples.go +++ b/testutils/g115_samples.go @@ -493,6 +493,23 @@ func foo(x int) uint32 { } return uint32(x) } +`, + }, 0, gosec.NewConfig()}, + {[]string{ + ` +package main + +import ( + "math" +) + +func foo(items []string) uint32 { + x := len(items) + if x > math.MaxUint32 { + return math.MaxUint32 + } + return uint32(x) +} `, }, 0, gosec.NewConfig()}, }