@@ -94,15 +94,50 @@ public void testMinimizeQuotesWithNulls() throws Exception
94
94
public void testMinimizeQuotesWithStringsContainingSpecialChars () throws Exception {
95
95
Map <String , String > content ;
96
96
97
+ String yaml = null ;
98
+
99
+ /* scenarios with plain scalars */
100
+
97
101
content = Collections .singletonMap ("key" , "a:b" );
98
- String yaml = MINIM_MAPPER .writeValueAsString (content ).trim ();
102
+ yaml = MINIM_MAPPER .writeValueAsString (content ).trim ();
99
103
assertEquals ("---\n " +
100
- "key: \" a:b\" " , yaml );
104
+ "key: a:b" , yaml );
101
105
102
106
content = Collections .singletonMap ("key" , "a#b" );
103
107
yaml = MINIM_MAPPER .writeValueAsString (content ).trim ();
104
108
assertEquals ("---\n " +
105
- "key: \" a#b\" " , yaml );
109
+ "key: a#b" , yaml );
110
+
111
+ content = Collections .singletonMap ("key" , "a# b" );
112
+ yaml = MINIM_MAPPER .writeValueAsString (content ).trim ();
113
+ assertEquals ("---\n " +
114
+ "key: a# b" , yaml );
115
+
116
+ // plus also some edge cases (wrt "false" etc checking
117
+ yaml = MINIM_MAPPER .writeValueAsString (Collections .singletonMap ("key" , "f:off" )).trim ();
118
+ assertEquals ("---\n " +
119
+ "key: f:off" , yaml );
120
+
121
+
122
+ /* scenarios with single quoted scalars */
123
+
124
+ content = Collections .singletonMap ("key" , "::" );
125
+ yaml = MINIM_MAPPER .writeValueAsString (content ).trim ();
126
+ assertEquals ("---\n " +
127
+ "key: '::'" , yaml );
128
+
129
+ content = Collections .singletonMap ("key" , "#" );
130
+ yaml = MINIM_MAPPER .writeValueAsString (content ).trim ();
131
+ assertEquals ("---\n " +
132
+ "key: '#'" , yaml );
133
+
134
+ content = Collections .singletonMap ("key" , "#a" );
135
+ yaml = MINIM_MAPPER .writeValueAsString (content ).trim ();
136
+ assertEquals ("---\n " +
137
+ "key: '#a'" , yaml );
138
+
139
+
140
+ /* scenarios with double quoted scalars */
106
141
107
142
content = Collections .singletonMap ("key" , "a[b" );
108
143
yaml = MINIM_MAPPER .writeValueAsString (content ).trim ();
@@ -128,10 +163,6 @@ public void testMinimizeQuotesWithStringsContainingSpecialChars() throws Excepti
128
163
assertEquals ("---\n " +
129
164
"key: \" a,b\" " , yaml );
130
165
131
- // plus also some edge cases (wrt "false" etc checking
132
- yaml = MINIM_MAPPER .writeValueAsString (Collections .singletonMap ("key" , "f:off" )).trim ();
133
- assertEquals ("---\n " +
134
- "key: \" f:off\" " , yaml );
135
166
}
136
167
137
168
public void testLiteralStringsMultiLine () throws Exception
@@ -182,7 +213,7 @@ public void testNonQuoteNumberStoredAsString() throws Exception
182
213
String yaml = MINIM_MAPPER .writeValueAsString (Collections .singletonMap ("key" , "20" )).trim ();
183
214
assertEquals ("---\n " +
184
215
"key: 20" , yaml );
185
-
216
+
186
217
yaml = MINIM_MAPPER .writeValueAsString (Collections .singletonMap ("key" , "2.0" )).trim ();
187
218
assertEquals ("---\n " +
188
219
"key: 2.0" , yaml );
@@ -213,7 +244,7 @@ public void testNumberKey() throws Exception
213
244
MINIM_MAPPER .writeValueAsString (stringKeyMap ).trim ());
214
245
215
246
// And then true Integer keys
216
-
247
+
217
248
final Map <Integer , String > intKeyMap = Collections .singletonMap (
218
249
Integer .valueOf (42 ), "answer" );
219
250
0 commit comments