ROOTPLOIT
Server: LiteSpeed
System: Linux in-mum-web1878.main-hosting.eu 5.14.0-570.21.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 11 07:22:35 EDT 2025 x86_64
User: u435929562 (435929562)
PHP: 7.4.33
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //proc/self/root/opt/go/pkg/mod/github.com/aws/[email protected]/internal/strings/strings_test.go
//go:build go1.7
// +build go1.7

package strings

import (
	"strings"
	"testing"
)

func TestHasPrefixFold(t *testing.T) {
	type args struct {
		s      string
		prefix string
	}
	tests := map[string]struct {
		args args
		want bool
	}{
		"empty strings and prefix": {
			args: args{
				s:      "",
				prefix: "",
			},
			want: true,
		},
		"strings starts with prefix": {
			args: args{
				s:      "some string",
				prefix: "some",
			},
			want: true,
		},
		"prefix longer then string": {
			args: args{
				s:      "some",
				prefix: "some string",
			},
		},
		"equal length string and prefix": {
			args: args{
				s:      "short string",
				prefix: "short string",
			},
			want: true,
		},
		"different cases": {
			args: args{
				s:      "ShOrT StRING",
				prefix: "short",
			},
			want: true,
		},
		"empty prefix not empty string": {
			args: args{
				s:      "ShOrT StRING",
				prefix: "",
			},
			want: true,
		},
		"mixed-case prefixes": {
			args: args{
				s:      "SoMe String",
				prefix: "sOme",
			},
			want: true,
		},
	}
	for name, tt := range tests {
		t.Run(name, func(t *testing.T) {
			if got := HasPrefixFold(tt.args.s, tt.args.prefix); got != tt.want {
				t.Errorf("HasPrefixFold() = %v, want %v", got, tt.want)
			}
		})
	}
}

func BenchmarkHasPrefixFold(b *testing.B) {
	HasPrefixFold("SoME string", "sOmE")
}

func BenchmarkHasPrefix(b *testing.B) {
	strings.HasPrefix(strings.ToLower("SoME string"), strings.ToLower("sOmE"))
}