@@ -88,101 +88,107 @@ endfunc
8888
8989" Tests for string and html text objects
9090func Test_string_html_objects ()
91- enew !
9291
93- let t = ' "wo\"rd\\" foo'
94- put = t
95- normal ! da"
96- call assert_equal (' foo' , getline (' .' ))
97-
98- let t = " 'foo' 'bar' 'piep'"
99- put = t
100- normal ! 0 va' a' rx
101- call assert_equal (" xxxxxxxxxxxx'piep'" , getline (' .' ))
102-
103- let t = " bla bla `quote` blah"
104- put = t
105- normal ! 02 f`da`
106- call assert_equal (" bla bla blah" , getline (' .' ))
107-
108- let t = ' out " in "noXno"'
109- put = t
110- normal ! 0 fXdi"
111- call assert_equal (' out " in ""' , getline (' .' ))
112-
113- let t = " \" '\" 'blah' rep 'buh'"
114- put = t
115- normal ! 03 f' vi' ry
116- call assert_equal (" \" '\" 'blah'yyyyy'buh'" , getline (' .' ))
117-
118- set quoteescape = +*-
119- let t = " bla `s*`d-`+++`l**` b`la"
120- put = t
121- normal ! di `
122- call assert_equal (" bla `` b`la" , getline (' .' ))
123-
124- let t = ' voo "nah" sdf " asdf" sdf " sdf" sd'
125- put = t
126- normal ! $F " va" oha" i" rz
127- call assert_equal (' voo "zzzzzzzzzzzzzzzzzzzzzzzzzzzzsd' , getline (' .' ))
128-
129- let t = " -<b>asdf<i>Xasdf</i>asdf</b>-"
130- put = t
131- normal ! fXdit
132- call assert_equal (' -<b>asdf<i></i>asdf</b>-' , getline (' .' ))
133-
134- let t = " -<b>asdX<i>a<i />sdf</i>asdf</b>-"
135- put = t
136- normal ! 0 fXdit
137- call assert_equal (' -<b></b>-' , getline (' .' ))
138-
139- let t = " -<b>asdf<i>Xasdf</i>asdf</b>-"
140- put = t
141- normal ! fXdat
142- call assert_equal (' -<b>asdfasdf</b>-' , getline (' .' ))
143-
144- let t = " -<b>asdX<i>as<b />df</i>asdf</b>-"
145- put = t
146- normal ! 0 fXdat
147- call assert_equal (' --' , getline (' .' ))
148-
149- let t = " -<b>\n innertext object\n </b>"
150- put = t
151- normal ! dit
152- call assert_equal (' -<b></b>' , getline (' .' ))
153-
154- " copy the tag block from leading indentation before the start tag
155- let t = " <b>\n text\n </b>"
156- $put = t
157- normal ! 2 kvaty
158- call assert_equal (" <b>\n text\n </b>" , @" )
159-
160- " copy the tag block from the end tag
161- let t = " <title>\n welcome\n </title>"
162- $put = t
163- normal ! $vaty
164- call assert_equal (" <title>\n welcome\n </title>" , @" )
165-
166- " copy the outer tag block from a tag without an end tag
167- let t = " <html>\n <title>welcome\n </html>"
168- $put = t
169- normal ! k $vaty
170- call assert_equal (" <html>\n <title>welcome\n </html>" , @" )
171-
172- " nested tag that has < in a different line from >
173- let t = " <div><div\n ></div></div>"
174- $put = t
175- normal ! k0vaty
176- call assert_equal (" <div><div\n ></div></div>" , @" )
177-
178- " nested tag with attribute that has < in a different line from >
179- let t = " <div><div\n attr=\" attr\" \n ></div></div>"
180- $put = t
181- normal ! 2 k0vaty
182- call assert_equal (" <div><div\n attr=\" attr\" \n ></div></div>" , @" )
183-
184- set quoteescape &
185- enew !
92+ for e in [' utf-8' , ' latin1' , ' cp932' ]
93+ enew !
94+ exe ' set enc=' .. e
95+
96+ let t = ' "wo\"rd\\" foo'
97+ put = t
98+ normal ! da"
99+ call assert_equal (' foo' , getline (' .' ), e )
100+
101+ let t = " 'foo' 'bar' 'piep'"
102+ put = t
103+ normal ! 0 va' a' rx
104+ call assert_equal (" xxxxxxxxxxxx'piep'" , getline (' .' ), e )
105+
106+ let t = " bla bla `quote` blah"
107+ put = t
108+ normal ! 02 f`da`
109+ call assert_equal (" bla bla blah" , getline (' .' ), e )
110+
111+ let t = ' out " in "noXno"'
112+ put = t
113+ normal ! 0 fXdi"
114+ call assert_equal (' out " in ""' , getline (' .' ), e )
115+
116+ let t = " \" '\" 'blah' rep 'buh'"
117+ put = t
118+ normal ! 03 f' vi' ry
119+ call assert_equal (" \" '\" 'blah'yyyyy'buh'" , getline (' .' ), e )
120+
121+ set quoteescape = +*-
122+ let t = " bla `s*`d-`+++`l**` b`la"
123+ put = t
124+ normal ! di `
125+ call assert_equal (" bla `` b`la" , getline (' .' ), e )
126+
127+ let t = ' voo "nah" sdf " asdf" sdf " sdf" sd'
128+ put = t
129+ normal ! $F " va" oha" i" rz
130+ call assert_equal (' voo "zzzzzzzzzzzzzzzzzzzzzzzzzzzzsd' , getline (' .' ), e )
131+
132+ let t = " -<b>asdf<i>Xasdf</i>asdf</b>-"
133+ put = t
134+ normal ! fXdit
135+ call assert_equal (' -<b>asdf<i></i>asdf</b>-' , getline (' .' ), e )
136+
137+ let t = " -<b>asdX<i>a<i />sdf</i>asdf</b>-"
138+ put = t
139+ normal ! 0 fXdit
140+ call assert_equal (' -<b></b>-' , getline (' .' ), e )
141+
142+ let t = " -<b>asdf<i>Xasdf</i>asdf</b>-"
143+ put = t
144+ normal ! fXdat
145+ call assert_equal (' -<b>asdfasdf</b>-' , getline (' .' ), e )
146+
147+ let t = " -<b>asdX<i>as<b />df</i>asdf</b>-"
148+ put = t
149+ normal ! 0 fXdat
150+ call assert_equal (' --' , getline (' .' ), e )
151+
152+ let t = " -<b>\n innertext object\n </b>"
153+ put = t
154+ normal ! dit
155+ call assert_equal (' -<b></b>' , getline (' .' ), e )
156+
157+ " copy the tag block from leading indentation before the start tag
158+ let t = " <b>\n text\n </b>"
159+ $put = t
160+ normal ! 2 kvaty
161+ call assert_equal (" <b>\n text\n </b>" , @" , e )
162+
163+ " copy the tag block from the end tag
164+ let t = " <title>\n welcome\n </title>"
165+ $put = t
166+ normal ! $vaty
167+ call assert_equal (" <title>\n welcome\n </title>" , @" , e )
168+
169+ " copy the outer tag block from a tag without an end tag
170+ let t = " <html>\n <title>welcome\n </html>"
171+ $put = t
172+ normal ! k $vaty
173+ call assert_equal (" <html>\n <title>welcome\n </html>" , @" , e )
174+
175+ " nested tag that has < in a different line from >
176+ let t = " <div><div\n ></div></div>"
177+ $put = t
178+ normal ! k0vaty
179+ call assert_equal (" <div><div\n ></div></div>" , @" , e )
180+
181+ " nested tag with attribute that has < in a different line from >
182+ let t = " <div><div\n attr=\" attr\" \n ></div></div>"
183+ $put = t
184+ normal ! 2 k0vaty
185+ call assert_equal (" <div><div\n attr=\" attr\" \n ></div></div>" , @" , e )
186+
187+ set quoteescape &
188+ endfor
189+
190+ set enc = utf- 8
191+ bwipe!
186192endfunc
187193
188194func Test_empty_html_tag ()
@@ -561,6 +567,20 @@ func Test_textobj_quote()
561567 normal 0 ya'
562568 call assert_equal (" 'special'" , @" )
563569
570+ " quoted string with odd or even number of backslashes.
571+ call setline (1 , ' char *s = "foo\"bar"' )
572+ normal $hhyi "
573+ call assert_equal (' foo\"bar' , @" )
574+ call setline (1 , ' char *s = "foo\\"bar"' )
575+ normal $hhyi "
576+ call assert_equal (' bar' , @" )
577+ call setline (1 , ' char *s = "foo\\\"bar"' )
578+ normal $hhyi "
579+ call assert_equal (' foo\\\"bar' , @" )
580+ call setline (1 , ' char *s = "foo\\\\"bar"' )
581+ normal $hhyi "
582+ call assert_equal (' bar' , @" )
583+
564584 close !
565585endfunc
566586
0 commit comments