11package imagemonkeyquerylang
22
33import (
4- "testing"
5- "reflect"
6- "runtime"
74 "fmt"
85 "path/filepath"
6+ "reflect"
7+ "runtime"
8+ "testing"
99)
1010
1111// ok fails the test if an err is not nil.
@@ -35,95 +35,94 @@ func equals(tb testing.TB, exp, act interface{}) {
3535 }
3636}
3737
38-
39- func TestParserCorrect (t * testing.T ) {
38+ func TestParserCorrect (t * testing.T ) {
4039 queryParser := NewQueryParser ("a & b & c" )
4140 parseResult , err := queryParser .Parse ()
4241 if err != nil {
43- t .Errorf (err .Error ())
42+ t .Errorf ("%s" , err .Error ())
4443 }
4544 equals (t , len (parseResult .QueryValues ), 3 )
4645 equals (t , parseResult .QueryValues , []interface {}{"a" , "b" , "c" })
4746 equals (t , parseResult .Query , "q.accessors @> ARRAY[$1]::text[] AND q.accessors @> ARRAY[$2]::text[] AND q.accessors @> ARRAY[$3]::text[]" )
4847}
4948
50- func TestParserCorrectWithParentheses (t * testing.T ) {
49+ func TestParserCorrectWithParentheses (t * testing.T ) {
5150 queryParser := NewQueryParser ("(a & b & c)" )
5251 parseResult , err := queryParser .Parse ()
5352 if err != nil {
54- t .Errorf (err .Error ())
53+ t .Errorf ("%s" , err .Error ())
5554 }
5655 equals (t , len (parseResult .QueryValues ), 3 )
5756 equals (t , parseResult .QueryValues , []interface {}{"a" , "b" , "c" })
5857 equals (t , parseResult .Query , "(q.accessors @> ARRAY[$1]::text[] AND q.accessors @> ARRAY[$2]::text[] AND q.accessors @> ARRAY[$3]::text[])" )
5958}
6059
61- func TestParserCorrectWithMultipleParentheses (t * testing.T ) {
60+ func TestParserCorrectWithMultipleParentheses (t * testing.T ) {
6261 queryParser := NewQueryParser ("(a & (b | c))" )
6362 parseResult , err := queryParser .Parse ()
6463 if err != nil {
65- t .Errorf (err .Error ())
64+ t .Errorf ("%s" , err .Error ())
6665 }
6766 equals (t , len (parseResult .QueryValues ), 3 )
6867 equals (t , parseResult .QueryValues , []interface {}{"a" , "b" , "c" })
6968 equals (t , parseResult .Query , "(q.accessors @> ARRAY[$1]::text[] AND (q.accessors @> ARRAY[$2]::text[] OR q.accessors @> ARRAY[$3]::text[]))" )
7069}
7170
72- func TestParserCorrectWithMultipleParentheses2 (t * testing.T ) {
71+ func TestParserCorrectWithMultipleParentheses2 (t * testing.T ) {
7372 queryParser := NewQueryParser ("(a | (b | c))" )
7473 parseResult , err := queryParser .Parse ()
7574 if err != nil {
76- t .Errorf (err .Error ())
75+ t .Errorf ("%s" , err .Error ())
7776 }
7877 equals (t , len (parseResult .QueryValues ), 3 )
7978 equals (t , parseResult .QueryValues , []interface {}{"a" , "b" , "c" })
8079 equals (t , parseResult .Query , "(q.accessors @> ARRAY[$1]::text[] OR (q.accessors @> ARRAY[$2]::text[] OR q.accessors @> ARRAY[$3]::text[]))" )
8180}
8281
83- func TestParserCorrectWithMultipleParentheses3 (t * testing.T ) {
82+ func TestParserCorrectWithMultipleParentheses3 (t * testing.T ) {
8483 queryParser := NewQueryParser ("((a | (b | c)))" )
8584 parseResult , err := queryParser .Parse ()
8685 if err != nil {
87- t .Errorf (err .Error ())
86+ t .Errorf ("%s" , err .Error ())
8887 }
8988 equals (t , len (parseResult .QueryValues ), 3 )
9089 equals (t , parseResult .QueryValues , []interface {}{"a" , "b" , "c" })
9190 equals (t , parseResult .Query , "((q.accessors @> ARRAY[$1]::text[] OR (q.accessors @> ARRAY[$2]::text[] OR q.accessors @> ARRAY[$3]::text[])))" )
9291}
9392
94- func TestParserIncorrectSyntax (t * testing.T ) {
93+ func TestParserIncorrectSyntax (t * testing.T ) {
9594 queryParser := NewQueryParser ("a & b & |" )
9695 _ , err := queryParser .Parse ()
9796 if err == nil {
9897 t .Errorf ("Expected not nil, but got nil" )
9998 }
10099}
101100
102- func TestParserIncorrectSyntax2 (t * testing.T ) {
101+ func TestParserIncorrectSyntax2 (t * testing.T ) {
103102 queryParser := NewQueryParser ("a |" )
104103 _ , err := queryParser .Parse ()
105104 if err == nil {
106105 t .Errorf ("Expected not nil, but got nil" )
107106 }
108107}
109108
110- func TestParserIncorrectBrackets (t * testing.T ) {
109+ func TestParserIncorrectBrackets (t * testing.T ) {
111110 queryParser := NewQueryParser ("a & b & )" )
112111 _ , err := queryParser .Parse ()
113112 if err == nil {
114113 t .Errorf ("Expected not nil, but got nil" )
115114 }
116115}
117116
118- func TestParserIncorrectLength (t * testing.T ) {
117+ func TestParserIncorrectLength (t * testing.T ) {
119118 queryParser := NewQueryParser ("a & b & c & d & e & f & f & g & h & z & u)" )
120119 _ , err := queryParser .Parse ()
121120 if err == nil {
122121 t .Errorf ("Expected not nil, but got nil" )
123122 }
124123}
125124
126- func TestParserKeepWhitespacesInAssigment (t * testing.T ) {
125+ func TestParserKeepWhitespacesInAssigment (t * testing.T ) {
127126 queryParser := NewQueryParser ("a | b.c = 'hello world'" )
128127 parseResult , err := queryParser .Parse ()
129128 if err != nil {
@@ -134,7 +133,7 @@ func TestParserKeepWhitespacesInAssigment(t *testing.T) {
134133 equals (t , parseResult .Query , "q.accessors @> ARRAY[$1]::text[] OR q.accessors @> ARRAY[$2]::text[]" )
135134}
136135
137- func TestParserKeepWhitespacesInAssigmentWithMultipleSpacesBefore (t * testing.T ) {
136+ func TestParserKeepWhitespacesInAssigmentWithMultipleSpacesBefore (t * testing.T ) {
138137 queryParser := NewQueryParser ("a | b.c = 'hello world'" )
139138 parseResult , err := queryParser .Parse ()
140139 if err != nil {
@@ -145,15 +144,15 @@ func TestParserKeepWhitespacesInAssigmentWithMultipleSpacesBefore(t *testing.T)
145144 equals (t , parseResult .Query , "q.accessors @> ARRAY[$1]::text[] OR q.accessors @> ARRAY[$2]::text[]" )
146145}
147146
148- func TestParserAssignment (t * testing.T ) {
147+ func TestParserAssignment (t * testing.T ) {
149148 queryParser := NewQueryParser ("hello='world'" )
150149 _ , err := queryParser .Parse ()
151150 if err != nil {
152151 t .Errorf ("Expected nil, but got not nil: %s" , err .Error ())
153152 }
154153}
155154
156- func TestParserAssignment1 (t * testing.T ) {
155+ func TestParserAssignment1 (t * testing.T ) {
157156 queryParser := NewQueryParser ("a & hello='big world'" )
158157 _ , err := queryParser .Parse ()
159158 if err != nil {
0 commit comments