@@ -89,11 +89,26 @@ def test_to_s
89
89
decl ( @id , nil ) . to_s )
90
90
end
91
91
92
+ def test_to_s_pubid_literal_include_apostrophe
93
+ assert_equal ( "<!NOTATION #{ @name } PUBLIC \" #{ @id } '\" >" ,
94
+ decl ( "#{ @id } '" , nil ) . to_s )
95
+ end
96
+
92
97
def test_to_s_with_uri
93
98
assert_equal ( "<!NOTATION #{ @name } PUBLIC \" #{ @id } \" \" #{ @uri } \" >" ,
94
99
decl ( @id , @uri ) . to_s )
95
100
end
96
101
102
+ def test_to_s_system_literal_include_apostrophe
103
+ assert_equal ( "<!NOTATION #{ @name } PUBLIC \" #{ @id } \" \" system'literal\" >" ,
104
+ decl ( @id , "system'literal" ) . to_s )
105
+ end
106
+
107
+ def test_to_s_system_literal_include_double_quote
108
+ assert_equal ( "<!NOTATION #{ @name } PUBLIC \" #{ @id } \" 'system\" literal'>" ,
109
+ decl ( @id , "system\" literal" ) . to_s )
110
+ end
111
+
97
112
def test_to_s_apostrophe
98
113
document = REXML ::Document . new ( <<-XML )
99
114
<!DOCTYPE root SYSTEM "urn:x-test:sysid" [
@@ -107,6 +122,49 @@ def test_to_s_apostrophe
107
122
notation . to_s )
108
123
end
109
124
125
+ def test_to_s_apostrophe_pubid_literal_include_apostrophe
126
+ document = REXML ::Document . new ( <<-XML )
127
+ <!DOCTYPE root SYSTEM "urn:x-test:sysid" [
128
+ #{ decl ( "#{ @id } '" , @uri ) . to_s }
129
+ ]>
130
+ <root/>
131
+ XML
132
+ # This isn't used for PubidLiteral because PubidChar includes '.
133
+ document . context [ :prologue_quote ] = :apostrophe
134
+ notation = document . doctype . notations [ 0 ]
135
+ assert_equal ( "<!NOTATION #{ @name } PUBLIC \" #{ @id } '\" '#{ @uri } '>" ,
136
+ notation . to_s )
137
+ end
138
+
139
+ def test_to_s_apostrophe_system_literal_include_apostrophe
140
+ document = REXML ::Document . new ( <<-XML )
141
+ <!DOCTYPE root SYSTEM "urn:x-test:sysid" [
142
+ #{ decl ( @id , "system'literal" ) . to_s }
143
+ ]>
144
+ <root/>
145
+ XML
146
+ # This isn't used for SystemLiteral because SystemLiteral includes '.
147
+ document . context [ :prologue_quote ] = :apostrophe
148
+ notation = document . doctype . notations [ 0 ]
149
+ assert_equal ( "<!NOTATION #{ @name } PUBLIC '#{ @id } ' \" system'literal\" >" ,
150
+ notation . to_s )
151
+ end
152
+
153
+ def test_to_s_apostrophe_system_literal_include_double_quote
154
+ document = REXML ::Document . new ( <<-XML )
155
+ <!DOCTYPE root SYSTEM "urn:x-test:sysid" [
156
+ #{ decl ( @id , "system\" literal" ) . to_s }
157
+ ]>
158
+ <root/>
159
+ XML
160
+ # This isn't used for SystemLiteral because SystemLiteral includes ".
161
+ # But quoted by ' because SystemLiteral includes ".
162
+ document . context [ :prologue_quote ] = :apostrophe
163
+ notation = document . doctype . notations [ 0 ]
164
+ assert_equal ( "<!NOTATION #{ @name } PUBLIC '#{ @id } ' 'system\" literal'>" ,
165
+ notation . to_s )
166
+ end
167
+
110
168
private
111
169
def decl ( id , uri )
112
170
REXML ::NotationDecl . new ( @name , "PUBLIC" , id , uri )
@@ -124,6 +182,16 @@ def test_to_s
124
182
decl ( @id ) . to_s )
125
183
end
126
184
185
+ def test_to_s_include_apostrophe
186
+ assert_equal ( "<!NOTATION #{ @name } SYSTEM \" #{ @id } '\" >" ,
187
+ decl ( "#{ @id } '" ) . to_s )
188
+ end
189
+
190
+ def test_to_s_include_double_quote
191
+ assert_equal ( "<!NOTATION #{ @name } SYSTEM '#{ @id } \" '>" ,
192
+ decl ( "#{ @id } \" " ) . to_s )
193
+ end
194
+
127
195
def test_to_s_apostrophe
128
196
document = REXML ::Document . new ( <<-XML )
129
197
<!DOCTYPE root SYSTEM "urn:x-test:sysid" [
@@ -137,9 +205,38 @@ def test_to_s_apostrophe
137
205
notation . to_s )
138
206
end
139
207
208
+ def test_to_s_apostrophe_include_apostrophe
209
+ document = REXML ::Document . new ( <<-XML )
210
+ <!DOCTYPE root SYSTEM "urn:x-test:sysid" [
211
+ #{ decl ( "#{ @id } '" ) . to_s }
212
+ ]>
213
+ <root/>
214
+ XML
215
+ # This isn't used for SystemLiteral because SystemLiteral includes '.
216
+ document . context [ :prologue_quote ] = :apostrophe
217
+ notation = document . doctype . notations [ 0 ]
218
+ assert_equal ( "<!NOTATION #{ @name } SYSTEM \" #{ @id } '\" >" ,
219
+ notation . to_s )
220
+ end
221
+
222
+ def test_to_s_apostrophe_include_double_quote
223
+ document = REXML ::Document . new ( <<-XML )
224
+ <!DOCTYPE root SYSTEM "urn:x-test:sysid" [
225
+ #{ decl ( "#{ @id } \" " ) . to_s }
226
+ ]>
227
+ <root/>
228
+ XML
229
+ # This isn't used for SystemLiteral because SystemLiteral includes ".
230
+ # But quoted by ' because SystemLiteral includes ".
231
+ document . context [ :prologue_quote ] = :apostrophe
232
+ notation = document . doctype . notations [ 0 ]
233
+ assert_equal ( "<!NOTATION #{ @name } SYSTEM '#{ @id } \" '>" ,
234
+ notation . to_s )
235
+ end
236
+
140
237
private
141
238
def decl ( id )
142
- REXML ::NotationDecl . new ( @name , "SYSTEM" , id , nil )
239
+ REXML ::NotationDecl . new ( @name , "SYSTEM" , nil , id )
143
240
end
144
241
end
145
242
end
0 commit comments