string-printable

Only produce input strings that contain printable characters.

Description

If the string-printable parameter is not set, Diffblue Cover doesn’t limit itself to ASCII characters when generating inputs. Generated strings could contain any kind of unicode characters. Since many of them are not even printable, the string-printable option restricts the generated characters to a subset of unicode that is printable. Not all printable characters are included, but the subset should be sufficient for general usage.

Usage

This option is usually set by default on Diffblue Cover, but to catch some specific cases, it might be necessary to disable it.

Most notably, the newline character \n is not considered as “printable”. So to be able to cover the return 1 line in the code below, you must turn off the string-printable option:

public static int func(String s) {
  if (s.charAt(0) == '\n') {
    return 1;
  }
  return 0;
}
phases:
-
  cbmcArguments:
    string-printable: false

results matching ""

    No results matching ""