github.com/jgbaldwinbrown/perf@v0.1.1/storage/query/query_test.go (about)

     1  // Copyright 2017 The Go Authors.  All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package query
     6  
     7  import (
     8  	"reflect"
     9  	"testing"
    10  )
    11  
    12  func TestSplitQueryWords(t *testing.T) {
    13  	for _, test := range []struct {
    14  		q    string
    15  		want []string
    16  	}{
    17  		{"hello world", []string{"hello", "world"}},
    18  		{"hello\\ world", []string{"hello world"}},
    19  		{`"key:value two" and\ more`, []string{"key:value two", "and more"}},
    20  		{`one" two"\ three four`, []string{"one two three", "four"}},
    21  		{`"4'7\""`, []string{`4'7"`}},
    22  	} {
    23  		have := SplitWords(test.q)
    24  		if !reflect.DeepEqual(have, test.want) {
    25  			t.Errorf("splitQueryWords(%q) = %+v, want %+v", test.q, have, test.want)
    26  		}
    27  	}
    28  }