本文整理匯總了Java中org.apache.commons.lang3.StringUtils.difference方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.difference方法的具體用法?Java StringUtils.difference怎麽用?Java StringUtils.difference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.difference方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testBinaryCompatibility
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
public void testBinaryCompatibility()
{
try
{
String golden = System.getProperty("trinidad.clirr.golden");
String clirrRunResult = System.getProperty("trinidad.clirr.compare");
String goldenFileContent = FileUtils.readFileToString(new File(golden));
String clirrRunFileContent = FileUtils.readFileToString(new File(clirrRunResult));
String binaryIssue = StringUtils.difference(goldenFileContent, clirrRunFileContent);
if (binaryIssue.length() > 0)
{
fail("Check your binary compatibility! - See output in file: " + clirrRunResult);
}
}
catch (IOException e)
{
e.printStackTrace();
fail(e.getMessage());
}
}
示例2: _throwAssertionFailure
import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private void _throwAssertionFailure(String golden, String results, boolean forceGolden)
{
if (golden == null)
{
// Don't report "no golden file" as an error when
// forceGolden is on; but do report diffs as errors
if (!forceGolden)
{
throw new AssertionFailedError("No golden file for test " +
_scriptName);
}
} else
{
int index = StringUtils.indexOfDifference(golden, results);
String difference = StringUtils.difference(golden, results);
int diffLength = difference.length();
if (diffLength > 50)
difference = StringUtils.abbreviate(difference, 50);
/*
int resultsLength = results.length();
int goldenLength = golden.length();
if (resultsLength != goldenLength)
{
if (resultsLength < goldenLength)
{
throw new AssertionFailedError("golden file longer by:" + (goldenLength - resultsLength) + " char='" + ((int)golden.charAt(index)) + "'");
}
else
{
throw new AssertionFailedError("results file longer by:" + (resultsLength - goldenLength));
}
}
if (index >= resultsLength)
throw new AssertionFailedError("golden file longer by:" + (goldenLength - resultsLength));
if (results.length() < 50)
{
throw new AssertionFailedError(
"Golden file for test "+ _scriptName + " did not match; " +
"first difference at " + index + ", difference of length " +
diffLength + ", \"" + difference + "\"" + "\ngolden:\n" + golden + "\nnew:\n" + results + "\ndiffChars g='" + golden.charAt(index) + "' r='" + results.charAt(index) + "'");
}
*/
throw new AssertionFailedError(
"Golden file for test " + _scriptName + " did not match; " +
"first difference at " + index + ", difference of length " +
diffLength + ", \"" + difference + "\"");
}
}