SourceDSL { public static StringsDSL strings() { return new StringsDSL(); }  static LongsDSL longs(); static IntegersDSL integers(); static DoublesDSL doubles(); static FloatsDSL floats(); static CharactersDSL characters(); static StringsDSL strings(); static ListsDSL lists(); static MapsDSL maps(); static ArraysDSL arrays(); static BigIntegersDSL bigIntegers(); static BigDecimalsDSL bigDecimals(); static ArbitraryDSL arbitrary(); static DatesDSL dates(); static LocalDatesDSL localDates(); static BooleansDSL booleans();  }
@SuppressWarnings("unused") @Test public void shouldThrowErrorWhenCreatingABoundedStringWithMaxLengthNegative() { try { Gen<String> testee = strings().basicLatinAlphabet() .ofLengthBetween(5, -6); fail("Created a string generator with negative length!"); } catch (IllegalArgumentException expected) { } }
@SuppressWarnings("unused") @Test public void shouldThrowErrorWhenCreatingABoundedStringWithMaxLengthLessThanMinLength() { try { Gen<String> testee = strings().basicLatinAlphabet() .ofLengthBetween(2, 0); fail("Created a string generator with maxLength smaller than minLength!"); } catch (IllegalArgumentException expected) { } }
@SuppressWarnings("unused") @Test public void shouldNotCatchWhenCreatingBoundedStringsWithMinLengthEqualToMaxLength() { try { Gen<String> testee = strings().basicLatinAlphabet() .ofLengthBetween(0, 0); } catch (IllegalArgumentException expected) { fail("Threw an exception for an acceptable input!"); } }
@Test public void shouldGenerateMaxAndMinIntegersAsStrings() { Gen<String> testee = strings().numeric(); assertThatGenerator(testee).generatesTheMinAndMax( Integer.toString(Integer.MIN_VALUE), Integer.toString(Integer.MAX_VALUE)); }
@Test public void shouldGenerateExtremeNumericStrings() { Gen<String> testee = strings().numericBetween(-30, 5500); assertThatGenerator(testee).generatesTheMinAndMax("-30", "5500"); }
@Test public void shouldShrinkBasicLatinStringsTowardsExclaimation() { Gen<String> testee = strings().basicLatinAlphabet() .ofLength(4); assertThatGenerator(testee).shrinksTowards("!!!!"); }
@Test public void shouldShrinkAsciiStringsAsExpected() { Gen<String> testee = strings().ascii().ofFixedNumberOfCodePoints(3); assertThatGenerator(testee).shrinksTowards("!!!"); }
@Test public void shouldShrinkBoundedStringsAsExpected() { Gen<String> testee = strings().allPossible().ofLengthBetween(2, 5); assertThatGenerator(testee).shrinksTowards("!!"); }
@Test public void shouldGenerateBetweenTwoCodePoints() { Gen<String> testee = strings().betweenCodePoints(97, 102).ofLength(1); assertThatGenerator(testee).generatesAllOf("a", "b", "c", "d", "e", "f"); }
@SuppressWarnings("unused") @Test public void shouldThrowErrorWhenCreatingNumericStringsWithMaxLessThanMin() { try { Gen<String> testee = strings().numericBetween(-5, -6); fail("Created an String generator where max is less than min!"); } catch (IllegalArgumentException expected) { assertTrue("Expected exception message to relate to improper interval", expected.getMessage() .indexOf("There are no Integer values to be generated") >= 0); } }
@SuppressWarnings("unused") @Test public void shouldNotCatchWhenCreatingNumericStringsWithMaxEqualToMin() { try { Gen<String> testee = strings().numericBetween(-5, -5); } catch (IllegalArgumentException expected) { fail("Threw an exception for an acceptable interval!"); } }
@SuppressWarnings("unused") @Test public void shouldThrowErrorWhenCreatingStringsOfNegativeCodePoints() { try { Gen<String> testee = strings().ascii() .ofFixedNumberOfCodePoints(-4); fail("Created a string generator with negative codepoints!"); } catch (IllegalArgumentException expected) { } }
@SuppressWarnings("unused") @Test public void shouldNotThrowErrorWhenCreatingStringsOfZeroCodePoints() { try { Gen<String> testee = strings().ascii() .ofFixedNumberOfCodePoints(0); } catch (IllegalArgumentException expected) { fail("Threw an exception for an acceptable input!"); } }
@SuppressWarnings("unused") @Test public void shouldThrowErrorWhenCreatingAStringOfNegativeLength() { try { Gen<String> testee = strings().basicMultilingualPlaneAlphabet() .ofLength(-7); fail("Created a string generator with negative length!"); } catch (IllegalArgumentException expected) { } }
@SuppressWarnings("unused") @Test public void shouldNotCatchWhenCreatingStringsOfZeroLength() { try { Gen<String> testee = strings().basicMultilingualPlaneAlphabet() .ofLength(0); } catch (IllegalArgumentException expected) { fail("Threw an exception for an acceptable input!"); } }
@SuppressWarnings("unused") @Test public void shouldThrowErrorWhenCreatingABoundedStringWithMinLengthNegative() { try { Gen<String> testee = strings().basicLatinAlphabet() .ofLengthBetween(-2, 6); fail("Created a string generator with negative length!"); } catch (IllegalArgumentException expected) { } }
@SuppressWarnings("unused") @Test public void shouldNotCatchWhenCreatingBoundedStringsWithMinLenghtOfZeroLength() { try { Gen<String> testee = strings().basicLatinAlphabet() .ofLengthBetween(0, 6); } catch (IllegalArgumentException expected) { fail("Threw an exception for an acceptable input!"); } }