├── .editorconfig ├── .github ├── dependabot.yml └── workflows │ └── ci.yml ├── .gitignore ├── .java-version ├── .travis.yml ├── LICENSE.txt ├── README.md ├── conf ├── MIT-LICENSE.txt ├── checkstyle-suppressions.xml └── src-checkstyle.xml ├── core ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── pholser │ │ │ └── junit │ │ │ └── quickcheck │ │ │ ├── From.java │ │ │ ├── MinimalCounterexampleHook.java │ │ │ ├── Mode.java │ │ │ ├── Pair.java │ │ │ ├── Produced.java │ │ │ ├── Property.java │ │ │ ├── When.java │ │ │ ├── conversion │ │ │ └── StringConversion.java │ │ │ ├── generator │ │ │ ├── Also.java │ │ │ ├── ComponentizedGenerator.java │ │ │ ├── Ctor.java │ │ │ ├── Distinct.java │ │ │ ├── Fields.java │ │ │ ├── Gen.java │ │ │ ├── GenerationStatus.java │ │ │ ├── Generator.java │ │ │ ├── GeneratorConfiguration.java │ │ │ ├── GeneratorConfigurationException.java │ │ │ ├── Generators.java │ │ │ ├── Lambdas.java │ │ │ ├── NullAllowed.java │ │ │ ├── Only.java │ │ │ ├── Shrink.java │ │ │ └── Size.java │ │ │ ├── hook │ │ │ └── NilMinimalCounterexampleHook.java │ │ │ ├── internal │ │ │ ├── CartesianIterator.java │ │ │ ├── Comparables.java │ │ │ ├── DefaultMethodHandleMaker.java │ │ │ ├── FakeAnnotatedTypeFactory.java │ │ │ ├── GeometricDistribution.java │ │ │ ├── Items.java │ │ │ ├── Lists.java │ │ │ ├── ParameterSampler.java │ │ │ ├── ParameterTypeContext.java │ │ │ ├── PropertyParameterContext.java │ │ │ ├── Ranges.java │ │ │ ├── Reflection.java │ │ │ ├── ReflectionException.java │ │ │ ├── SeededValue.java │ │ │ ├── Sequences.java │ │ │ ├── ShrinkControl.java │ │ │ ├── Weighted.java │ │ │ ├── Zilch.java │ │ │ ├── constraint │ │ │ │ └── ConstraintEvaluator.java │ │ │ ├── conversion │ │ │ │ ├── ConstructorInvokingStringConversion.java │ │ │ │ ├── MethodInvokingStringConversion.java │ │ │ │ └── StringConversions.java │ │ │ ├── generator │ │ │ │ ├── AbstractGenerationStatus.java │ │ │ │ ├── ArrayGenerator.java │ │ │ │ ├── CompositeGenerator.java │ │ │ │ ├── EnumGenerator.java │ │ │ │ ├── ExhaustiveDomainGenerator.java │ │ │ │ ├── GeneratorRepository.java │ │ │ │ ├── GuaranteeValuesGenerator.java │ │ │ │ ├── LambdaGenerator.java │ │ │ │ ├── MarkerInterfaceGenerator.java │ │ │ │ ├── NullableGenerator.java │ │ │ │ ├── PropertyParameterGenerationContext.java │ │ │ │ ├── SamplingDomainGenerator.java │ │ │ │ ├── ServiceLoaderGeneratorSource.java │ │ │ │ ├── SimpleGenerationStatus.java │ │ │ │ └── ZilchGenerator.java │ │ │ └── sampling │ │ │ │ ├── ExhaustiveParameterSampler.java │ │ │ │ └── TupleParameterSampler.java │ │ │ ├── random │ │ │ └── SourceOfRandomness.java │ │ │ └── runner │ │ │ ├── JUnitQuickcheck.java │ │ │ ├── JUnitQuickcheckTestClass.java │ │ │ ├── NoValuesSatisfiedPropertyAssumptions.java │ │ │ ├── PropertyFalsified.java │ │ │ ├── PropertyStatement.java │ │ │ ├── PropertyVerifier.java │ │ │ ├── ShrinkNode.java │ │ │ └── Shrinker.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── com.pholser.junit.quickcheck.generator.Generator │ └── test │ ├── java │ └── com │ │ └── pholser │ │ └── junit │ │ └── quickcheck │ │ ├── Annotations.java │ │ ├── BasicCapabilitiesOfGeneratorTest.java │ │ ├── Classes.java │ │ ├── ComponentizedGeneratorsIsolateConfigurationFromComponentsTest.java │ │ ├── ComposedObjectsTest.java │ │ ├── EnumPropertyParameterTypesTest.java │ │ ├── EqualsHashCodePropertiesTest.java │ │ ├── ExhaustingAGivenSetButIncludingAnotherTest.java │ │ ├── ExhaustingAGivenSetTest.java │ │ ├── FilterTest.java │ │ ├── FooEqualsHashCodeTest.java │ │ ├── GeneratorDescriptorsIssue235.java │ │ ├── GeneratorTest.java │ │ ├── GenericArrayPropertyParameterTypesTest.java │ │ ├── LambdaPropertyParameterTypesTest.java │ │ ├── LongRunning.java │ │ ├── MapFlatMapTest.java │ │ ├── MarkingTypeUsesOnPropertyParametersWithConfigurationTest.java │ │ ├── MinimalCounterexampleHookTest.java │ │ ├── Objects.java │ │ ├── PairTest.java │ │ ├── PropertiesWithExplicitGeneratorsTest.java │ │ ├── PropertyExhaustiveSampleSizeTest.java │ │ ├── PropertyParameterConfigurationIsolationTest.java │ │ ├── PropertyParameterDiscardRatioTest.java │ │ ├── PropertyParameterGenerationByConstructorTest.java │ │ ├── PropertyParameterGenerationByFieldsTest.java │ │ ├── PropertyParameterMarkedWithSuperfluousConfigurationTest.java │ │ ├── PropertyTupleSampleSizeTest.java │ │ ├── ReproIssue175Test.java │ │ ├── ReproIssue240Test.java │ │ ├── ResolvingGenericPropertyParameterTypesTest.java │ │ ├── SamplingButAlsoIncludingAGivenSetTest.java │ │ ├── SamplingOnlyFromAGivenSetTest.java │ │ ├── ShrinkingTest.java │ │ ├── Strings.java │ │ ├── TimesTest.java │ │ ├── Types.java │ │ ├── UsualJUnitMachineryOnPropertyBasedTest.java │ │ ├── UsualJUnitMachineryOnShrinkingPropertyBasedTest.java │ │ ├── UsualJUnitMachineryOnSubclassPropertyTest.java │ │ ├── UsualJUnitMachineryOnTraitBasedPropertyTest.java │ │ ├── UtilityClassesUninstantiabilityHarness.java │ │ ├── generator │ │ ├── GenFrequencyTest.java │ │ ├── GenOneOfTest.java │ │ ├── GenerationStatusOnPropertyParametersTest.java │ │ ├── LambdasTest.java │ │ ├── LambdasUtilityClassTest.java │ │ ├── PrimitiveIntegerArrayPropertyParameterTest.java │ │ ├── PropertyParameterGenerationStatusTest.java │ │ ├── SizeConstrainedPrimitiveIntegerArrayPropertyParameterTest.java │ │ └── ThreeDCharArrayPropertyParameterTest.java │ │ ├── internal │ │ ├── CartesianIteratorTest.java │ │ ├── ComparablesTest.java │ │ ├── ComparablesUtilityClassTest.java │ │ ├── FakeAnnotatedTypeFactoryUtilityClassTest.java │ │ ├── GeometricDistributionTest.java │ │ ├── InvocationTargetProblematic.java │ │ ├── ItemsTest.java │ │ ├── ItemsUtilityClassTest.java │ │ ├── ListsTest.java │ │ ├── ListsUtilityClassTest.java │ │ ├── MultiArgIllegalAccessProblematic.java │ │ ├── RangesTest.java │ │ ├── RangesUtilityClassTest.java │ │ ├── ReflectionTest.java │ │ ├── ReflectionUtilityClassTest.java │ │ ├── SequencesTest.java │ │ ├── SequencesUtilityClassTest.java │ │ ├── WeightedTest.java │ │ ├── ZeroArgIllegalAccessProblematic.java │ │ ├── constraint │ │ │ └── ConstraintEvaluatorTest.java │ │ └── generator │ │ │ ├── ArrayGeneratorTest.java │ │ │ ├── CompositeGeneratorTest.java │ │ │ ├── ConstrainingWhatGeneratorsCanAcceptCertainComponentsTest.java │ │ │ ├── CorePropertyParameterTest.java │ │ │ ├── EnumGeneratorTest.java │ │ │ ├── ExplicitGeneratorsChosenWithEqualProbabilityTest.java │ │ │ ├── ExplicitGroupOfGeneratorsChosenWithDiscreteProbabilityTest.java │ │ │ ├── ExplicitGroupOfGeneratorsChosenWithEqualProbabilityTest.java │ │ │ ├── Generators.java │ │ │ ├── MissingGeneratorForGivenTypeTest.java │ │ │ ├── OneOfSetOfGeneratorsTest.java │ │ │ ├── PropertyParameterGenerationContextTest.java │ │ │ ├── PropertyParameterGenerationContextWithNonShrinkingGeneratorTest.java │ │ │ ├── RegisterGeneratorsByConventionTest.java │ │ │ ├── RegisteringGeneratorsForHierarchyOfArrayListTest.java │ │ │ ├── RegisteringGeneratorsForHierarchyOfBigDecimalTest.java │ │ │ ├── RegisteringGeneratorsForHierarchyOfHashMapTest.java │ │ │ ├── RegisteringGeneratorsForHierarchyOfInterfaceTest.java │ │ │ ├── RegisteringGeneratorsWithServiceLoaderTest.java │ │ │ └── conventiontestclasses │ │ │ ├── Convention.java │ │ │ ├── ConventionGen.java │ │ │ ├── GeneratesOtherTypes.java │ │ │ ├── GeneratesOtherTypesGen.java │ │ │ ├── NotAGenerator.java │ │ │ └── NotAGeneratorGen.java │ │ ├── random │ │ ├── GeneratingRandomValuesFromJavaUtilRandomCloneTest.java │ │ ├── GeneratingRandomValuesTest.java │ │ └── other │ │ │ └── AccessingJDKRandomDelegateTest.java │ │ ├── runner │ │ └── PropertyFalsifiedUtilityClassTest.java │ │ └── test │ │ └── generator │ │ ├── ABigInt.java │ │ ├── ABool.java │ │ ├── ABox.java │ │ ├── AByte.java │ │ ├── ACallable.java │ │ ├── AChar.java │ │ ├── ADecimal.java │ │ ├── ADouble.java │ │ ├── AFloat.java │ │ ├── AFoo.java │ │ ├── AFooBadShrinks.java │ │ ├── AList.java │ │ ├── ALong.java │ │ ├── AMap.java │ │ ├── APair.java │ │ ├── AShort.java │ │ ├── AString.java │ │ ├── AnInt.java │ │ ├── AnotherBox.java │ │ ├── Between.java │ │ ├── Box.java │ │ ├── Foo.java │ │ ├── FooBoxOpener.java │ │ ├── Pair.java │ │ ├── TestGeneratorSource.java │ │ └── X.java │ └── resources │ ├── META-INF │ └── services │ │ └── com.pholser.junit.quickcheck.generator.Generator │ ├── logback-test.xml │ ├── subclass-property-test-expected.txt │ └── trait-property-test-expected.txt ├── examples ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── pholser │ │ └── junit │ │ └── quickcheck │ │ └── examples │ │ ├── counter │ │ └── Counter.java │ │ ├── crypto │ │ └── SymmetricCrypto.java │ │ ├── dummy │ │ ├── A.java │ │ └── B.java │ │ ├── func │ │ └── Either.java │ │ ├── geom │ │ ├── Point.java │ │ ├── Polygon.java │ │ └── Segment.java │ │ ├── money │ │ └── DollarsAndCents.java │ │ ├── number │ │ └── NonNegative.java │ │ └── tree │ │ ├── Empty.java │ │ ├── Leaf.java │ │ ├── Node.java │ │ ├── Tree.java │ │ ├── TreeVisitor.java │ │ ├── Visited.java │ │ └── visitor │ │ ├── TreeDeepestLeafVisitor.java │ │ ├── TreeDepthVisitor.java │ │ └── TreeStructureVisitor.java │ └── test │ ├── java │ └── com │ │ └── pholser │ │ └── junit │ │ └── quickcheck │ │ └── examples │ │ ├── convention │ │ ├── Convention.java │ │ ├── ConventionGen.java │ │ └── ConventionGenTest.java │ │ ├── counter │ │ └── CounterPropertiesTest.java │ │ ├── crypto │ │ ├── AES128Keys.java │ │ └── SymmetricKeyCryptoPropertiesTest.java │ │ ├── dummy │ │ ├── AGenerator.java │ │ ├── AGeneratorTest.java │ │ └── BGenerator.java │ │ ├── func │ │ ├── EitherGenerator.java │ │ └── EitherTest.java │ │ ├── geom │ │ ├── Dimensions.java │ │ ├── PointGenerator.java │ │ ├── PolygonGenerator.java │ │ ├── PolygonPropertiesTest.java │ │ ├── SegmentGenerator.java │ │ └── SegmentPropertiesTest.java │ │ ├── money │ │ └── DollarsAndCentsPropertiesTest.java │ │ ├── nullable │ │ └── NullableParameterTest.java │ │ ├── number │ │ ├── IntegralGenerator.java │ │ ├── NumbersPropertiesTest.java │ │ ├── PrimeFactors.java │ │ └── PrimeFactorsPropertiesTest.java │ │ ├── text │ │ ├── SSNTest.java │ │ ├── StringPropertiesTest.java │ │ └── Structured.java │ │ └── tree │ │ ├── Depth.java │ │ ├── EmptyGenerator.java │ │ ├── LeafGenerator.java │ │ ├── NodeGenerator.java │ │ ├── TreeKeys.java │ │ ├── TreeMaker.java │ │ └── TreePropertyTest.java │ └── resources │ └── META-INF │ └── services │ └── com.pholser.junit.quickcheck.generator.Generator ├── generators ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── pholser │ │ └── junit │ │ └── quickcheck │ │ └── generator │ │ ├── DecimalGenerator.java │ │ ├── InRange.java │ │ ├── IntegralGenerator.java │ │ ├── Precision.java │ │ ├── VoidGenerator.java │ │ └── java │ │ ├── lang │ │ ├── AbstractStringGenerator.java │ │ ├── BooleanGenerator.java │ │ ├── ByteGenerator.java │ │ ├── CharacterGenerator.java │ │ ├── CodePointShrink.java │ │ ├── DoubleGenerator.java │ │ ├── Encoded.java │ │ ├── FloatGenerator.java │ │ ├── IntegerGenerator.java │ │ ├── LongGenerator.java │ │ ├── ShortGenerator.java │ │ ├── StringGenerator.java │ │ └── strings │ │ │ └── CodePoints.java │ │ ├── math │ │ ├── BigDecimalGenerator.java │ │ └── BigIntegerGenerator.java │ │ ├── nio │ │ └── charset │ │ │ └── CharsetGenerator.java │ │ ├── time │ │ ├── ClockGenerator.java │ │ ├── DurationGenerator.java │ │ ├── InstantGenerator.java │ │ ├── LocalDateGenerator.java │ │ ├── LocalDateTimeGenerator.java │ │ ├── LocalTimeGenerator.java │ │ ├── MonthDayGenerator.java │ │ ├── OffsetDateTimeGenerator.java │ │ ├── OffsetTimeGenerator.java │ │ ├── PeriodGenerator.java │ │ ├── YearGenerator.java │ │ ├── YearMonthGenerator.java │ │ ├── ZoneIdGenerator.java │ │ ├── ZoneOffsetGenerator.java │ │ └── ZonedDateTimeGenerator.java │ │ └── util │ │ ├── ArrayListGenerator.java │ │ ├── BitSetGenerator.java │ │ ├── CollectionGenerator.java │ │ ├── DateGenerator.java │ │ ├── HashMapGenerator.java │ │ ├── HashSetGenerator.java │ │ ├── HashtableGenerator.java │ │ ├── LinkedHashMapGenerator.java │ │ ├── LinkedHashSetGenerator.java │ │ ├── LinkedListGenerator.java │ │ ├── ListGenerator.java │ │ ├── LocaleGenerator.java │ │ ├── MapGenerator.java │ │ ├── OptionalDoubleGenerator.java │ │ ├── OptionalGenerator.java │ │ ├── OptionalIntGenerator.java │ │ ├── OptionalLongGenerator.java │ │ ├── PropertiesGenerator.java │ │ ├── RFC4122.java │ │ ├── SetGenerator.java │ │ ├── StackGenerator.java │ │ ├── TimeZoneGenerator.java │ │ ├── VectorGenerator.java │ │ ├── concurrent │ │ └── CallableGenerator.java │ │ └── function │ │ ├── BiFunctionGenerator.java │ │ ├── BiPredicateGenerator.java │ │ ├── BinaryOperatorGenerator.java │ │ ├── DoubleFunctionGenerator.java │ │ ├── FunctionGenerator.java │ │ ├── IntFunctionGenerator.java │ │ ├── LongFunctionGenerator.java │ │ ├── PredicateGenerator.java │ │ ├── SupplierGenerator.java │ │ ├── ToDoubleBiFunctionGenerator.java │ │ ├── ToDoubleFunctionGenerator.java │ │ ├── ToIntBiFunctionGenerator.java │ │ ├── ToIntFunctionGenerator.java │ │ ├── ToLongBiFunctionGenerator.java │ │ ├── ToLongFunctionGenerator.java │ │ └── UnaryOperatorGenerator.java │ └── test │ └── java │ └── com │ └── pholser │ └── junit │ └── quickcheck │ ├── BigNumberPropertyParameterTypesTest.java │ ├── BitSetPropertyParameterTypesTest.java │ ├── CallablePropertyParameterTest.java │ ├── ClockPropertyParameterTypesTest.java │ ├── ComparableWithConsistentEqualsContract.java │ ├── ComparatorContract.java │ ├── ContractTestWithArrayTypeParameterTest.java │ ├── ContractTestWithTypeVariableForPropertyParameterTest.java │ ├── DatePropertyParameterTypesTest.java │ ├── DayOfWeekPropertyParameterTypesTest.java │ ├── DistinctArrayPropertyParameterTypesTest.java │ ├── DistinctListPropertyParameterTypesTest.java │ ├── DistinctMapPropertyParameterTypesTest.java │ ├── DistinctSetPropertyParameterTypesTest.java │ ├── DurationPropertyParameterTypesTest.java │ ├── Generating.java │ ├── InstantPropertyParameterTypesTest.java │ ├── IntegerComparableTest.java │ ├── IntegerComparatorTest.java │ ├── ListPropertyParameterTypesTest.java │ ├── LocalDatePropertyParameterTypesTest.java │ ├── LocalDateTimePropertyParameterTypesTest.java │ ├── LocalTimePropertyParameterTypesTest.java │ ├── MapPropertyParameterTypesTest.java │ ├── MonthDayPropertyParameterTypesTest.java │ ├── MonthPropertyParameterTypesTest.java │ ├── NumberPropertyParameterTypesTest.java │ ├── OffsetDateTimePropertyParameterTypesTest.java │ ├── OffsetTimePropertyParameterTypesTest.java │ ├── OnlyAlsoTest.java │ ├── PeriodPropertyParameterTypesTest.java │ ├── Primitive2DArrayPropertyParameterTypesTest.java │ ├── Primitive3DArrayPropertyParameterTypesTest.java │ ├── PrimitiveArrayPropertyParameterTypesTest.java │ ├── PrimitivePropertyParameterTypesTest.java │ ├── PropertiesPropertyParameterTypesTest.java │ ├── ReferenceArrayPropertyParameterTypesTest.java │ ├── Repro179Test.java │ ├── ReproIssue240Test.java │ ├── SetPropertyParameterTypesTest.java │ ├── SizeConstrainedArrayPropertyParameterTypesTest.java │ ├── SizeConstrainedListPropertyParameterTypesTest.java │ ├── SizeConstrainedMapPropertyParameterTypesTest.java │ ├── SizeConstrainedSetPropertyParameterTypesTest.java │ ├── SizeConstrainedStringPropertyParameterTypesTest.java │ ├── StringPropertyParameterTypesTest.java │ ├── YearMonthPropertyParameterTypesTest.java │ ├── YearPropertyParameterTypesTest.java │ ├── ZoneOffsetPropertyParameterTypesTest.java │ ├── ZonedDateTimePropertyParameterTypesTest.java │ ├── generator │ ├── BasicGeneratorPropertyParameterTest.java │ ├── RangeAttributes.java │ ├── VoidGeneratorTest.java │ └── java │ │ ├── lang │ │ ├── ConstrainedPrimitiveIntegerPropertyParameterTest.java │ │ ├── EncodedStringPropertyParameterTest.java │ │ ├── PrimitiveBooleanPropertyParameterTest.java │ │ ├── PrimitiveBytePropertyParameterTest.java │ │ ├── PrimitiveCharPropertyParameterTest.java │ │ ├── PrimitiveDoublePropertyParameterTest.java │ │ ├── PrimitiveFloatPropertyParameterTest.java │ │ ├── PrimitiveIntegerPropertyParameterTest.java │ │ ├── PrimitiveLongPropertyParameterTest.java │ │ ├── PrimitiveShortPropertyParameterTest.java │ │ ├── RangedPrimitiveIntegerPropertyParameterTest.java │ │ ├── StringPropertyParameterTest.java │ │ ├── WrapperBooleanPropertyParameterTest.java │ │ ├── WrapperBytePropertyParameterTest.java │ │ ├── WrapperCharacterPropertyParameterTest.java │ │ ├── WrapperDoublePropertyParameterTest.java │ │ ├── WrapperFloatPropertyParameterTest.java │ │ ├── WrapperIntegerPropertyParameterTest.java │ │ ├── WrapperLongPropertyParameterTest.java │ │ ├── WrapperShortPropertyParameterTest.java │ │ └── strings │ │ │ ├── CodePointRangeTest.java │ │ │ ├── CodePointsTest.java │ │ │ └── LargeCharsetCodePointsTest.java │ │ ├── math │ │ ├── BigDecimalPropertyParameterTest.java │ │ ├── BigDecimalWithSpecifiedPrecisionPropertyParameterTest.java │ │ ├── BigIntegerPropertyParameterTest.java │ │ ├── RangedBigDecimalNoMaxPropertyParameterTest.java │ │ ├── RangedBigDecimalNoMaxWithGreaterSpecifiedPrecisionPropertyParameterTest.java │ │ ├── RangedBigDecimalNoMaxWithLesserSpecifiedPrecisionPropertyParameterTest.java │ │ ├── RangedBigDecimalNoMinPropertyParameterTest.java │ │ ├── RangedBigDecimalNoMinWithGreaterSpecifiedPrecisionPropertyParameterTest.java │ │ ├── RangedBigDecimalNoMinWithLesserSpecifiedPrecisionPropertyParameterTest.java │ │ ├── RangedBigDecimalPropertyParameterTest.java │ │ ├── RangedBigDecimalWithGreaterSpecifiedPrecisionPropertyParameterTest.java │ │ ├── RangedBigDecimalWithLesserSpecifiedPrecisionPropertyParameterTest.java │ │ ├── RangedBigIntegerNoMaxPropertyParameterTest.java │ │ ├── RangedBigIntegerNoMinPropertyParameterTest.java │ │ └── RangedBigIntegerPropertyParameterTest.java │ │ ├── nio │ │ └── charset │ │ │ └── CharsetPropertyParameterTest.java │ │ └── util │ │ ├── BitSetPropertyParameterTest.java │ │ ├── DatePropertyParameterTest.java │ │ ├── HashtableGeneratorTest.java │ │ ├── ListOfExtendsShortPropertyParameterTest.java │ │ ├── ListOfHuhPropertyParameterTest.java │ │ ├── ListOfIntArrayPropertyParameterTest.java │ │ ├── ListOfWrapperLongPropertyParameterTest.java │ │ ├── LocalePropertyParameterTest.java │ │ ├── MapOfIntegerToFloatPropertyParameterTest.java │ │ ├── MessageDigestsTest.java │ │ ├── MessageDigestsUtilityClassTest.java │ │ ├── OptionalDoublePropertyParameterTest.java │ │ ├── OptionalIntPropertyParameterTest.java │ │ ├── OptionalLongPropertyParameterTest.java │ │ ├── OptionalPropertyParameterTest.java │ │ ├── PropertiesPropertyParameterTest.java │ │ ├── RFC4122UtilityClassTest.java │ │ ├── RFC4122Version3PropertyParameterTest.java │ │ ├── RFC4122Version4PropertyParameterTest.java │ │ ├── RFC4122Version5PropertyParameterTest.java │ │ ├── RangedDatePropertyParameterTest.java │ │ ├── SetOfEnumPropertyParameterTest.java │ │ ├── SetOfExtendsBytePropertyParameterTest.java │ │ ├── SetOfHuhPropertyParameterTest.java │ │ ├── SetOfSuperFloatPropertyParameterTest.java │ │ ├── SetOfWrapperBooleanPropertyParameterTest.java │ │ ├── TimeZonePropertyParameterTest.java │ │ └── function │ │ ├── BiConsumerPropertyParameterTest.java │ │ ├── BiFunctionPropertyParameterTest.java │ │ ├── BiPredicatePropertyParameterTest.java │ │ ├── BinaryOperatorPropertyParameterTest.java │ │ ├── BooleanSupplierPropertyParameterTest.java │ │ ├── ConsumerPropertyParameterTest.java │ │ ├── DoubleBinaryOperatorPropertyParameterTest.java │ │ ├── DoubleConsumerPropertyParameterTest.java │ │ ├── DoubleFunctionPropertyParameterTest.java │ │ ├── DoublePredicatePropertyParameterTest.java │ │ ├── DoubleSupplierPropertyParameterTest.java │ │ ├── DoubleToIntFunctionPropertyParameterTest.java │ │ ├── DoubleToLongFunctionPropertyParameterTest.java │ │ ├── DoubleUnaryOperatorPropertyParameterTest.java │ │ ├── FunctionPropertyParameterTest.java │ │ ├── IntBinaryOperatorPropertyParameterTest.java │ │ ├── IntConsumerPropertyParameterTest.java │ │ ├── IntFunctionPropertyParameterTest.java │ │ ├── IntPredicatePropertyParameterTest.java │ │ ├── IntSupplierPropertyParameterTest.java │ │ ├── IntToDoubleFunctionPropertyParameterTest.java │ │ ├── IntToLongFunctionPropertyParameterTest.java │ │ ├── IntUnaryOperatorPropertyParameterTest.java │ │ ├── LongBinaryOperatorPropertyParameterTest.java │ │ ├── LongConsumerPropertyParameterTest.java │ │ ├── LongFunctionPropertyParameterTest.java │ │ ├── LongPredicatePropertyParameterTest.java │ │ ├── LongSupplierPropertyParameterTest.java │ │ ├── LongToDoubleFunctionPropertyParameterTest.java │ │ ├── LongToIntFunctionPropertyParameterTest.java │ │ ├── LongUnaryOperatorPropertyParameterTest.java │ │ ├── ObjDoubleConsumerPropertyParameterTest.java │ │ ├── ObjIntConsumerPropertyParameterTest.java │ │ ├── ObjLongConsumerPropertyParameterTest.java │ │ ├── PredicatePropertyParameterTest.java │ │ ├── SupplierPropertyParameterTest.java │ │ ├── ToDoubleBiFunctionPropertyParameterTest.java │ │ ├── ToDoubleFunctionPropertyParameterTest.java │ │ ├── ToIntBiFunctionPropertyParameterTest.java │ │ ├── ToIntFunctionPropertyParameterTest.java │ │ ├── ToLongBiFunctionPropertyParameterTest.java │ │ ├── ToLongFunctionPropertyParameterTest.java │ │ └── UnaryOperatorPropertyParameterTest.java │ └── issue275 │ ├── Functor.java │ ├── FunctorContract.java │ ├── List.java │ ├── ListFunctor.java │ ├── ListFunctorProperties.java │ ├── ListGen.java │ ├── __.java │ └── __Gen.java ├── guava ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── pholser │ │ └── junit │ │ └── quickcheck │ │ └── guava │ │ └── generator │ │ ├── FunctionGenerator.java │ │ ├── OptionalGenerator.java │ │ ├── PredicateGenerator.java │ │ └── SupplierGenerator.java │ └── test │ └── java │ └── com │ └── pholser │ └── junit │ └── quickcheck │ └── guava │ └── generator │ ├── FunctionOfStringToIntPropertyParameterTest.java │ ├── FunctionPropertyParameterTypesTest.java │ ├── OptionalPropertyParameterTest.java │ ├── PredicatePropertyParameterTest.java │ └── SupplierPropertyParameterTest.java ├── infinitest.filters ├── pom.xml └── src └── site ├── markdown ├── background │ ├── history.md │ ├── migrating.md │ └── similar-projects.md ├── discuss.md ├── download.md ├── index.md ├── javadoc.md ├── license.md ├── reports │ ├── reports-core.md │ ├── reports-generators.md │ └── reports-guava.md └── usage │ ├── basic-types.md │ ├── complex-types.md │ ├── configuring.md │ ├── constraining.md │ ├── contract-tests.md │ ├── getting-started.md │ ├── null.md │ ├── other-types.md │ ├── seed.md │ ├── shrinking.md │ └── verification-modes.md └── site.xml /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | 9 | [*.java,*.xml] 10 | indent_style = space 11 | indent_size = 4 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "maven" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | - package-ecosystem: "github-actions" 8 | directory: "/" 9 | schedule: 10 | interval: "weekly" 11 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | push: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | build: 13 | strategy: 14 | matrix: 15 | java: [ '8.0.192', '8', '11.0.3', '11', '15', '17' ] 16 | os: [ 'ubuntu-latest' ] 17 | runs-on: ${{ matrix.os }} 18 | steps: 19 | - uses: actions/checkout@v4 20 | - name: Set up JDK ${{ matrix.java }} 21 | uses: actions/setup-java@v4 22 | with: 23 | java-version: ${{ matrix.java }} 24 | distribution: 'zulu' 25 | - name: print Java version 26 | run: java -version 27 | - uses: actions/cache@v4 28 | with: 29 | path: ~/.m2/repository 30 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} 31 | restore-keys: | 32 | ${{ runner.os }}-maven- 33 | - name: Build 34 | run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .classpath 3 | .project 4 | .settings 5 | *.iml 6 | *.ipr 7 | *.iws 8 | bin 9 | target 10 | *~ 11 | .*~ 12 | *.hs 13 | -------------------------------------------------------------------------------- /.java-version: -------------------------------------------------------------------------------- 1 | 1.8 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | matrix: 3 | include: 4 | - jdk: openjdk8 5 | install: true 6 | - jdk: openjdk11 7 | install: true 8 | - jdk: openjdk14 9 | install: true 10 | before_install: 11 | - sudo apt-get update -qq 12 | install: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V 13 | script: mvn clean test 14 | cache: 15 | directories: 16 | - $HOME/.m2 17 | branches: 18 | except: 19 | - gh-pages 20 | - 0.5-branch 21 | - 0.6-branch 22 | - 0.7-branch 23 | - 0.8-branch 24 | notifications: 25 | email: 26 | recipients: 27 | - pholser@alumni.rice.edu 28 | 29 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2010-2021 Paul R. Holser, Jr. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /conf/MIT-LICENSE.txt: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | -------------------------------------------------------------------------------- /conf/checkstyle-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/MinimalCounterexampleHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck; 27 | 28 | /** 29 | *

Allows access to an actual failing example.

30 | * 31 | *

This may be useful if any of the objects' {@link Object#toString()} 32 | * representations is difficult to understand.

33 | * 34 | * @see Property#onMinimalCounterexample() 35 | */ 36 | public interface MinimalCounterexampleHook { 37 | /** 38 | * @param counterexample the minimal counterexample (after shrinking) 39 | * @param action work to perform with the minimal counterexample; 40 | * for example, this could repeat the test using the same inputs. 41 | * This action should be safely callable multiple times. 42 | */ 43 | void handle(Object[] counterexample, Runnable action); 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/conversion/StringConversion.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.conversion; 27 | 28 | /** 29 | * Describes ways of transforming string input into objects of another type. 30 | */ 31 | @FunctionalInterface 32 | public interface StringConversion { 33 | /** 34 | * Transform the given "raw" string" into an object of another type. 35 | * 36 | * @param raw the string to convert 37 | * @return the result of the conversion 38 | */ 39 | Object convert(String raw); 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/generator/GeneratorConfigurationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator; 27 | 28 | /** 29 | * Raised if a problem arises when attempting to configure a generator with 30 | * annotations from a property parameter. 31 | * 32 | * @see Generator#configure(java.lang.reflect.AnnotatedType) 33 | */ 34 | public class GeneratorConfigurationException extends RuntimeException { 35 | private static final long serialVersionUID = 1L; 36 | 37 | public GeneratorConfigurationException(String message) { 38 | super(message); 39 | } 40 | 41 | public GeneratorConfigurationException(String message, Throwable cause) { 42 | super(message, cause); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/generator/NullAllowed.java: -------------------------------------------------------------------------------- 1 | package com.pholser.junit.quickcheck.generator; 2 | 3 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 4 | import static java.lang.annotation.ElementType.FIELD; 5 | import static java.lang.annotation.ElementType.PARAMETER; 6 | import static java.lang.annotation.ElementType.TYPE_USE; 7 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 8 | 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | *

Mark a parameter of a {@link com.pholser.junit.quickcheck.Property} 14 | * method with this annotation to indicate that the parameter is nullable, and 15 | * to optionally configure the probability of generating a null value.

16 | */ 17 | @Target({ PARAMETER, FIELD, ANNOTATION_TYPE, TYPE_USE }) 18 | @Retention(RUNTIME) 19 | public @interface NullAllowed { 20 | /** 21 | * @return probability of generating {@code null}, in the range [0,1] 22 | */ 23 | double probability() default 0.2; 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/generator/Shrink.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator; 27 | 28 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 29 | import java.util.List; 30 | 31 | /** 32 | * Represents a strategy for producing objects "smaller than" a given object. 33 | * 34 | * @param type of shrunken objects produced 35 | */ 36 | @FunctionalInterface 37 | public interface Shrink { 38 | /** 39 | * Gives some objects that are "smaller" than a given object. 40 | * 41 | * @param random source of randomness to use in shrinking, if desired 42 | * @param larger the larger object 43 | * @return objects that are "smaller" than the larger object 44 | */ 45 | List shrink(SourceOfRandomness random, Object larger); 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/hook/NilMinimalCounterexampleHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.hook; 27 | 28 | import com.pholser.junit.quickcheck.MinimalCounterexampleHook; 29 | 30 | /** 31 | * Counterexample hook that does nothing. 32 | */ 33 | public class NilMinimalCounterexampleHook 34 | implements MinimalCounterexampleHook { 35 | 36 | @Override public void handle(Object[] counterexample, Runnable action) { 37 | // do nothing purposely 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/internal/DefaultMethodHandleMaker.java: -------------------------------------------------------------------------------- 1 | package com.pholser.junit.quickcheck.internal; 2 | 3 | import static com.pholser.junit.quickcheck.internal.Reflection.findDeclaredConstructor; 4 | import static com.pholser.junit.quickcheck.internal.Reflection.jdk9OrBetter; 5 | 6 | import java.lang.invoke.MethodHandle; 7 | import java.lang.invoke.MethodHandles; 8 | import java.lang.invoke.MethodHandles.Lookup; 9 | import java.lang.invoke.MethodType; 10 | import java.lang.reflect.Constructor; 11 | import java.lang.reflect.Method; 12 | 13 | public final class DefaultMethodHandleMaker { 14 | private static volatile Constructor methodLookupCtorJDK8; 15 | 16 | private static Constructor methodLookupCtorJDK8() { 17 | if (methodLookupCtorJDK8 == null) { 18 | methodLookupCtorJDK8 = 19 | findDeclaredConstructor(Lookup.class, Class.class, int.class); 20 | } 21 | 22 | return methodLookupCtorJDK8; 23 | } 24 | 25 | public MethodHandle handleForSpecialMethod(Method method) 26 | throws Exception { 27 | 28 | return jdk9OrBetter() 29 | ? jdk9OrBetterMethodHandle(method) 30 | : jdk8MethodHandleForDefault(method); 31 | } 32 | 33 | private MethodHandle jdk9OrBetterMethodHandle(Method method) 34 | throws Exception { 35 | 36 | return MethodHandles.lookup() 37 | .findSpecial( 38 | method.getDeclaringClass(), 39 | method.getName(), 40 | MethodType.methodType( 41 | method.getReturnType(), 42 | method.getParameterTypes()), 43 | method.getDeclaringClass()); 44 | } 45 | 46 | private MethodHandle jdk8MethodHandleForDefault(Method method) 47 | throws Exception { 48 | 49 | Lookup lookup = 50 | methodLookupCtorJDK8().newInstance( 51 | method.getDeclaringClass(), 52 | Lookup.PRIVATE); 53 | return lookup.unreflectSpecial(method, method.getDeclaringClass()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/internal/ParameterSampler.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | import com.pholser.junit.quickcheck.generator.Generator; 29 | import com.pholser.junit.quickcheck.internal.generator.GeneratorRepository; 30 | import com.pholser.junit.quickcheck.internal.generator.PropertyParameterGenerationContext; 31 | import java.util.List; 32 | import java.util.stream.Stream; 33 | 34 | public interface ParameterSampler { 35 | int sizeFactor(ParameterTypeContext p); 36 | 37 | Stream> sample( 38 | List parameters); 39 | 40 | default Generator decideGenerator( 41 | GeneratorRepository repository, 42 | ParameterTypeContext p) { 43 | 44 | return repository.produceGenerator(p); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/internal/ReflectionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | public class ReflectionException extends RuntimeException { 29 | private static final long serialVersionUID = Long.MIN_VALUE; 30 | 31 | public ReflectionException(String message) { 32 | super(message); 33 | } 34 | 35 | public ReflectionException(Throwable cause) { 36 | super(cause.toString()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/internal/Weighted.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | public final class Weighted { 29 | public final T item; 30 | public final int weight; 31 | 32 | public Weighted(T item, int weight) { 33 | if (weight <= 0) { 34 | throw new IllegalArgumentException( 35 | "non-positive weight: " + weight); 36 | } 37 | 38 | this.item = item; 39 | this.weight = weight; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/internal/Zilch.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | public final class Zilch { 29 | public static final Zilch INSTANCE = new Zilch(); 30 | 31 | private Zilch() { 32 | // nothing to do here 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/internal/conversion/ConstructorInvokingStringConversion.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal.conversion; 27 | 28 | import static com.pholser.junit.quickcheck.internal.Reflection.reflectionException; 29 | 30 | import com.pholser.junit.quickcheck.conversion.StringConversion; 31 | import java.lang.reflect.Constructor; 32 | 33 | public class ConstructorInvokingStringConversion implements StringConversion { 34 | private final Constructor ctor; 35 | 36 | ConstructorInvokingStringConversion(Constructor ctor) { 37 | this.ctor = ctor; 38 | } 39 | 40 | @Override public Object convert(String raw) { 41 | try { 42 | return ctor.newInstance(raw); 43 | } catch (Exception ex) { 44 | throw reflectionException(ex); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/internal/conversion/MethodInvokingStringConversion.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal.conversion; 27 | 28 | import static com.pholser.junit.quickcheck.internal.Reflection.reflectionException; 29 | 30 | import com.pholser.junit.quickcheck.conversion.StringConversion; 31 | import java.lang.reflect.Method; 32 | 33 | public class MethodInvokingStringConversion implements StringConversion { 34 | private final Method method; 35 | 36 | MethodInvokingStringConversion(Method method) { 37 | this.method = method; 38 | } 39 | 40 | @Override public Object convert(String raw) { 41 | try { 42 | return method.invoke(null, raw); 43 | } catch (Exception ex) { 44 | throw reflectionException(ex); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/internal/generator/SamplingDomainGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal.generator; 27 | 28 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 29 | import com.pholser.junit.quickcheck.generator.Generator; 30 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 31 | import java.util.ArrayList; 32 | import java.util.List; 33 | import java.util.Set; 34 | 35 | public class SamplingDomainGenerator extends Generator { 36 | private final List items; 37 | 38 | public SamplingDomainGenerator(Set items) { 39 | super(Object.class); 40 | 41 | this.items = new ArrayList<>(items); 42 | } 43 | 44 | @Override public Object generate( 45 | SourceOfRandomness random, 46 | GenerationStatus status) { 47 | 48 | return random.choose(items); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/internal/generator/SimpleGenerationStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal.generator; 27 | 28 | import com.pholser.junit.quickcheck.internal.GeometricDistribution; 29 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 30 | 31 | public class SimpleGenerationStatus extends AbstractGenerationStatus { 32 | private final int attempts; 33 | 34 | public SimpleGenerationStatus( 35 | GeometricDistribution distro, 36 | SourceOfRandomness random, 37 | int attempts) { 38 | 39 | super(distro, random); 40 | this.attempts = attempts; 41 | } 42 | 43 | @Override public int attempts() { 44 | return attempts; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/internal/generator/ZilchGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal.generator; 27 | 28 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 29 | import com.pholser.junit.quickcheck.generator.Generator; 30 | import com.pholser.junit.quickcheck.internal.Zilch; 31 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 32 | 33 | public class ZilchGenerator extends Generator { 34 | public ZilchGenerator() { 35 | super(Zilch.class); 36 | } 37 | 38 | @Override public Zilch generate( 39 | SourceOfRandomness random, 40 | GenerationStatus status) { 41 | 42 | return Zilch.INSTANCE; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/com/pholser/junit/quickcheck/runner/NoValuesSatisfiedPropertyAssumptions.java: -------------------------------------------------------------------------------- 1 | package com.pholser.junit.quickcheck.runner; 2 | 3 | import java.util.List; 4 | import org.junit.internal.AssumptionViolatedException; 5 | 6 | class NoValuesSatisfiedPropertyAssumptions 7 | extends org.junit.AssumptionViolatedException { 8 | 9 | NoValuesSatisfiedPropertyAssumptions( 10 | List violations) { 11 | 12 | super( 13 | "No values satisfied property assumptions. Violated assumptions: " 14 | + violations); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/main/resources/META-INF/services/com.pholser.junit.quickcheck.generator.Generator: -------------------------------------------------------------------------------- 1 | com.pholser.junit.quickcheck.internal.generator.ZilchGenerator 2 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/Classes.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck; 27 | 28 | import static com.google.common.io.Resources.getResource; 29 | 30 | import com.google.common.io.Resources; 31 | import java.io.IOException; 32 | import java.nio.charset.StandardCharsets; 33 | 34 | final class Classes { 35 | private Classes() { 36 | throw new UnsupportedOperationException(); 37 | } 38 | 39 | static String currentMethodName() { 40 | StackTraceElement[] trace = Thread.currentThread().getStackTrace(); 41 | StackTraceElement element = trace[2]; 42 | return element.getClassName() + "::" + element.getMethodName(); 43 | } 44 | 45 | static String resourceAsString(String name) throws IOException { 46 | return Resources.toString(getResource(name), StandardCharsets.UTF_8); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/FooEqualsHashCodeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck; 27 | 28 | import com.pholser.junit.quickcheck.test.generator.Foo; 29 | 30 | public class FooEqualsHashCodeTest extends EqualsHashCodePropertiesTest { 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/GeneratorDescriptorsIssue235.java: -------------------------------------------------------------------------------- 1 | package com.pholser.junit.quickcheck; 2 | 3 | import com.pholser.junit.quickcheck.test.generator.AString; 4 | import java.util.HashMap; 5 | 6 | public class GeneratorDescriptorsIssue235 { 7 | public static final HashMap< 8 | @Produced({ 9 | @From(value = AString.class, frequency = 50), 10 | @From(value = AString.class, frequency = 50) 11 | }) 12 | String, 13 | String> manifestAttributes = null; 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/LongRunning.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck; 27 | 28 | public class LongRunning { 29 | } 30 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/PairTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck; 27 | 28 | import static org.junit.Assert.assertEquals; 29 | 30 | import com.google.common.testing.EqualsTester; 31 | import org.junit.Test; 32 | 33 | public class PairTest { 34 | @Test public void equalsHash() { 35 | new EqualsTester() 36 | .addEqualityGroup(new Pair<>(1, 2), new Pair<>(1, 2)) 37 | .addEqualityGroup(new Pair<>(null, 3), new Pair<>(null, 3)) 38 | .addEqualityGroup(new Pair<>(4, null), new Pair<>(4, null)) 39 | .addEqualityGroup(new Pair<>(null, null), new Pair<>(null, null)) 40 | .testEquals(); 41 | } 42 | 43 | @Test public void stringifying() { 44 | assertEquals("[1 = 2]", new Pair<>(1, 2).toString()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/Strings.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck; 27 | 28 | public final class Strings { 29 | private Strings() { 30 | throw new UnsupportedOperationException(); 31 | } 32 | 33 | public static String normalizeLineEndings(String s) { 34 | return s.replaceAll(System.lineSeparator(), "\r\n"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/Types.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck; 27 | 28 | import com.pholser.junit.quickcheck.internal.ParameterTypeContext; 29 | 30 | public final class Types { 31 | private Types() { 32 | throw new UnsupportedOperationException(); 33 | } 34 | 35 | public static ParameterTypeContext typeOf(Class c, String fieldName) 36 | throws NoSuchFieldException { 37 | 38 | return ParameterTypeContext.forField(c.getDeclaredField(fieldName)) 39 | .allowMixedTypes(true); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/generator/LambdasUtilityClassTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2004-2011 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator; 27 | 28 | import com.pholser.junit.quickcheck.UtilityClassesUninstantiabilityHarness; 29 | 30 | public class LambdasUtilityClassTest 31 | extends UtilityClassesUninstantiabilityHarness { 32 | 33 | public LambdasUtilityClassTest() { 34 | super(Lambdas.class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/ComparablesUtilityClassTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2004-2011 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | import com.pholser.junit.quickcheck.UtilityClassesUninstantiabilityHarness; 29 | 30 | public class ComparablesUtilityClassTest 31 | extends UtilityClassesUninstantiabilityHarness { 32 | 33 | public ComparablesUtilityClassTest() { 34 | super(Comparables.class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/FakeAnnotatedTypeFactoryUtilityClassTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | import com.pholser.junit.quickcheck.UtilityClassesUninstantiabilityHarness; 29 | 30 | public class FakeAnnotatedTypeFactoryUtilityClassTest 31 | extends UtilityClassesUninstantiabilityHarness { 32 | 33 | public FakeAnnotatedTypeFactoryUtilityClassTest() { 34 | super(FakeAnnotatedTypeFactory.class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/InvocationTargetProblematic.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2004-2011 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | public class InvocationTargetProblematic { 29 | public InvocationTargetProblematic() { 30 | throw new IllegalStateException(); 31 | } 32 | 33 | public InvocationTargetProblematic(int i) { 34 | throw new IndexOutOfBoundsException(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/ItemsUtilityClassTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2004-2011 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | import com.pholser.junit.quickcheck.UtilityClassesUninstantiabilityHarness; 29 | 30 | public class ItemsUtilityClassTest 31 | extends UtilityClassesUninstantiabilityHarness { 32 | 33 | public ItemsUtilityClassTest() { 34 | super(Items.class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/ListsUtilityClassTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | import com.pholser.junit.quickcheck.UtilityClassesUninstantiabilityHarness; 29 | 30 | public class ListsUtilityClassTest 31 | extends UtilityClassesUninstantiabilityHarness { 32 | 33 | public ListsUtilityClassTest() { 34 | super(Lists.class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/MultiArgIllegalAccessProblematic.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2004-2011 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | class MultiArgIllegalAccessProblematic { 29 | private MultiArgIllegalAccessProblematic(int i) { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/RangesUtilityClassTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2004-2011 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | import com.pholser.junit.quickcheck.UtilityClassesUninstantiabilityHarness; 29 | 30 | public class RangesUtilityClassTest 31 | extends UtilityClassesUninstantiabilityHarness { 32 | 33 | public RangesUtilityClassTest() { 34 | super(Ranges.class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/ReflectionUtilityClassTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2004-2011 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | import com.pholser.junit.quickcheck.UtilityClassesUninstantiabilityHarness; 29 | 30 | public class ReflectionUtilityClassTest 31 | extends UtilityClassesUninstantiabilityHarness { 32 | 33 | public ReflectionUtilityClassTest() { 34 | super(Reflection.class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/SequencesUtilityClassTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2004-2011 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | import com.pholser.junit.quickcheck.UtilityClassesUninstantiabilityHarness; 29 | 30 | public class SequencesUtilityClassTest 31 | extends UtilityClassesUninstantiabilityHarness { 32 | 33 | public SequencesUtilityClassTest() { 34 | super(Sequences.class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/WeightedTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | import org.junit.Test; 29 | 30 | public class WeightedTest { 31 | @Test(expected = IllegalArgumentException.class) 32 | public void disallowZero() { 33 | new Weighted<>(null, 0); 34 | } 35 | 36 | @Test(expected = IllegalArgumentException.class) 37 | public void disallowNegative() { 38 | new Weighted<>(null, -1); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/ZeroArgIllegalAccessProblematic.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2004-2011 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal; 27 | 28 | class ZeroArgIllegalAccessProblematic { 29 | private ZeroArgIllegalAccessProblematic() { 30 | // no-op 31 | } 32 | 33 | ZeroArgIllegalAccessProblematic(int i) { 34 | } 35 | 36 | private void foo() { 37 | // no-op 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/generator/conventiontestclasses/Convention.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal.generator.conventiontestclasses; 27 | 28 | public class Convention { 29 | // just need an object in a package 30 | } 31 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/generator/conventiontestclasses/ConventionGen.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal.generator.conventiontestclasses; 27 | 28 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 29 | import com.pholser.junit.quickcheck.generator.Generator; 30 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 31 | 32 | public class ConventionGen extends Generator { 33 | public ConventionGen() { 34 | super(Convention.class); 35 | } 36 | 37 | @Override public Convention generate( 38 | SourceOfRandomness random, 39 | GenerationStatus status) { 40 | 41 | return new Convention(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/generator/conventiontestclasses/GeneratesOtherTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal.generator.conventiontestclasses; 27 | 28 | public class GeneratesOtherTypes { 29 | // just need an object in a package 30 | } 31 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/generator/conventiontestclasses/GeneratesOtherTypesGen.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal.generator.conventiontestclasses; 27 | 28 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 29 | import com.pholser.junit.quickcheck.generator.Generator; 30 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 31 | 32 | public class GeneratesOtherTypesGen extends Generator { 33 | public GeneratesOtherTypesGen() { 34 | super(Void.class); 35 | } 36 | 37 | @Override public Void generate( 38 | SourceOfRandomness random, 39 | GenerationStatus status) { 40 | 41 | return null; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/generator/conventiontestclasses/NotAGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal.generator.conventiontestclasses; 27 | 28 | public class NotAGenerator { 29 | // just need an object in a package 30 | } 31 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/internal/generator/conventiontestclasses/NotAGeneratorGen.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.internal.generator.conventiontestclasses; 27 | 28 | public class NotAGeneratorGen { 29 | // just need an object in a package with this name 30 | } 31 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/test/generator/ABigInt.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.test.generator; 27 | 28 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 29 | import com.pholser.junit.quickcheck.generator.Generator; 30 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 31 | import java.math.BigDecimal; 32 | import java.math.BigInteger; 33 | 34 | public class ABigInt extends Generator { 35 | public ABigInt() { 36 | super(BigInteger.class); 37 | } 38 | 39 | @Override public BigInteger generate( 40 | SourceOfRandomness random, 41 | GenerationStatus status) { 42 | 43 | return new BigInteger(random.nextBytes(status.size() + 1)); 44 | } 45 | 46 | @Override public BigDecimal magnitude(Object value) { 47 | return new BigDecimal(narrow(value)); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/test/generator/ABool.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.test.generator; 27 | 28 | import static java.util.Arrays.asList; 29 | 30 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 31 | import com.pholser.junit.quickcheck.generator.Generator; 32 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 33 | 34 | public class ABool extends Generator { 35 | public ABool() { 36 | super(asList(Boolean.class, boolean.class)); 37 | } 38 | 39 | @Override public Boolean generate( 40 | SourceOfRandomness random, 41 | GenerationStatus status) { 42 | 43 | return random.nextBoolean(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/test/generator/AByte.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.test.generator; 27 | 28 | import static java.util.Arrays.asList; 29 | 30 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 31 | import com.pholser.junit.quickcheck.generator.Generator; 32 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 33 | import java.math.BigDecimal; 34 | 35 | public class AByte extends Generator { 36 | public AByte() { 37 | super(asList(Byte.class, byte.class)); 38 | } 39 | 40 | @Override public Byte generate( 41 | SourceOfRandomness random, 42 | GenerationStatus status) { 43 | 44 | return (byte) random.nextInt(); 45 | } 46 | 47 | @Override public BigDecimal magnitude(Object value) { 48 | return BigDecimal.valueOf(narrow(value)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/test/generator/AChar.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.test.generator; 27 | 28 | import static java.util.Arrays.asList; 29 | 30 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 31 | import com.pholser.junit.quickcheck.generator.Generator; 32 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 33 | import java.math.BigDecimal; 34 | 35 | public class AChar extends Generator { 36 | public AChar() { 37 | super(asList(Character.class, char.class)); 38 | } 39 | 40 | @Override public Character generate( 41 | SourceOfRandomness random, 42 | GenerationStatus status) { 43 | 44 | return (char) random.nextInt(); 45 | } 46 | 47 | @Override public BigDecimal magnitude(Object value) { 48 | return BigDecimal.valueOf(narrow(value)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/test/generator/ADecimal.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.test.generator; 27 | 28 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 29 | import com.pholser.junit.quickcheck.generator.Generator; 30 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 31 | import java.math.BigDecimal; 32 | 33 | public class ADecimal extends Generator { 34 | public ADecimal() { 35 | super(BigDecimal.class); 36 | } 37 | 38 | @Override public BigDecimal generate( 39 | SourceOfRandomness random, 40 | GenerationStatus status) { 41 | 42 | return BigDecimal.valueOf(random.nextDouble()); 43 | } 44 | 45 | @Override public BigDecimal magnitude(Object value) { 46 | return narrow(value); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/test/generator/ADouble.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.test.generator; 27 | 28 | import static java.util.Arrays.asList; 29 | 30 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 31 | import com.pholser.junit.quickcheck.generator.Generator; 32 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 33 | import java.math.BigDecimal; 34 | 35 | public class ADouble extends Generator { 36 | public ADouble() { 37 | super(asList(Double.class, double.class)); 38 | } 39 | 40 | @Override public Double generate( 41 | SourceOfRandomness random, 42 | GenerationStatus status) { 43 | 44 | return random.nextDouble(); 45 | } 46 | 47 | @Override public BigDecimal magnitude(Object value) { 48 | return BigDecimal.valueOf(narrow(value)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/test/generator/AFloat.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.test.generator; 27 | 28 | import static java.util.Arrays.asList; 29 | 30 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 31 | import com.pholser.junit.quickcheck.generator.Generator; 32 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 33 | import java.math.BigDecimal; 34 | 35 | public class AFloat extends Generator { 36 | public AFloat() { 37 | super(asList(Float.class, float.class)); 38 | } 39 | 40 | @Override public Float generate( 41 | SourceOfRandomness random, 42 | GenerationStatus status) { 43 | 44 | return random.nextFloat(); 45 | } 46 | 47 | @Override public BigDecimal magnitude(Object value) { 48 | return BigDecimal.valueOf(narrow(value)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/test/generator/ALong.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.test.generator; 27 | 28 | import static java.util.Arrays.asList; 29 | 30 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 31 | import com.pholser.junit.quickcheck.generator.Generator; 32 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 33 | import java.math.BigDecimal; 34 | 35 | public class ALong extends Generator { 36 | public ALong() { 37 | super(asList(Long.class, long.class)); 38 | } 39 | 40 | @Override public Long generate( 41 | SourceOfRandomness random, 42 | GenerationStatus status) { 43 | 44 | return random.nextLong(); 45 | } 46 | 47 | @Override public BigDecimal magnitude(Object value) { 48 | return BigDecimal.valueOf(narrow(value)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/test/generator/AShort.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.test.generator; 27 | 28 | import static java.util.Arrays.asList; 29 | 30 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 31 | import com.pholser.junit.quickcheck.generator.Generator; 32 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 33 | import java.math.BigDecimal; 34 | 35 | public class AShort extends Generator { 36 | public AShort() { 37 | super(asList(Short.class, short.class)); 38 | } 39 | 40 | @Override public Short generate( 41 | SourceOfRandomness random, 42 | GenerationStatus status) { 43 | 44 | return (short) random.nextInt(); 45 | } 46 | 47 | @Override public BigDecimal magnitude(Object value) { 48 | return BigDecimal.valueOf(narrow(value)).abs(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/test/generator/AnotherBox.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.test.generator; 27 | 28 | public class AnotherBox extends ABox { 29 | } 30 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/test/generator/Between.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.test.generator; 27 | 28 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 29 | import static java.lang.annotation.ElementType.FIELD; 30 | import static java.lang.annotation.ElementType.PARAMETER; 31 | import static java.lang.annotation.ElementType.TYPE_USE; 32 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 33 | 34 | import com.pholser.junit.quickcheck.generator.GeneratorConfiguration; 35 | import java.lang.annotation.Retention; 36 | import java.lang.annotation.Target; 37 | 38 | @Target({ PARAMETER, FIELD, ANNOTATION_TYPE, TYPE_USE }) 39 | @Retention(RUNTIME) 40 | @GeneratorConfiguration 41 | public @interface Between { 42 | int min(); 43 | 44 | int max(); 45 | } 46 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/test/generator/FooBoxOpener.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.test.generator; 27 | 28 | public interface FooBoxOpener { 29 | Foo open(Box b); 30 | } 31 | -------------------------------------------------------------------------------- /core/src/test/java/com/pholser/junit/quickcheck/test/generator/X.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.test.generator; 27 | 28 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 29 | import static java.lang.annotation.ElementType.FIELD; 30 | import static java.lang.annotation.ElementType.PARAMETER; 31 | import static java.lang.annotation.ElementType.TYPE_USE; 32 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 33 | 34 | import com.pholser.junit.quickcheck.generator.GeneratorConfiguration; 35 | import java.lang.annotation.Retention; 36 | import java.lang.annotation.Target; 37 | 38 | @Target({ PARAMETER, FIELD, ANNOTATION_TYPE, TYPE_USE }) 39 | @Retention(RUNTIME) 40 | @GeneratorConfiguration 41 | public @interface X { 42 | } 43 | -------------------------------------------------------------------------------- /core/src/test/resources/META-INF/services/com.pholser.junit.quickcheck.generator.Generator: -------------------------------------------------------------------------------- 1 | com.pholser.junit.quickcheck.test.generator.AnotherBox 2 | com.pholser.junit.quickcheck.test.generator.AFoo 3 | com.pholser.junit.quickcheck.test.generator.APair 4 | -------------------------------------------------------------------------------- /core/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /examples/src/main/java/com/pholser/junit/quickcheck/examples/counter/Counter.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.counter; 27 | 28 | public final class Counter { 29 | private int count; 30 | 31 | public Counter() { 32 | } 33 | 34 | Counter increment() { 35 | ++count; 36 | return this; 37 | } 38 | 39 | Counter decrement() { 40 | --count; 41 | return this; 42 | } 43 | 44 | int count() { 45 | return count; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /examples/src/main/java/com/pholser/junit/quickcheck/examples/dummy/A.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.dummy; 27 | 28 | import java.util.List; 29 | 30 | class A { 31 | private final String someString; 32 | private final int someInt; 33 | private List listOfB; 34 | 35 | A(String someString, int someInt) { 36 | this.someString = someString; 37 | this.someInt = someInt; 38 | } 39 | 40 | List getListOfB() { 41 | return listOfB; 42 | } 43 | 44 | void setListOfB(List listOfB) { 45 | this.listOfB = listOfB; 46 | } 47 | 48 | @Override public String toString() { 49 | return String.format("%s, %d, %s", someString, someInt, listOfB); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /examples/src/main/java/com/pholser/junit/quickcheck/examples/dummy/B.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.dummy; 27 | 28 | class B { 29 | private final String someString; 30 | private final int someInt; 31 | 32 | B(String someString, int someInt) { 33 | this.someString = someString; 34 | this.someInt = someInt; 35 | } 36 | 37 | @Override public String toString() { 38 | return String.format("%s, %d", someString, someInt); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/src/main/java/com/pholser/junit/quickcheck/examples/money/DollarsAndCents.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.money; 27 | 28 | import static java.math.RoundingMode.HALF_EVEN; 29 | 30 | import java.math.BigDecimal; 31 | 32 | final class DollarsAndCents { 33 | private final BigDecimal amount; 34 | 35 | DollarsAndCents(BigDecimal amount) { 36 | this.amount = amount.setScale(2, HALF_EVEN); 37 | } 38 | 39 | BigDecimal toBigDecimal() { 40 | return amount; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examples/src/main/java/com/pholser/junit/quickcheck/examples/number/NonNegative.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.number; 27 | 28 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 29 | import static java.lang.annotation.ElementType.FIELD; 30 | import static java.lang.annotation.ElementType.PARAMETER; 31 | import static java.lang.annotation.ElementType.TYPE_USE; 32 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 33 | 34 | import com.pholser.junit.quickcheck.generator.GeneratorConfiguration; 35 | import java.lang.annotation.Retention; 36 | import java.lang.annotation.Target; 37 | 38 | @Target({PARAMETER, FIELD, ANNOTATION_TYPE, TYPE_USE}) 39 | @Retention(RUNTIME) 40 | @GeneratorConfiguration 41 | public @interface NonNegative { 42 | } 43 | -------------------------------------------------------------------------------- /examples/src/main/java/com/pholser/junit/quickcheck/examples/tree/Empty.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.tree; 27 | 28 | import com.pholser.junit.quickcheck.examples.tree.visitor.TreeStructureVisitor; 29 | 30 | public class Empty implements Tree { 31 | @Override public Object accept(TreeVisitor visitor) { 32 | return visitor.visit(this); 33 | } 34 | 35 | @Override public String toString() { 36 | TreeStructureVisitor v = new TreeStructureVisitor(); 37 | accept(v); 38 | return v.toString(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/src/main/java/com/pholser/junit/quickcheck/examples/tree/Leaf.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.tree; 27 | 28 | import com.pholser.junit.quickcheck.examples.tree.visitor.TreeStructureVisitor; 29 | 30 | public class Leaf implements Tree { 31 | private final String value; 32 | 33 | public Leaf(String value) { 34 | this.value = value; 35 | } 36 | 37 | @Override public Object accept(TreeVisitor visitor) { 38 | return visitor.visit(this); 39 | } 40 | 41 | public String value() { 42 | return value; 43 | } 44 | 45 | @Override public String toString() { 46 | TreeStructureVisitor v = new TreeStructureVisitor(); 47 | accept(v); 48 | return v.toString(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /examples/src/main/java/com/pholser/junit/quickcheck/examples/tree/Node.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.tree; 27 | 28 | import com.pholser.junit.quickcheck.examples.tree.visitor.TreeStructureVisitor; 29 | 30 | public class Node implements Tree { 31 | private final Tree left; 32 | private final Tree right; 33 | 34 | public Node(Tree left, Tree right) { 35 | this.left = left; 36 | this.right = right; 37 | } 38 | 39 | @Override public Object accept(TreeVisitor visitor) { 40 | return visitor.visit(this); 41 | } 42 | 43 | public Tree left() { 44 | return left; 45 | } 46 | 47 | public Tree right() { 48 | return right; 49 | } 50 | 51 | @Override public String toString() { 52 | TreeStructureVisitor v = new TreeStructureVisitor(); 53 | accept(v); 54 | return v.toString(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /examples/src/main/java/com/pholser/junit/quickcheck/examples/tree/Tree.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.tree; 27 | 28 | public interface Tree extends Visited { 29 | } 30 | -------------------------------------------------------------------------------- /examples/src/main/java/com/pholser/junit/quickcheck/examples/tree/TreeVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.tree; 27 | 28 | public interface TreeVisitor { 29 | Object visit(Empty empty); 30 | 31 | Object visit(Leaf leaf); 32 | 33 | Object visit(Node node); 34 | } 35 | -------------------------------------------------------------------------------- /examples/src/main/java/com/pholser/junit/quickcheck/examples/tree/Visited.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.tree; 27 | 28 | public interface Visited { 29 | Object accept(V visitor); 30 | } 31 | -------------------------------------------------------------------------------- /examples/src/main/java/com/pholser/junit/quickcheck/examples/tree/visitor/TreeDepthVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.tree.visitor; 27 | 28 | import com.pholser.junit.quickcheck.examples.tree.Empty; 29 | import com.pholser.junit.quickcheck.examples.tree.Leaf; 30 | import com.pholser.junit.quickcheck.examples.tree.Node; 31 | import com.pholser.junit.quickcheck.examples.tree.TreeVisitor; 32 | 33 | public class TreeDepthVisitor implements TreeVisitor { 34 | @Override public Integer visit(Empty empty) { 35 | return 0; 36 | } 37 | 38 | @Override public Integer visit(Leaf leaf) { 39 | return 0; 40 | } 41 | 42 | @Override public Integer visit(Node node) { 43 | Integer leftDepth = (Integer) node.left().accept(this); 44 | Integer rightDepth = (Integer) node.right().accept(this); 45 | return 1 + Math.max(leftDepth, rightDepth); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /examples/src/test/java/com/pholser/junit/quickcheck/examples/convention/Convention.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.convention; 27 | 28 | public class Convention { 29 | } 30 | -------------------------------------------------------------------------------- /examples/src/test/java/com/pholser/junit/quickcheck/examples/convention/ConventionGen.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.convention; 27 | 28 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 29 | import com.pholser.junit.quickcheck.generator.Generator; 30 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 31 | 32 | public class ConventionGen extends Generator { 33 | public ConventionGen() { 34 | super(Convention.class); 35 | } 36 | 37 | @Override public Convention generate( 38 | SourceOfRandomness random, 39 | GenerationStatus status) { 40 | 41 | return new Convention(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /examples/src/test/java/com/pholser/junit/quickcheck/examples/dummy/AGeneratorTest.java: -------------------------------------------------------------------------------- 1 | package com.pholser.junit.quickcheck.examples.dummy; 2 | 3 | import static org.hamcrest.MatcherAssert.assertThat; 4 | import static org.hamcrest.Matchers.instanceOf; 5 | 6 | import com.pholser.junit.quickcheck.Property; 7 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 8 | import org.junit.runner.RunWith; 9 | 10 | @RunWith(JUnitQuickcheck.class) 11 | public class AGeneratorTest { 12 | @Property public void listAreCorrectlyGenerated(A a) { 13 | a.getListOfB().forEach(b -> 14 | assertThat(b, instanceOf(B.class))); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/src/test/java/com/pholser/junit/quickcheck/examples/dummy/BGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.dummy; 27 | 28 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 29 | import com.pholser.junit.quickcheck.generator.Generator; 30 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 31 | 32 | public class BGenerator extends Generator { 33 | public BGenerator() { 34 | super(B.class); 35 | } 36 | 37 | @Override public B generate(SourceOfRandomness r, GenerationStatus s) { 38 | String someString = gen().type(String.class).generate(r, s); 39 | int someInt = gen().type(int.class).generate(r, s); 40 | 41 | return new B(someString, someInt); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /examples/src/test/java/com/pholser/junit/quickcheck/examples/func/EitherTest.java: -------------------------------------------------------------------------------- 1 | package com.pholser.junit.quickcheck.examples.func; 2 | 3 | import static org.hamcrest.MatcherAssert.assertThat; 4 | import static org.hamcrest.Matchers.allOf; 5 | import static org.hamcrest.Matchers.greaterThanOrEqualTo; 6 | import static org.hamcrest.Matchers.lessThanOrEqualTo; 7 | 8 | import com.pholser.junit.quickcheck.Property; 9 | import com.pholser.junit.quickcheck.generator.InRange; 10 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 11 | import org.junit.runner.RunWith; 12 | 13 | @RunWith(JUnitQuickcheck.class) 14 | public class EitherTest { 15 | @Property public void withRanges( 16 | Either< 17 | @InRange(minInt = 0) Integer, 18 | @InRange(minDouble = -7.0, maxDouble = -4.0) Double> e) { 19 | 20 | e.map( 21 | left -> { 22 | assertThat(left, greaterThanOrEqualTo(0)); 23 | return 0; 24 | }, 25 | right -> { 26 | assertThat( 27 | right, 28 | allOf( 29 | greaterThanOrEqualTo(-7.0), 30 | lessThanOrEqualTo(-4.0))); 31 | return 1; 32 | } 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/src/test/java/com/pholser/junit/quickcheck/examples/geom/Dimensions.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.geom; 27 | 28 | import static java.lang.Math.abs; 29 | 30 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 31 | import com.pholser.junit.quickcheck.generator.Generator; 32 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 33 | import java.awt.Dimension; 34 | 35 | public class Dimensions extends Generator { 36 | public Dimensions() { 37 | super(Dimension.class); 38 | } 39 | 40 | @Override public Dimension generate( 41 | SourceOfRandomness r, 42 | GenerationStatus status) { 43 | 44 | return new Dimension(abs(r.nextInt()), abs(r.nextInt())); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /examples/src/test/java/com/pholser/junit/quickcheck/examples/geom/SegmentPropertiesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.geom; 27 | 28 | import static org.junit.Assert.assertEquals; 29 | 30 | import com.pholser.junit.quickcheck.Property; 31 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 32 | import org.junit.runner.RunWith; 33 | 34 | @RunWith(JUnitQuickcheck.class) 35 | public class SegmentPropertiesTest { 36 | @Property public void intersectionIsSymmetric( 37 | Segment a, 38 | Segment b) { 39 | 40 | assertEquals(a.intersects(b), b.intersects(a)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examples/src/test/java/com/pholser/junit/quickcheck/examples/number/NumbersPropertiesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.number; 27 | 28 | import static org.hamcrest.MatcherAssert.assertThat; 29 | import static org.hamcrest.Matchers.greaterThanOrEqualTo; 30 | 31 | import com.pholser.junit.quickcheck.Property; 32 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 33 | import org.junit.runner.RunWith; 34 | 35 | @RunWith(JUnitQuickcheck.class) 36 | public class NumbersPropertiesTest { 37 | @Property public void nonNegativity(@NonNegative int i) { 38 | assertThat(i, greaterThanOrEqualTo(0)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/src/test/java/com/pholser/junit/quickcheck/examples/text/StringPropertiesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.text; 27 | 28 | import static org.junit.Assert.assertEquals; 29 | 30 | import com.pholser.junit.quickcheck.Property; 31 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 32 | import org.junit.runner.RunWith; 33 | 34 | @RunWith(JUnitQuickcheck.class) 35 | public class StringPropertiesTest { 36 | @Property public void concatenationLength(String s1, String s2) { 37 | assertEquals(s1.length() + s2.length(), (s1 + s2).length()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/src/test/java/com/pholser/junit/quickcheck/examples/tree/Depth.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.tree; 27 | 28 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 29 | import static java.lang.annotation.ElementType.FIELD; 30 | import static java.lang.annotation.ElementType.PARAMETER; 31 | import static java.lang.annotation.ElementType.TYPE_USE; 32 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 33 | 34 | import com.pholser.junit.quickcheck.generator.GeneratorConfiguration; 35 | import java.lang.annotation.Retention; 36 | import java.lang.annotation.Target; 37 | 38 | @Target({ PARAMETER, FIELD, ANNOTATION_TYPE, TYPE_USE }) 39 | @Retention(RUNTIME) 40 | @GeneratorConfiguration 41 | public @interface Depth { 42 | int min() default 0; 43 | 44 | int max(); 45 | } 46 | -------------------------------------------------------------------------------- /examples/src/test/java/com/pholser/junit/quickcheck/examples/tree/EmptyGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.tree; 27 | 28 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 29 | import com.pholser.junit.quickcheck.generator.Generator; 30 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 31 | 32 | public class EmptyGenerator extends Generator { 33 | public EmptyGenerator() { 34 | super(Empty.class); 35 | } 36 | 37 | @Override public Empty generate(SourceOfRandomness r, GenerationStatus s) { 38 | return new Empty(); 39 | } 40 | 41 | @Override public boolean canRegisterAsType(Class type) { 42 | return Tree.class.isAssignableFrom(type); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /examples/src/test/java/com/pholser/junit/quickcheck/examples/tree/LeafGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.examples.tree; 27 | 28 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 29 | import com.pholser.junit.quickcheck.generator.Generator; 30 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 31 | 32 | public class LeafGenerator extends Generator { 33 | public LeafGenerator() { 34 | super(Leaf.class); 35 | } 36 | 37 | @Override public Leaf generate(SourceOfRandomness r, GenerationStatus s) { 38 | return new Leaf(gen().type(String.class).generate(r, s)); 39 | } 40 | 41 | @Override public boolean canRegisterAsType(Class type) { 42 | return Tree.class.isAssignableFrom(type); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /examples/src/test/java/com/pholser/junit/quickcheck/examples/tree/TreeKeys.java: -------------------------------------------------------------------------------- 1 | package com.pholser.junit.quickcheck.examples.tree; 2 | 3 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 4 | 5 | final class TreeKeys { 6 | static final GenerationStatus.Key DEPTH = 7 | new GenerationStatus.Key<>("depth", Integer.class); 8 | 9 | private TreeKeys() { 10 | throw new UnsupportedOperationException(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/src/test/resources/META-INF/services/com.pholser.junit.quickcheck.generator.Generator: -------------------------------------------------------------------------------- 1 | com.pholser.junit.quickcheck.examples.crypto.AES128Keys 2 | com.pholser.junit.quickcheck.examples.dummy.AGenerator 3 | com.pholser.junit.quickcheck.examples.dummy.BGenerator 4 | com.pholser.junit.quickcheck.examples.func.EitherGenerator 5 | com.pholser.junit.quickcheck.examples.geom.PointGenerator 6 | com.pholser.junit.quickcheck.examples.geom.PolygonGenerator 7 | com.pholser.junit.quickcheck.examples.geom.SegmentGenerator 8 | com.pholser.junit.quickcheck.examples.number.IntegralGenerator 9 | com.pholser.junit.quickcheck.examples.tree.EmptyGenerator 10 | com.pholser.junit.quickcheck.examples.tree.LeafGenerator 11 | com.pholser.junit.quickcheck.examples.tree.NodeGenerator 12 | -------------------------------------------------------------------------------- /generators/src/main/java/com/pholser/junit/quickcheck/generator/VoidGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator; 27 | 28 | import static java.util.Arrays.asList; 29 | 30 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 31 | 32 | /** 33 | * Produces values for property parameters of type {@code void} or 34 | * {@link Void}. 35 | */ 36 | public class VoidGenerator extends Generator { 37 | public VoidGenerator() { 38 | super(asList(Void.class, void.class)); 39 | } 40 | 41 | @Override public Void generate( 42 | SourceOfRandomness random, 43 | GenerationStatus status) { 44 | 45 | return null; 46 | } 47 | 48 | @Override 49 | public boolean canRegisterAsType(Class type) { 50 | return !Object.class.equals(type); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /generators/src/main/java/com/pholser/junit/quickcheck/generator/java/lang/StringGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.lang; 27 | 28 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 29 | 30 | /** 31 | *

Produces {@link String}s whose characters are in the interval 32 | * {@code [0x0000, 0xD7FF]}.

33 | */ 34 | public class StringGenerator extends AbstractStringGenerator { 35 | @Override protected int nextCodePoint(SourceOfRandomness random) { 36 | return random.nextInt(0, Character.MIN_SURROGATE - 1); 37 | } 38 | 39 | @Override protected boolean codePointInRange(int codePoint) { 40 | return codePoint >= 0 && codePoint < Character.MIN_SURROGATE; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /generators/src/main/java/com/pholser/junit/quickcheck/generator/java/time/ZoneIdGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.time; 27 | 28 | import static java.time.ZoneId.getAvailableZoneIds; 29 | 30 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 31 | import com.pholser.junit.quickcheck.generator.Generator; 32 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 33 | import java.time.ZoneId; 34 | 35 | /** 36 | * Produces values of type {@link ZoneId}. 37 | */ 38 | public class ZoneIdGenerator extends Generator { 39 | public ZoneIdGenerator() { 40 | super(ZoneId.class); 41 | } 42 | 43 | @Override public ZoneId generate( 44 | SourceOfRandomness random, 45 | GenerationStatus status) { 46 | 47 | return ZoneId.of(random.choose(getAvailableZoneIds())); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /generators/src/main/java/com/pholser/junit/quickcheck/generator/java/util/ArrayListGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.util; 27 | 28 | import java.util.ArrayList; 29 | 30 | /** 31 | * Produces values of type {@link ArrayList}. 32 | */ 33 | public class ArrayListGenerator extends ListGenerator { 34 | public ArrayListGenerator() { 35 | super(ArrayList.class); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /generators/src/main/java/com/pholser/junit/quickcheck/generator/java/util/HashMapGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.util; 27 | 28 | import java.util.HashMap; 29 | 30 | /** 31 | * Produces values of type {@link HashMap}. 32 | */ 33 | public class HashMapGenerator extends MapGenerator { 34 | public HashMapGenerator() { 35 | super(HashMap.class); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /generators/src/main/java/com/pholser/junit/quickcheck/generator/java/util/HashSetGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.util; 27 | 28 | import java.util.HashSet; 29 | 30 | /** 31 | * Produces values of type {@link HashSet}. 32 | */ 33 | public class HashSetGenerator extends SetGenerator { 34 | public HashSetGenerator() { 35 | super(HashSet.class); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /generators/src/main/java/com/pholser/junit/quickcheck/generator/java/util/HashtableGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.util; 27 | 28 | import java.util.Hashtable; 29 | 30 | /** 31 | * Produces values of type {@link Hashtable}. 32 | */ 33 | public class HashtableGenerator extends MapGenerator { 34 | public HashtableGenerator() { 35 | super(Hashtable.class); 36 | } 37 | 38 | @Override protected boolean okToAdd(Object key, Object value) { 39 | return key != null && value != null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /generators/src/main/java/com/pholser/junit/quickcheck/generator/java/util/LinkedHashMapGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.util; 27 | 28 | import java.util.LinkedHashMap; 29 | 30 | /** 31 | * Produces values of type {@link LinkedHashMap}. 32 | */ 33 | public class LinkedHashMapGenerator extends MapGenerator { 34 | public LinkedHashMapGenerator() { 35 | super(LinkedHashMap.class); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /generators/src/main/java/com/pholser/junit/quickcheck/generator/java/util/LinkedHashSetGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.util; 27 | 28 | import java.util.LinkedHashSet; 29 | 30 | /** 31 | * Produces values of type {@link LinkedHashSet}. 32 | */ 33 | public class LinkedHashSetGenerator extends SetGenerator { 34 | public LinkedHashSetGenerator() { 35 | super(LinkedHashSet.class); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /generators/src/main/java/com/pholser/junit/quickcheck/generator/java/util/LinkedListGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.util; 27 | 28 | import java.util.LinkedList; 29 | 30 | /** 31 | * Produces values of type {@link LinkedList}. 32 | */ 33 | public class LinkedListGenerator extends ListGenerator { 34 | public LinkedListGenerator() { 35 | super(LinkedList.class); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /generators/src/main/java/com/pholser/junit/quickcheck/generator/java/util/ListGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.util; 27 | 28 | import java.util.List; 29 | 30 | /** 31 | * Base class for generators of {@link java.util.List}s. 32 | * 33 | * @param the type of list generated 34 | */ 35 | public abstract class ListGenerator 36 | extends CollectionGenerator { 37 | 38 | protected ListGenerator(Class type) { 39 | super(type); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /generators/src/main/java/com/pholser/junit/quickcheck/generator/java/util/SetGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.util; 27 | 28 | import com.pholser.junit.quickcheck.generator.Size; 29 | import java.util.Set; 30 | 31 | /** 32 | * Base class for generators of {@link Set}s. 33 | * 34 | * @param the type of set generated 35 | */ 36 | public abstract class SetGenerator 37 | extends CollectionGenerator { 38 | 39 | protected SetGenerator(Class type) { 40 | super(type); 41 | } 42 | 43 | @Override public void configure(Size size) { 44 | super.configure(size); 45 | 46 | setDistinct(true); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /generators/src/main/java/com/pholser/junit/quickcheck/generator/java/util/StackGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.util; 27 | 28 | import java.util.Stack; 29 | 30 | /** 31 | * Produces values of type {@link Stack}. 32 | */ 33 | public class StackGenerator extends ListGenerator { 34 | public StackGenerator() { 35 | super(Stack.class); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /generators/src/main/java/com/pholser/junit/quickcheck/generator/java/util/VectorGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.util; 27 | 28 | import java.util.Vector; 29 | 30 | /** 31 | * Produces values of type {@link Vector}. 32 | */ 33 | public class VectorGenerator extends ListGenerator { 34 | public VectorGenerator() { 35 | super(Vector.class); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/ComparableWithConsistentEqualsContract.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck; 27 | 28 | import static org.hamcrest.Matchers.*; 29 | import static org.junit.Assert.*; 30 | import static org.junit.Assume.*; 31 | 32 | public interface 33 | ComparableWithConsistentEqualsContract> { 34 | @Property default void equalsConsistency(T thing) { 35 | T other = thingComparableTo(thing); 36 | assumeThat(thing.compareTo(other), equalTo(0)); 37 | 38 | assertEquals(thing, other); 39 | } 40 | 41 | T thingComparableTo(T thing); 42 | } 43 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/ComparatorContract.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck; 27 | 28 | import java.util.Comparator; 29 | 30 | import static java.lang.Math.*; 31 | import static org.junit.Assert.*; 32 | 33 | public interface ComparatorContract { 34 | Comparator subject(); 35 | 36 | @Property default void symmetry(T x, T y) { 37 | Comparator subject = subject(); 38 | 39 | assertEquals( 40 | signum(subject.compare(x, y)), 41 | -signum(subject.compare(y, x)), 42 | 0F); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/DayOfWeekPropertyParameterTypesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck; 27 | 28 | import java.time.DayOfWeek; 29 | 30 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 31 | import org.junit.Test; 32 | import org.junit.runner.RunWith; 33 | 34 | import static org.hamcrest.MatcherAssert.assertThat; 35 | import static org.junit.experimental.results.PrintableResult.*; 36 | import static org.junit.experimental.results.ResultMatchers.*; 37 | 38 | public class DayOfWeekPropertyParameterTypesTest { 39 | @Test public void dayOfWeek() { 40 | assertThat(testResult(DaysOfWeek.class), isSuccessful()); 41 | } 42 | 43 | @RunWith(JUnitQuickcheck.class) 44 | public static class DaysOfWeek { 45 | @Property public void shouldHold(DayOfWeek d) { 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/DistinctSetPropertyParameterTypesTest.java: -------------------------------------------------------------------------------- 1 | package com.pholser.junit.quickcheck; 2 | 3 | import com.pholser.junit.quickcheck.generator.Distinct; 4 | import com.pholser.junit.quickcheck.generator.InRange; 5 | import com.pholser.junit.quickcheck.generator.Size; 6 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import java.util.Set; 11 | 12 | import static org.hamcrest.MatcherAssert.assertThat; 13 | import static org.hamcrest.Matchers.*; 14 | import static org.junit.Assert.*; 15 | import static org.junit.experimental.results.PrintableResult.*; 16 | import static org.junit.experimental.results.ResultMatchers.*; 17 | 18 | public class DistinctSetPropertyParameterTypesTest { 19 | @Test public void distinctSets() { 20 | assertThat(testResult(DistinctSets.class), isSuccessful()); 21 | } 22 | 23 | @RunWith(JUnitQuickcheck.class) 24 | public static class DistinctSets { 25 | @Property public void shouldHold( 26 | @Size(min = 4, max = 5) 27 | @Distinct 28 | Set<@InRange(minInt = 1, maxInt = 5) Integer> items) { 29 | 30 | assertThat( 31 | items.size(), 32 | allOf(greaterThanOrEqualTo(4), lessThanOrEqualTo(5))); 33 | } 34 | } 35 | 36 | @Test public void shrinkingDistinctSets() { 37 | assertThat(testResult(ShrinkingDistinctSets.class), failureCountIs(1)); 38 | assertThat( 39 | ShrinkingDistinctSets.failed.size(), 40 | allOf(greaterThanOrEqualTo(4), lessThanOrEqualTo(5))); 41 | } 42 | 43 | @RunWith(JUnitQuickcheck.class) 44 | public static class ShrinkingDistinctSets { 45 | static Set failed; 46 | 47 | @Property public void shouldHold( 48 | @Size(min = 4, max = 5) 49 | @Distinct 50 | Set<@InRange(minInt = 1, maxInt = 5) Integer> items) { 51 | 52 | failed = items; 53 | 54 | fail(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/IntegerComparableTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck; 27 | 28 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 29 | import org.junit.runner.RunWith; 30 | 31 | @RunWith(JUnitQuickcheck.class) 32 | public class IntegerComparableTest 33 | implements ComparableWithConsistentEqualsContract { 34 | 35 | @Override public Integer thingComparableTo(Integer thing) { 36 | return thing; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/IntegerComparatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck; 27 | 28 | import java.util.Comparator; 29 | 30 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 31 | import org.junit.runner.RunWith; 32 | 33 | @RunWith(JUnitQuickcheck.class) 34 | public class IntegerComparatorTest implements ComparatorContract { 35 | @Override public Comparator subject() { 36 | return Integer::compare; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/MonthPropertyParameterTypesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck; 27 | 28 | import java.time.Month; 29 | 30 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 31 | import org.junit.Test; 32 | import org.junit.runner.RunWith; 33 | 34 | import static org.hamcrest.MatcherAssert.assertThat; 35 | import static org.junit.experimental.results.PrintableResult.*; 36 | import static org.junit.experimental.results.ResultMatchers.*; 37 | 38 | public class MonthPropertyParameterTypesTest { 39 | @Test public void month() { 40 | assertThat(testResult(Months.class), isSuccessful()); 41 | } 42 | 43 | @RunWith(JUnitQuickcheck.class) 44 | public static class Months { 45 | @Property public void shouldHold(Month m) { 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/NumberPropertyParameterTypesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck; 27 | 28 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 29 | import org.junit.Test; 30 | import org.junit.runner.RunWith; 31 | 32 | import static org.hamcrest.MatcherAssert.assertThat; 33 | import static org.junit.experimental.results.PrintableResult.*; 34 | import static org.junit.experimental.results.ResultMatchers.*; 35 | 36 | public class NumberPropertyParameterTypesTest { 37 | @Test public void numbers() { 38 | assertThat(testResult(NumberSuperclass.class), isSuccessful()); 39 | } 40 | 41 | @RunWith(JUnitQuickcheck.class) 42 | public static class NumberSuperclass { 43 | @Property public void shouldHold(Number n) { 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/generator/BasicGeneratorPropertyParameterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator; 27 | 28 | import com.pholser.junit.quickcheck.internal.generator.CorePropertyParameterTest; 29 | import com.pholser.junit.quickcheck.internal.generator.ServiceLoaderGeneratorSource; 30 | 31 | public abstract class BasicGeneratorPropertyParameterTest 32 | extends CorePropertyParameterTest { 33 | 34 | @Override protected Iterable> generatorSource() { 35 | return new ServiceLoaderGeneratorSource(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/generator/VoidGeneratorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator; 27 | 28 | import org.junit.Test; 29 | 30 | import static org.junit.Assert.*; 31 | 32 | public class VoidGeneratorTest { 33 | @Test public void canOnlyGenerateNull() { 34 | VoidGenerator generator = new VoidGenerator(); 35 | 36 | Void value = generator.generate(null, null); 37 | 38 | assertNull(value); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/generator/java/util/MessageDigestsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.util; 27 | 28 | import java.security.NoSuchAlgorithmException; 29 | 30 | import org.junit.Test; 31 | 32 | import static com.pholser.junit.quickcheck.generator.java.util.RFC4122.*; 33 | import static org.hamcrest.MatcherAssert.assertThat; 34 | import static org.hamcrest.Matchers.*; 35 | import static org.junit.Assert.*; 36 | 37 | public class MessageDigestsTest { 38 | @Test public void treatsNoSuchAlgorithmAsIllegalState() { 39 | IllegalStateException ex = 40 | assertThrows( 41 | IllegalStateException.class, 42 | () -> MessageDigests.get("foobar")); 43 | assertThat(ex.getCause(), instanceOf(NoSuchAlgorithmException.class)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/generator/java/util/MessageDigestsUtilityClassTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.util; 27 | 28 | import com.pholser.junit.quickcheck.UtilityClassesUninstantiabilityHarness; 29 | 30 | import static com.pholser.junit.quickcheck.generator.java.util.RFC4122.*; 31 | 32 | public class MessageDigestsUtilityClassTest 33 | extends UtilityClassesUninstantiabilityHarness { 34 | 35 | public MessageDigestsUtilityClassTest() { 36 | super(MessageDigests.class); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/generator/java/util/RFC4122UtilityClassTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.generator.java.util; 27 | 28 | import com.pholser.junit.quickcheck.UtilityClassesUninstantiabilityHarness; 29 | 30 | public class RFC4122UtilityClassTest 31 | extends UtilityClassesUninstantiabilityHarness { 32 | 33 | public RFC4122UtilityClassTest() { 34 | super(RFC4122.class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/issue275/Functor.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.issue275; 27 | 28 | import java.util.function.Function; 29 | 30 | public interface Functor { 31 | __ map(Function fn, __ nestedA); 32 | } 33 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/issue275/FunctorContract.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.issue275; 27 | 28 | import static org.junit.Assert.assertEquals; 29 | 30 | import com.pholser.junit.quickcheck.Property; 31 | import java.util.function.Function; 32 | 33 | public interface FunctorContract { 34 | Functor subject(); 35 | 36 | @Property default void mapIdentity(__ a) { 37 | Functor functor = subject(); 38 | 39 | __ mappedA = functor.map(Function.identity(), a); 40 | 41 | assertEquals(a, mappedA); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/issue275/List.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.issue275; 27 | 28 | public abstract class List implements __ { 29 | public interface mu { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/issue275/ListFunctor.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.issue275; 27 | 28 | import java.util.function.Function; 29 | 30 | public class ListFunctor implements Functor { 31 | @Override 32 | @SuppressWarnings("unchecked") 33 | public __ map( 34 | Function fn, 35 | __ nestedA) { 36 | 37 | return (__) nestedA; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/issue275/ListFunctorProperties.java: -------------------------------------------------------------------------------- 1 | package com.pholser.junit.quickcheck.issue275; 2 | 3 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 4 | import org.junit.runner.RunWith; 5 | 6 | @RunWith(JUnitQuickcheck.class) 7 | public class ListFunctorProperties implements FunctorContract { 8 | @Override public ListFunctor subject() { 9 | return new ListFunctor(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/issue275/ListGen.java: -------------------------------------------------------------------------------- 1 | package com.pholser.junit.quickcheck.issue275; 2 | 3 | import com.pholser.junit.quickcheck.generator.ComponentizedGenerator; 4 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 5 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 6 | 7 | public class ListGen extends ComponentizedGenerator { 8 | public ListGen() { 9 | super(List.class); 10 | } 11 | 12 | @Override public int numberOfNeededComponents() { 13 | return 1; 14 | } 15 | 16 | @Override public List generate( 17 | SourceOfRandomness random, 18 | GenerationStatus status) { 19 | 20 | return new List() {}; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/issue275/__.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.issue275; 27 | 28 | public interface __ { 29 | } 30 | -------------------------------------------------------------------------------- /generators/src/test/java/com/pholser/junit/quickcheck/issue275/__Gen.java: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.pholser.junit.quickcheck.issue275; 27 | 28 | import com.pholser.junit.quickcheck.generator.ComponentizedGenerator; 29 | import com.pholser.junit.quickcheck.generator.GenerationStatus; 30 | import com.pholser.junit.quickcheck.random.SourceOfRandomness; 31 | 32 | public class __Gen extends ComponentizedGenerator<__> { 33 | public __Gen() { 34 | super(__.class); 35 | } 36 | 37 | @Override public int numberOfNeededComponents() { 38 | return 2; 39 | } 40 | 41 | @Override public __ generate( 42 | SourceOfRandomness r, 43 | GenerationStatus status) { 44 | 45 | return null; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /infinitest.filters: -------------------------------------------------------------------------------- 1 | .*\$.* 2 | -------------------------------------------------------------------------------- /src/site/markdown/background/migrating.md: -------------------------------------------------------------------------------- 1 | # Migrating from theories to properties 2 | 3 | - Instead of the `Theories` runner, with `@Theory` methods with parameters 4 | marked `@ForAll`, we use the `JUnitQuickcheck` runner, with `@Property` 5 | methods. 6 | - There are `Property.trials()` executions of the property, instead of a 7 | combinatorial number of executions of a `Theory` 8 | - Use the `@When` annotation to control seed and parameter value generation 9 | if desired 10 | - You can still mark property parameters with configuration annotations, 11 | just like you did with `@ForAll` theory parameters 12 | - Your generators should work the same as before 13 | -------------------------------------------------------------------------------- /src/site/markdown/background/similar-projects.md: -------------------------------------------------------------------------------- 1 | # Similar projects 2 | 3 | * [jqwik](https://jqwik.net) - Built on JUnit 5. 4 | * [QuickTheories](https://github.com/NCR-CoDE/QuickTheories) 5 | * [QuickCheck](http://java.net/projects/quickcheck/pages/Home). This appears 6 | to be test framework-agnostic, focusing instead on generators of random 7 | values. 8 | * [ScalaCheck](http://code.google.com/p/scalacheck/). For testing 9 | Java or Scala code using Scala. 10 | * [fj.test package of FunctionalJava (formerly Reductio)] 11 | (http://functionaljava.org/) 12 | * [JCheck](http://www.jcheck.org/) 13 | -------------------------------------------------------------------------------- /src/site/markdown/discuss.md: -------------------------------------------------------------------------------- 1 | # Discuss 2 | 3 | There is [a Google group for junit-quickcheck](https://groups.google.com/g/junit-quickcheck). 4 | -------------------------------------------------------------------------------- /src/site/markdown/download.md: -------------------------------------------------------------------------------- 1 | # Download 2 | 3 | The JAR file for the module `junit-quickcheck-core` contains junit-quickcheck's 4 | machinery. You will want to start out also with the JAR file for 5 | the module `junit-quickcheck-generators`, which consists of generators for 6 | basic Java types, such as primitives, arrays, and collections. 7 | 8 | There is also a module `junit-quickcheck-guava`, containing generators for 9 | [Guava](https://github.com/google/guava) types. 10 | 11 | Releases live in the central Maven repository. Here are the coordinates 12 | for the junit-quickcheck JAR files: 13 | 14 | - [junit-quickcheck-core](junit-quickcheck-core/dependency-info.html) 15 | - [junit-quickcheck-generators](junit-quickcheck-generators/dependency-info.html) 16 | - [junit-quickcheck-guava](junit-quickcheck-guava/dependency-info.html) 17 | -------------------------------------------------------------------------------- /src/site/markdown/index.md: -------------------------------------------------------------------------------- 1 | # junit-quickcheck: Property-based testing, JUnit-style 2 | 3 | junit-quickcheck is a library that supports writing and running property-based 4 | tests in [JUnit](http://junit.org), inspired by 5 | [QuickCheck](http://www.cse.chalmers.se/~rjmh/QuickCheck/manual.html) for 6 | [Haskell](http://haskell.org). 7 | 8 | junit-quickcheck is source/target-compatible with JDK 8. 9 | 10 | 11 | ## Basic example 12 | 13 | ```java 14 | import com.pholser.junit.quickcheck.Property; 15 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 16 | import org.junit.runner.RunWith; 17 | 18 | import static org.junit.Assert.*; 19 | 20 | @RunWith(JUnitQuickcheck.class) 21 | public class StringProperties { 22 | @Property public void concatenationLength(String s1, String s2) { 23 | assertEquals(s1.length() + s2.length(), (s1 + s2).length()); 24 | } 25 | } 26 | ``` -------------------------------------------------------------------------------- /src/site/markdown/javadoc.md: -------------------------------------------------------------------------------- 1 | # Javadoc 2 | 3 | - [junit-quickcheck-core](junit-quickcheck-core/apidocs/index.html) 4 | - [junit-quickcheck-generators](junit-quickcheck-generators/apidocs/index.html) 5 | - [junit-quickcheck-guava](junit-quickcheck-guava/apidocs/index.html) 6 | -------------------------------------------------------------------------------- /src/site/markdown/license.md: -------------------------------------------------------------------------------- 1 | junit-quickcheck is written by Paul Holser, and is distributed under 2 | [The MIT License](https://opensource.org/licenses/MIT). 3 | 4 | The MIT License 5 | 6 | Copyright (c) 2010-2021 Paul R. Holser, Jr. 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining 9 | a copy of this software and associated documentation files (the 10 | "Software"), to deal in the Software without restriction, including 11 | without limitation the rights to use, copy, modify, merge, publish, 12 | distribute, sublicense, and/or sell copies of the Software, and to 13 | permit persons to whom the Software is furnished to do so, subject to 14 | the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be 17 | included in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /src/site/markdown/reports/reports-core.md: -------------------------------------------------------------------------------- 1 | # Reports: junit-quickcheck-core 2 | 3 | - [Dependencies](../junit-quickcheck-core/dependencies.html) 4 | - [Jacoco](../junit-quickcheck-core/jacoco/index.html) 5 | - [PMD](../junit-quickcheck-core/pmd.html) 6 | -------------------------------------------------------------------------------- /src/site/markdown/reports/reports-generators.md: -------------------------------------------------------------------------------- 1 | # Reports: junit-quickcheck-generators 2 | 3 | - [Dependencies](../junit-quickcheck-generators/dependencies.html) 4 | - [Jacoco](../junit-quickcheck-generators/jacoco/index.html) 5 | - [PMD](../junit-quickcheck-generators/pmd.html) 6 | -------------------------------------------------------------------------------- /src/site/markdown/reports/reports-guava.md: -------------------------------------------------------------------------------- 1 | # Reports: junit-quickcheck-guava 2 | 3 | - [Dependencies](../junit-quickcheck-guava/dependencies.html) 4 | - [Jacoco](../junit-quickcheck-guava/jacoco/index.html) 5 | - [PMD](../junit-quickcheck-guava/pmd.html) 6 | -------------------------------------------------------------------------------- /src/site/markdown/usage/basic-types.md: -------------------------------------------------------------------------------- 1 | # Supported types 2 | 3 | "Out of the box" (core + generators), junit-quickcheck recognizes property 4 | parameters of the following types: 5 | 6 | * all Java primitives and primitive wrappers 7 | * `java.math.Big(Decimal|Integer)` 8 | * `java.util.Date` 9 | * any `enum` 10 | * `String` 11 | * "functional interfaces" (interfaces with a single abstract method 12 | that does not override a method from `java.lang.Object`) 13 | * `java.util.Optional` of supported types 14 | * `java.util.ArrayList` and `java.util.LinkedList` of supported types 15 | * `java.util.HashSet` and `java.util.LinkedHashSet` of supported types 16 | * `java.util.HashMap` and `java.util.LinkedHashMap` of supported types 17 | * arrays of supported types 18 | * "marker" interfaces (interfaces with no methods that do not override 19 | a method from `java.lang.Object` or are not `default`) 20 | * others... 21 | 22 | When many generators can satisfy a given property parameter based on its type 23 | (for example, `java.io.Serializable`), on a given generation junit-quickcheck 24 | will choose one of the multiple generators at random with (roughly) equal 25 | probability. 26 | -------------------------------------------------------------------------------- /src/site/markdown/usage/contract-tests.md: -------------------------------------------------------------------------------- 1 | # Contract Tests 2 | 3 | Beginning with version 0.8, junit-quickcheck supports the usual JUnit 4 | machinery on interface default methods (`@Property`, `@Before`, `@After`, 5 | `@Rule`), interface static methods (`@BeforeClass`, `@AfterClass`, 6 | `@ClassRule`), and interface fields (`@ClassRule`). 7 | 8 | As with JUnit 5, this allows for tests for interface contracts: 9 | 10 | ```java 11 | public interface ComparatorContract { 12 | Comparator subject(); 13 | 14 | @Property default void symmetry(T x, T y) { 15 | Comparator subject = subject(); 16 | 17 | assertEquals( 18 | signum(subject.compare(x, y)), 19 | -signum(subject.compare(y, x)), 20 | 0F); 21 | } 22 | } 23 | 24 | @RunWith(JUnitQuickcheck.class) 25 | public class StringCaseInsensitiveProperties 26 | implements ComparatorContract { 27 | 28 | @Override public Comparator subject() { 29 | return String::compareToIgnoreCase; 30 | } 31 | } 32 | 33 | public interface ComparableVersusEqualsContract> { 34 | T thingComparableTo(T thing); 35 | 36 | @Property default void equalsConsistency(T thing) { 37 | T other = thingComparableTo(thing); 38 | assumeThat(thing.compareTo(other), equalTo(0)); 39 | 40 | assertEquals(thing, other); 41 | } 42 | } 43 | 44 | @RunWith(JUnitQuickcheck.class) 45 | public class StringProperties 46 | implements ComparableVersusEqualsContract { 47 | 48 | @Override public String thingComparableTo(String s) { 49 | return new String(s.toCharArray()); 50 | } 51 | } 52 | ``` 53 | -------------------------------------------------------------------------------- /src/site/markdown/usage/getting-started.md: -------------------------------------------------------------------------------- 1 | # Getting started with junit-quickcheck 2 | 3 | - Create a class to host the properties you want to verify about a part of 4 | your system. Mark it with the annotation `@RunWith(JUnitQuickcheck.class)`. 5 | - Add `public` methods with a return type of `void` on your class, to 6 | represent the individual properties. Mark each of them with the annotation 7 | `@Property`. 8 | - Run your class using JUnit. Each of your properties will be verified against 9 | several randomly generated values for each of the parameters on the properties' 10 | methods. 11 | 12 | ```java 13 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 14 | import com.pholser.junit.quickcheck.Property; 15 | import java.nio.charset.StandardCharsets; 16 | 17 | class Crypto { 18 | byte[] encrypt(byte[] plaintext, Key key) { 19 | // ... 20 | } 21 | 22 | byte[] decrypt(byte[] ciphertext, Key key) { 23 | // ... 24 | } 25 | } 26 | 27 | @RunWith(JUnitQuickcheck.class) 28 | public class SymmetricKeyCryptographyProperties { 29 | @Property public void decryptReversesEncrypt(String plaintext, Key key) 30 | throws Exception { 31 | 32 | Crypto crypto = new Crypto(); 33 | 34 | byte[] ciphertext = 35 | crypto.encrypt( 36 | plaintext.getBytes(StandardCharsets.US_ASCII), 37 | key); 38 | 39 | assertEquals( 40 | plaintext, 41 | new String(crypto.decrypt(ciphertext, key))); 42 | } 43 | } 44 | ``` 45 | 46 | *Note*: The example above presumes the existence and availability of generators 47 | for classes `String` and `Key`. Find out more about generators in 48 | [Basic Types](basic-types.html) and 49 | [Generating Values of Other Types](other-types.html). 50 | 51 | junit-quickcheck honors the usual JUnit machinery: `@Before`, `@After`, 52 | `@Rule`, `@BeforeClass`, `@AfterClass`, `@ClassRule`. It will also run 53 | zero-arg `public` `void` methods annotated with `@Test`. 54 | -------------------------------------------------------------------------------- /src/site/markdown/usage/null.md: -------------------------------------------------------------------------------- 1 | # Generating null values 2 | 3 | By default, generated values are never `null`. One possible way to generate an optional 4 | value of type `T` in Java is to declare a parameter of type `Optional`. 5 | 6 | However, in some cases it preferable to generate values that can include 7 | `null`. For example, Kotlin's type system explicitly manages nullable types and 8 | therefore Kotlin programs use nullable types like `T?` instead of `Optional` to 9 | indicate that a value may be absent. 10 | 11 | In order to generate `null` values, attach the JSR 303 12 | `javax.annotation.Nullable` annotation to a parameter of any supported type: 13 | 14 | ```java 15 | @RunWith(JUnitQuickcheck.class) 16 | public class NullableParameterProperties { 17 | @Property public void validPhoneNumber(@Nullable String areaCode, String lineNumber) { 18 | // ... 19 | } 20 | } 21 | ``` 22 | 23 | Alternatively, use the annotation `@NullAllowed` introduced by junit-quickcheck, 24 | which makes it possible to indicate the probability of generating a `null` value: 25 | 26 | ```java 27 | @RunWith(JUnitQuickcheck.class) 28 | public class NullableParameterProperties { 29 | @Property public void validPhoneNumber(@NullAllowed(probability = 0.8f) String areaCode, String lineNumber) { 30 | // ... 31 | } 32 | } 33 | ``` 34 | -------------------------------------------------------------------------------- /src/site/markdown/usage/seed.md: -------------------------------------------------------------------------------- 1 | # Seed 2 | 3 | For each property parameter, junit-quickcheck uses a unique value as a seed 4 | for the source of randomness used to generate the parameter's values. To fix 5 | the seed value for a property parameter, use the `seed` attribute of the 6 | `@When` annotation. 7 | 8 | ```java 9 | @RunWith(JUnitQuickcheck.class) 10 | public class SameValues { 11 | @Property public void holds(@When(seed = -1L) int i) { 12 | // ... 13 | } 14 | } 15 | ``` 16 | 17 | You may want to fix the seed when a property fails, so that you can test the 18 | property over and over again with the same set of generated values that caused 19 | the failure. 20 | 21 | junit-quickcheck reports the seed used for a given property parameter in the 22 | message of the `AssertionError` raised when a property fails. 23 | 24 | java.lang.AssertionError: Property named 'myProperty' failed: 25 | With arguments: [10] 26 | Original failure message: 27 | Expected: a value less than <1> 28 | but: <10> was greater than <1> 29 | First arguments found to also provoke a failure: [753701363] 30 | Seeds for reproduction: [-6700838609453830748] 31 | ... 32 | --------------------------------------------------------------------------------