Skip to content

Commit 9cacc7e

Browse files
committed
AssertNotEquals preserve formatting
1 parent 7e3072c commit 9cacc7e

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

src/main/java/org/skyscreamer/jsonassert/JSONAssert.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
/**
99
* <p>A set of assertion methods useful for writing tests methods that return JSON.</p>
1010
*
11-
* <p>There are two modes, strict and non-strict. In most cases, you will probably want
11+
* <p>There are two modes, strict and non-strict. In most cases, you will probably want
1212
* to set strict to <i>false</i>, since that will make the tests less brittle.</p>
1313
*
1414
* <p>Strict tests require all of the elements requested to be returned, and only those elements
15-
* (ie, the tests are non-extensible). Arrays of elements must be returned in the same
16-
* order as expected. For example, say I'm expecting:</p>
15+
* (ie, the tests are non-extensible). Arrays of elements must be returned in the same
16+
* order as expected. For example, say I'm expecting:</p>
1717
*
1818
* <code>{id:123,things['a','b','c']}</code>
1919
*
2020
* <p>The following would match when doing non-strict checking, but would fail on strict checking:</p>
2121
*
2222
* <code>{id:123,things['c','b','a'],anotherfield:'blah'}</code>
2323
*
24-
* <p><i>This library uses org.json. It has fewer dependencies than other JSON libraries (like net.sf.json),
24+
* <p><i>This library uses org.json. It has fewer dependencies than other JSON libraries (like net.sf.json),
2525
* making JSONassert more portable.</i></p>
2626
*
2727
* <p>There are two known issues when dealing with non-strict comparisons:</p>
@@ -31,15 +31,15 @@
3131
* <li>Unless the order is strict, checking cannot handle arrays of arrays (e.g. <code>[[1,2],[3,4]]</code>)</li>
3232
* </ul>
3333
* <p>You do not have to worry about encountering a false positive or false negative in these two edge cases.
34-
* <i>JSONassert</i> will identify the conditions and throw a descriptive {@link IllegalArgumentException}. These
34+
* <i>JSONassert</i> will identify the conditions and throw a descriptive {@link IllegalArgumentException}. These
3535
* cases will be fixed in future versions.</p>
3636
*
3737
*/
3838
public class JSONAssert {
3939
private JSONAssert() {}
4040

4141
/**
42-
* Asserts that the JSONObject provided matches the expected string. If it isn't it throws an
42+
* Asserts that the JSONObject provided matches the expected string. If it isn't it throws an
4343
* {@link AssertionError}.
4444
*
4545
* @param expectedStr Expected JSON string
@@ -53,7 +53,7 @@ public static void assertEquals(String expectedStr, JSONObject actual, boolean s
5353
}
5454

5555
/**
56-
* Asserts that the JSONObject provided does not match the expected string. If it is it throws an
56+
* Asserts that the JSONObject provided does not match the expected string. If it is it throws an
5757
* {@link AssertionError}.
5858
*
5959
* @see #assertEquals(String JSONObject, boolean)
@@ -69,7 +69,7 @@ public static void assertNotEquals(String expectedStr, JSONObject actual, boolea
6969
}
7070

7171
/**
72-
* Asserts that the JSONObject provided matches the expected string. If it isn't it throws an
72+
* Asserts that the JSONObject provided matches the expected string. If it isn't it throws an
7373
* {@link AssertionError}.
7474
*
7575
* @param expectedStr Expected JSON string
@@ -89,7 +89,7 @@ public static void assertEquals(String expectedStr, JSONObject actual, JSONCompa
8989
}
9090

9191
/**
92-
* Asserts that the JSONObject provided does not match the expected string. If it is it throws an
92+
* Asserts that the JSONObject provided does not match the expected string. If it is it throws an
9393
* {@link AssertionError}.
9494
*
9595
* @see #assertEquals(String, JSONObject, JSONCompareMode)
@@ -111,7 +111,7 @@ public static void assertNotEquals(String expectedStr, JSONObject actual, JSONCo
111111
}
112112

113113
/**
114-
* Asserts that the JSONArray provided matches the expected string. If it isn't it throws an
114+
* Asserts that the JSONArray provided matches the expected string. If it isn't it throws an
115115
* {@link AssertionError}.
116116
*
117117
* @param expectedStr Expected JSON string
@@ -125,7 +125,7 @@ public static void assertEquals(String expectedStr, JSONArray actual, boolean st
125125
}
126126

127127
/**
128-
* Asserts that the JSONArray provided does not match the expected string. If it is it throws an
128+
* Asserts that the JSONArray provided does not match the expected string. If it is it throws an
129129
* {@link AssertionError}.
130130
*
131131
* @param expectedStr Expected JSON string
@@ -139,7 +139,7 @@ public static void assertNotEquals(String expectedStr, JSONArray actual, boolean
139139
}
140140

141141
/**
142-
* Asserts that the JSONArray provided matches the expected string. If it isn't it throws an
142+
* Asserts that the JSONArray provided matches the expected string. If it isn't it throws an
143143
* {@link AssertionError}.
144144
*
145145
* @param expectedStr Expected JSON string
@@ -159,7 +159,7 @@ public static void assertEquals(String expectedStr, JSONArray actual, JSONCompar
159159
}
160160

161161
/**
162-
* Asserts that the JSONArray provided does not match the expected string. If it is it throws an
162+
* Asserts that the JSONArray provided does not match the expected string. If it is it throws an
163163
* {@link AssertionError}.
164164
*
165165
* @param expectedStr Expected JSON string
@@ -179,7 +179,7 @@ public static void assertNotEquals(String expectedStr, JSONArray actual, JSONCom
179179
}
180180

181181
/**
182-
* Asserts that the JSONArray provided matches the expected string. If it isn't it throws an
182+
* Asserts that the JSONArray provided matches the expected string. If it isn't it throws an
183183
* {@link AssertionError}.
184184
*
185185
* @param expectedStr Expected JSON string
@@ -193,7 +193,7 @@ public static void assertEquals(String expectedStr, String actualStr, boolean st
193193
}
194194

195195
/**
196-
* Asserts that the JSONArray provided does not match the expected string. If it is it throws an
196+
* Asserts that the JSONArray provided does not match the expected string. If it is it throws an
197197
* {@link AssertionError}.
198198
*
199199
* @param expectedStr Expected JSON string
@@ -207,7 +207,7 @@ public static void assertNotEquals(String expectedStr, String actualStr, boolean
207207
}
208208

209209
/**
210-
* Asserts that the JSONArray provided matches the expected string. If it isn't it throws an
210+
* Asserts that the JSONArray provided matches the expected string. If it isn't it throws an
211211
* {@link AssertionError}.
212212
*
213213
* @param expectedStr Expected JSON string
@@ -224,7 +224,7 @@ public static void assertEquals(String expectedStr, String actualStr, JSONCompar
224224
}
225225

226226
/**
227-
* Asserts that the JSONArray provided does not match the expected string. If it is it throws an
227+
* Asserts that the JSONArray provided does not match the expected string. If it is it throws an
228228
* {@link AssertionError}.
229229
*
230230
* @param expectedStr Expected JSON string
@@ -241,7 +241,7 @@ public static void assertNotEquals(String expectedStr, String actualStr, JSONCom
241241
}
242242

243243
/**
244-
* Asserts that the json string provided matches the expected string. If it isn't it throws an
244+
* Asserts that the json string provided matches the expected string. If it isn't it throws an
245245
* {@link AssertionError}.
246246
*
247247
* @param expectedStr Expected JSON string
@@ -258,7 +258,7 @@ public static void assertEquals(String expectedStr, String actualStr, JSONCompar
258258
}
259259

260260
/**
261-
* Asserts that the json string provided does not match the expected string. If it is it throws an
261+
* Asserts that the json string provided does not match the expected string. If it is it throws an
262262
* {@link AssertionError}.
263263
*
264264
* @param expectedStr Expected JSON string
@@ -275,7 +275,7 @@ public static void assertNotEquals(String expectedStr, String actualStr, JSONCom
275275
}
276276

277277
/**
278-
* Asserts that the JSONObject provided matches the expected JSONObject. If it isn't it throws an
278+
* Asserts that the JSONObject provided matches the expected JSONObject. If it isn't it throws an
279279
* {@link AssertionError}.
280280
*
281281
* @param expected Expected JSONObject
@@ -289,7 +289,7 @@ public static void assertEquals(JSONObject expected, JSONObject actual, boolean
289289
}
290290

291291
/**
292-
* Asserts that the JSONObject provided does not match the expected JSONObject. If it is it throws an
292+
* Asserts that the JSONObject provided does not match the expected JSONObject. If it is it throws an
293293
* {@link AssertionError}.
294294
*
295295
* @param expected Expected JSONObject
@@ -303,7 +303,7 @@ public static void assertNotEquals(JSONObject expected, JSONObject actual, boole
303303
}
304304

305305
/**
306-
* Asserts that the JSONObject provided matches the expected JSONObject. If it isn't it throws an
306+
* Asserts that the JSONObject provided matches the expected JSONObject. If it isn't it throws an
307307
* {@link AssertionError}.
308308
*
309309
* @param expected Expected JSONObject
@@ -321,7 +321,7 @@ public static void assertEquals(JSONObject expected, JSONObject actual, JSONComp
321321
}
322322

323323
/**
324-
* Asserts that the JSONObject provided does not match the expected JSONObject. If it is it throws an
324+
* Asserts that the JSONObject provided does not match the expected JSONObject. If it is it throws an
325325
* {@link AssertionError}.
326326
*
327327
* @param expected Expected JSONObject
@@ -339,7 +339,7 @@ public static void assertNotEquals(JSONObject expected, JSONObject actual, JSONC
339339
}
340340

341341
/**
342-
* Asserts that the JSONArray provided matches the expected JSONArray. If it isn't it throws an
342+
* Asserts that the JSONArray provided matches the expected JSONArray. If it isn't it throws an
343343
* {@link AssertionError}.
344344
*
345345
* @param expected Expected JSONArray
@@ -353,7 +353,7 @@ public static void assertEquals(JSONArray expected, JSONArray actual, boolean st
353353
}
354354

355355
/**
356-
* Asserts that the JSONArray provided does not match the expected JSONArray. If it is it throws an
356+
* Asserts that the JSONArray provided does not match the expected JSONArray. If it is it throws an
357357
* {@link AssertionError}.
358358
*
359359
* @param expected Expected JSONArray
@@ -367,7 +367,7 @@ public static void assertNotEquals(JSONArray expected, JSONArray actual, boolean
367367
}
368368

369369
/**
370-
* Asserts that the JSONArray provided matches the expected JSONArray. If it isn't it throws an
370+
* Asserts that the JSONArray provided matches the expected JSONArray. If it isn't it throws an
371371
* {@link AssertionError}.
372372
*
373373
* @param expected Expected JSONArray
@@ -384,7 +384,7 @@ public static void assertEquals(JSONArray expected, JSONArray actual, JSONCompar
384384
}
385385

386386
/**
387-
* Asserts that the JSONArray provided does not match the expected JSONArray. If it is it throws an
387+
* Asserts that the JSONArray provided does not match the expected JSONArray. If it is it throws an
388388
* {@link AssertionError}.
389389
*
390390
* @param expected Expected JSONArray

src/test/java/org/skyscreamer/jsonassert/JSONAssertTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ public void testReversed() throws JSONException {
4444

4545
@Test // Currently JSONAssert assumes JSONObject.
4646
public void testArray() throws JSONException {
47-
testPass("[1,2,3]", "[1,2,3]",STRICT);
48-
testPass("[1,2,3]", "[1,3,2]",LENIENT);
49-
testFail("[1,2,3]", "[1,3,2]",STRICT);
50-
testFail("[1,2,3]", "[4,5,6]",LENIENT);
51-
testPass("[1,2,3]", "[1,2,3]",STRICT_ORDER);
52-
testPass("[1,2,3]", "[1,3,2]",NON_EXTENSIBLE);
53-
testFail("[1,2,3]", "[1,3,2]",STRICT_ORDER);
54-
testFail("[1,2,3]", "[4,5,6]",NON_EXTENSIBLE);
47+
testPass("[1,2,3]","[1,2,3]", STRICT);
48+
testPass("[1,2,3]","[1,3,2]", LENIENT);
49+
testFail("[1,2,3]","[1,3,2]", STRICT);
50+
testFail("[1,2,3]","[4,5,6]", LENIENT);
51+
testPass("[1,2,3]","[1,2,3]", STRICT_ORDER);
52+
testPass("[1,2,3]","[1,3,2]", NON_EXTENSIBLE);
53+
testFail("[1,2,3]","[1,3,2]", STRICT_ORDER);
54+
testFail("[1,2,3]","[4,5,6]", NON_EXTENSIBLE);
5555
}
5656

5757
@Test
@@ -73,8 +73,8 @@ public void testVeryNested() throws JSONException {
7373
@Test
7474
public void testSimpleArray() throws JSONException {
7575
testPass("{id:1,pets:[\"dog\",\"cat\",\"fish\"]}", // Exact to exact (strict)
76-
"{id:1,pets:[\"dog\",\"cat\",\"fish\"]}",
77-
STRICT);
76+
"{id:1,pets:[\"dog\",\"cat\",\"fish\"]}",
77+
STRICT);
7878
testFail("{id:1,pets:[\"dog\",\"cat\",\"fish\"]}", // Out-of-order fails (strict)
7979
"{id:1,pets:[\"dog\",\"fish\",\"cat\"]}",
8080
STRICT);

0 commit comments

Comments
 (0)