func TestValueAtPathFailure(t *testing.T) {
	var testCases = []struct {
		expect      []interface{}
		errContains string
		data        interface{}
		path        string
	}{
		{nil, "", data, "C.x"},
		{nil, "SyntaxError: Invalid token: tDot", data, ".x"},
		{nil, "", data, "X.Y.Z"},
		{nil, "", data, "A[100].C"},
		{nil, "", data, "A[3].C"},
		{nil, "", data, "B.B.C.Z"},
		{nil, "", data, "z[-1].C"},
		{nil, "", nil, "A.B.C"},
		{[]interface{}{}, "", Struct{}, "A"},
		{nil, "", data, "A[0].B.C"},
		{nil, "", data, "D"},
	}

	for i, c := range testCases {
		v, err := awsutil.ValuesAtPath(c.data, c.path)
		if c.errContains != "" {
			assert.Contains(t, err.Error(), c.errContains, "case %d, expected error, %s", i, c.path)
			continue
		} else {
			assert.NoError(t, err, "case %d, expected no error, %s", i, c.path)
		}
		assert.Equal(t, c.expect, v, "case %d, %s", i, c.path)
	}
}
func TestValueAtPathSuccess(t *testing.T) {
	var testCases = []struct {
		expect []interface{}
		data   interface{}
		path   string
	}{
		{[]interface{}{"initial"}, data, "C"},
		{[]interface{}{"value1"}, data, "A[0].C"},
		{[]interface{}{"value2"}, data, "A[1].C"},
		{[]interface{}{"value3"}, data, "A[2].C"},
		{[]interface{}{"value3"}, data, "a[2].c"},
		{[]interface{}{"value3"}, data, "A[-1].C"},
		{[]interface{}{"value1", "value2", "value3"}, data, "A[].C"},
		{[]interface{}{"terminal"}, data, "B . B . C"},
		{[]interface{}{"initial"}, data, "A.D.X || C"},
		{[]interface{}{"initial"}, data, "A[0].B || C"},
		{[]interface{}{
			Struct{A: []Struct{{C: "1"}, {C: "1"}, {C: "1"}, {C: "1"}, {C: "1"}}},
			Struct{A: []Struct{{C: "2"}, {C: "2"}, {C: "2"}, {C: "2"}, {C: "2"}}},
		}, data2, "A"},
	}
	for i, c := range testCases {
		v, err := awsutil.ValuesAtPath(c.data, c.path)
		assert.NoError(t, err, "case %d, expected no error, %s", i, c.path)
		assert.Equal(t, c.expect, v, "case %d, %s", i, c.path)
	}
}
// nextPageTokens returns the tokens to use when asking for the next page of
// data.
func (r *Request) nextPageTokens() []interface{} {
	if r.Operation.Paginator == nil {
		return nil
	}

	if r.Operation.TruncationToken != "" {
		tr, _ := awsutil.ValuesAtPath(r.Data, r.Operation.TruncationToken)
		if len(tr) == 0 {
			return nil
		}

		switch v := tr[0].(type) {
		case *bool:
			if !aws.BoolValue(v) {
				return nil
			}
		case bool:
			if v == false {
				return nil
			}
		}
	}

	tokens := []interface{}{}
	tokenAdded := false
	for _, outToken := range r.Operation.OutputTokens {
		v, _ := awsutil.ValuesAtPath(r.Data, outToken)
		if len(v) > 0 {
			tokens = append(tokens, v[0])
			tokenAdded = true
		} else {
			tokens = append(tokens, nil)
		}
	}
	if !tokenAdded {
		return nil
	}

	return tokens
}