tests for NewlineAtEndOfFile check, contributed by Christopher Lenz
This commit is contained in:
parent
35139b1ca2
commit
09efd9db71
|
|
@ -0,0 +1,46 @@
|
|||
package com.puppycrawl.tools.checkstyle.checks;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
|
||||
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
||||
import com.puppycrawl.tools.checkstyle.api.Configuration;
|
||||
|
||||
public class NewlineAtEndOfFileCheckTest
|
||||
extends BaseCheckTestCase
|
||||
{
|
||||
protected DefaultConfiguration createCheckerConfig(
|
||||
Configuration aCheckConfig)
|
||||
{
|
||||
final DefaultConfiguration dc = new DefaultConfiguration("root");
|
||||
dc.addChild(aCheckConfig);
|
||||
return dc;
|
||||
}
|
||||
|
||||
public void testNewlineAtEndOfFile()
|
||||
throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(NewlineAtEndOfFileCheck.class);
|
||||
checkConfig.addAttribute("lineSeparator", LineSeparatorOption.LF.toString());
|
||||
final String[] expected = { };
|
||||
verify(
|
||||
createChecker(checkConfig),
|
||||
getPath("InputNewlineAtEndOfFile.java"),
|
||||
expected);
|
||||
}
|
||||
|
||||
public void testNoNewlineAtEndOfFile()
|
||||
throws Exception
|
||||
{
|
||||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(NewlineAtEndOfFileCheck.class);
|
||||
checkConfig.addAttribute("lineSeparator", LineSeparatorOption.LF.toString());
|
||||
final String[] expected = {
|
||||
"0: File does not end with a newline."
|
||||
};
|
||||
verify(
|
||||
createChecker(checkConfig),
|
||||
getPath("InputNoNewlineAtEndOfFile.java"),
|
||||
expected);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue