Skip to content

BigInteger Shrink appears to be broken #276

@jbgi

Description

@jbgi

Current implementation:

public static final Shrink<BigInteger> shrinkBigInteger =

as per original comment by @bakeemawaytoys in #274:

There is a call to System.arraycopy in the implementation that throws an exception because the source array is byte[] and the destination array is Byte[]. Once fixed, BigInteger shrink and doesn't appear to shrink correctly.

For example

Shrink.shrinkLong.shrink(1000L).take(100).toList();
//Produces List(0,0,500,750,875,938,969,985,993,997,999)

versus

Shrink.shrinkBigInteger.shrink(BigInteger.valueOf(1000L)).take(100).toList();
//Produces List(0,0,0,512,0,0,0,512,2,2,2,514)

Modifying Shrink.shrinkBigInteger to use the same logic as Shrink.shrinkLong appears to work correctly.

@tonymorris / @mperry / @mrbackend: Would you confirm this is a bug? Is the suggested fix correct?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions