MCPcopy Index your code
hub / github.com/go-openapi/jsonpointer / TestOffset

Function TestOffset

pointer_test.go:927–1051  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

925}
926
927func TestOffset(t *testing.T) {
928 t.Parallel()
929
930 cases := []struct {
931 name string
932 ptr string
933 input string
934 offset int64
935 hasError bool
936 }{
937 {
938 name: "object key",
939 ptr: "/foo/bar",
940 input: `{"foo": {"bar": 21}}`,
941 offset: 9,
942 },
943 {
944 name: "complex object key",
945 ptr: "/paths/~1p~1{}/get",
946 input: `{"paths": {"foo": {"bar": 123, "baz": {}}, "/p/{}": {"get": {}}}}`,
947 offset: 53,
948 },
949 {
950 name: "array index",
951 ptr: "/0/1",
952 input: `[[1,2], [3,4]]`,
953 offset: 4,
954 },
955 {
956 name: "mix array index and object key",
957 ptr: "/0/1/foo/0",
958 input: `[[1, {"foo": ["a", "b"]}], [3, 4]]`,
959 offset: 14,
960 },
961 {
962 name: "nonexist object key",
963 ptr: "/foo/baz",
964 input: `{"foo": {"bar": 21}}`,
965 hasError: true,
966 },
967 {
968 name: "nonexist array index",
969 ptr: "/0/2",
970 input: `[[1,2], [3,4]]`,
971 hasError: true,
972 },
973 {
974 name: "array element after nested object",
975 ptr: "/1",
976 input: `[{"x":1}, 42]`,
977 offset: 10,
978 },
979 {
980 name: "array element after nested array",
981 ptr: "/1",
982 input: `[[1,2], 42]`,
983 offset: 8,
984 },

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
OffsetMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…