Skip to content

Default Arbitrary instances for e.g. long return very small values? #9

Open
@BardurArantsson

Description

@BardurArantsson

It seems that the default Arbitrary instances for integral types return very small values. Here's the small prop I've been using to test:

template <typename T>
struct ReproducerProp: cppqc::Property<T>
{
	bool check(const T &expected) const override
	{
		std::cout << expected << std::endl;
		if (expected > 255) {
			return false;
		}
		if (expected < -255) {
			return false;
		}
		return true;
	}
};

I would certainly have expected this to fail at least some of the time, but I've done ~20 runs (each with 100 tests) and it's not failed so far.

It seems very odd that it's not using the full range of the type by default.

(Generally speaking it might also be a good idea to make sure to always include the min/max/0 value for any given type in the set of integers tested, by that's another issue.)

EDIT: Oh, the runner code is

	quickCheckOutput(ReproducerProp<long>());

Tested current master.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions