|
| 1 | +package org.skyscreamer.jsonassert; |
| 2 | + |
| 3 | +import static junit.framework.Assert.assertEquals; |
| 4 | +import static junit.framework.Assert.assertFalse; |
| 5 | +import static junit.framework.Assert.assertTrue; |
| 6 | +import static org.skyscreamer.jsonassert.JSONCompareMode.LENIENT; |
| 7 | +import static org.skyscreamer.jsonassert.JSONCompareMode.NON_EXTENSIBLE; |
| 8 | +import static org.skyscreamer.jsonassert.JSONCompareMode.STRICT; |
| 9 | +import static org.skyscreamer.jsonassert.JSONCompareMode.STRICT_ORDER; |
| 10 | + |
| 11 | +import org.junit.Test; |
| 12 | + |
| 13 | +/** |
| 14 | + * Unit tests for {@link JSONCompareMode} |
| 15 | + */ |
| 16 | +public class JSONCompareModeTest { |
| 17 | + @Test |
| 18 | + public void testWithStrictOrdering() { |
| 19 | + assertTrue(LENIENT.withStrictOrdering(true).hasStrictOrder()); |
| 20 | + assertTrue(LENIENT.withStrictOrdering(true).isExtensible()); |
| 21 | + assertTrue(NON_EXTENSIBLE.withStrictOrdering(true).hasStrictOrder()); |
| 22 | + assertFalse(NON_EXTENSIBLE.withStrictOrdering(true).isExtensible()); |
| 23 | + |
| 24 | + assertEquals(STRICT.withStrictOrdering(true), STRICT); |
| 25 | + assertEquals(STRICT_ORDER.withStrictOrdering(true), STRICT_ORDER); |
| 26 | + } |
| 27 | + |
| 28 | + @Test |
| 29 | + public void testWithoutStrictOrdering() { |
| 30 | + assertFalse(STRICT_ORDER.withStrictOrdering(false).hasStrictOrder()); |
| 31 | + assertTrue(STRICT_ORDER.withStrictOrdering(false).isExtensible()); |
| 32 | + assertFalse(STRICT.withStrictOrdering(false).hasStrictOrder()); |
| 33 | + assertFalse(STRICT.withStrictOrdering(false).isExtensible()); |
| 34 | + |
| 35 | + assertEquals(LENIENT.withStrictOrdering(false), LENIENT); |
| 36 | + assertEquals(NON_EXTENSIBLE.withStrictOrdering(false), NON_EXTENSIBLE); |
| 37 | + } |
| 38 | + |
| 39 | + @Test |
| 40 | + public void testWithExtensibility() { |
| 41 | + assertTrue(NON_EXTENSIBLE.withExtensible(true).isExtensible()); |
| 42 | + assertFalse(NON_EXTENSIBLE.withExtensible(true).hasStrictOrder()); |
| 43 | + assertTrue(STRICT.withExtensible(true).isExtensible()); |
| 44 | + assertTrue(STRICT.withExtensible(true).hasStrictOrder()); |
| 45 | + |
| 46 | + assertEquals(LENIENT.withExtensible(true), LENIENT); |
| 47 | + assertEquals(STRICT_ORDER.withExtensible(true), STRICT_ORDER); |
| 48 | + } |
| 49 | + |
| 50 | + @Test |
| 51 | + public void testWithoutExtensibility() { |
| 52 | + assertFalse(STRICT_ORDER.withExtensible(false).isExtensible()); |
| 53 | + assertTrue(STRICT_ORDER.withExtensible(false).hasStrictOrder()); |
| 54 | + assertFalse(LENIENT.withExtensible(false).isExtensible()); |
| 55 | + assertFalse(LENIENT.withExtensible(false).hasStrictOrder()); |
| 56 | + |
| 57 | + assertEquals(STRICT.withExtensible(false), STRICT); |
| 58 | + assertEquals(NON_EXTENSIBLE.withExtensible(false), NON_EXTENSIBLE); |
| 59 | + } |
| 60 | +} |
0 commit comments