Reduce path formatting allocations
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package engine
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPathRoundTripsSemanticKeys(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -36,6 +39,13 @@ func TestPathRoundTripsSemanticKeys(t *testing.T) {
|
||||
if got := Keys("items").Index(12).Key("name").String(); got != "/items/12/name" {
|
||||
t.Fatalf("indexed path = %q", got)
|
||||
}
|
||||
maximum := int(^uint(0) >> 1)
|
||||
for _, index := range []int{100, maximum, -1, -maximum - 1} {
|
||||
want := "/items/" + strconv.Itoa(index)
|
||||
if got := Keys("items").Index(index).String(); got != want {
|
||||
t.Fatalf("indexed path = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPathPreservesSegmentIntentAndImmutability(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user