org.eigenbase.util
Class TestUtil

java.lang.Object
  extended by org.eigenbase.util.TestUtil

public abstract class TestUtil
extends Object

Static utilities for JUnit tests.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/util/TestUtil.java#20 $
Author:
John V. Sichi

Field Summary
private static String lineBreak
           
private static String lineBreak2
           
private static String lineBreak3
           
private static Pattern LineBreakPattern
           
static String NL
          System-dependent newline character.
private static Pattern TabPattern
           
 
Constructor Summary
TestUtil()
           
 
Method Summary
static void assertEqualsVerbose(String expected, String actual)
           
static String fold(String string)
          Converts a string containing newlines (\n) into a string containing os-dependent line endings.
static String fold(String[] strings)
          Combines an array of strings, each representing a line, into a single string containing line separators.
static String quoteForJava(String s)
          Converts a string (which may contain quotes and newlines) into a java literal.
static String quotePattern(String s)
          Quotes a pattern.
static String toJavaString(String s)
          Converts a string (which may contain quotes and newlines) into a java literal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LineBreakPattern

private static final Pattern LineBreakPattern

TabPattern

private static final Pattern TabPattern

NL

public static final String NL
System-dependent newline character.

Do not use '\n' in strings which are samples for test results. PrintWriter.println() produces '\n' on Unix and '\r\n' on Windows, but '\n' is always '\n', so your tests will fail on Windows.


lineBreak

private static final String lineBreak

lineBreak2

private static final String lineBreak2

lineBreak3

private static final String lineBreak3
Constructor Detail

TestUtil

public TestUtil()
Method Detail

assertEqualsVerbose

public static void assertEqualsVerbose(String expected,
                                       String actual)

quoteForJava

public static String quoteForJava(String s)
Converts a string (which may contain quotes and newlines) into a java literal.

For example,

string with "quotes" split
 across lines
becomes
"string with \"quotes\" split" + NL +
  "across lines"


toJavaString

public static String toJavaString(String s)
Converts a string (which may contain quotes and newlines) into a java literal.

For example,

string with "quotes" split
 across lines
becomes
TestUtil.fold(
  "string with \"quotes\" split\n",
  + "across lines")


fold

public static String fold(String[] strings)
Combines an array of strings, each representing a line, into a single string containing line separators.


fold

public static String fold(String string)
Converts a string containing newlines (\n) into a string containing os-dependent line endings.


quotePattern

public static String quotePattern(String s)
Quotes a pattern.