public class Value
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.String,java.lang.Boolean> |
escapedStringLengthOkCached
Used to increase performance of stringLengthOk method.
|
private static java.util.regex.Pattern |
OBJECT_TOSTRING_PATTERN
The pattern for strings that look like the output of a call to
Object.toString() . |
Constructor and Description |
---|
Value() |
Modifier and Type | Method and Description |
---|---|
static boolean |
arrayLengthOk(java.lang.Object a)
Returns true if the given array is shorter than the --string-maxlen=N parameter.
|
static boolean |
escapedStringLengthOk(java.lang.String s)
Returns true if the given string, when quoted for inclusion in a Java program, is no longer
than the --string-maxlen=N parameter.
|
static boolean |
isUnassertableString(java.lang.Object o)
Returns true if the value is a string that may NOT be asserted over, because it is (likely to
be) nondeterministic or is too long.
|
static boolean |
lastValueSizeOk(ExecutableSequence eseq)
Returns true if the value returned by the last statement is not too large.
|
static boolean |
looksLikeObjectToString(java.lang.String s)
Returns true if the given string looks like it came from a call of Object.toString(); in other
words, it contains
"@<em>hex</em>" . |
static boolean |
stringLengthOk(java.lang.String s)
Returns true if the given string is no longer than the --string-maxlen=N parameter.
|
static java.lang.String |
toCodeString(java.lang.Object value)
Given a primitive, boxed primitive, String, Enum, or Class, or the value
null , returns
a String that can be used in Java source to represent it. |
static boolean |
valueSizeOk(java.lang.Object v)
Returns true if the given value is not longer than the --string-maxlen=N parameter.
|
private static final java.util.regex.Pattern OBJECT_TOSTRING_PATTERN
Object.toString()
.
This regex is more efficient than a more complete one that matches against "<em>classname</em>@<em>hex</em>"
. This regex almost always works and is a faster check.
private static java.util.Map<java.lang.String,java.lang.Boolean> escapedStringLengthOkCached
public static java.lang.String toCodeString(java.lang.Object value)
null
, returns
a String that can be used in Java source to represent it.value
- the value to create a String representation for. The value's type must be a
primitive type, a String, Enum, Class, or null.public static boolean isUnassertableString(java.lang.Object o)
o
- the value to test, which may or may not be a stringpublic static boolean looksLikeObjectToString(java.lang.String s)
"@<em>hex</em>"
. Such strings are rarely useful in generation
because they contain non-reproducible hash strings.s
- the stringpublic static boolean stringLengthOk(java.lang.String s)
s
- the stringGenInputsAbstract.string_maxlen
public static boolean escapedStringLengthOk(java.lang.String s)
If Randoop generates tests using strings that are too long, this can result in non-compilable tests due to the JVM's limit on the length of a string.
s
- the stringGenInputsAbstract.string_maxlen
public static boolean arrayLengthOk(java.lang.Object a)
a
- the stringpublic static boolean valueSizeOk(java.lang.Object v)
v
- a valuepublic static boolean lastValueSizeOk(ExecutableSequence eseq)
eseq
- an executable sequence that has been executed