Skip to content

Commit

Permalink
Issue checkstyle#11446: Update CheckerTest method testUnmappableChara…
Browse files Browse the repository at this point in the history
…cters
  • Loading branch information
LakshmiSowmya20 committed Apr 5, 2024
1 parent f7e952b commit 85ff7cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 2 additions & 0 deletions config/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<suppress checks="FileLength"
files="TokenTypes.java|IndentationCheckTest.java|XdocsPagesTest|CheckerTest.java"
lines="1"/>

<suppress checks="LineLength" files="CheckerTest.java"/>

<!-- illegal words are part of Javadoc -->
<suppress checks="TodoComment" files=".*TodoCommentCheck\.java"/>
Expand Down
16 changes: 4 additions & 12 deletions src/test/java/com/puppycrawl/tools/checkstyle/CheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@
import com.puppycrawl.tools.checkstyle.internal.utils.CloseAndFlushTestByteArrayOutputStream;
import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil;
import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
import de.thetaphi.forbiddenapis.SuppressForbidden;

/**
/**N
* CheckerTest.
*
* @noinspection ClassWithTooManyDependencies
Expand Down Expand Up @@ -1656,20 +1655,13 @@ public void testCachedFile() throws Exception {
checker.destroy();
}

@SuppressForbidden
@Test
public void testUnmappableCharacters() throws Exception {
final String[] expected = {
"4: " + getCheckMessage(LineLengthCheck.class, MSG_KEY, 75, 238),
"14: " + getCheckMessage(LineLengthCheck.class, MSG_KEY, 80, 100),
};

final DefaultConfiguration checkConfig = createModuleConfig(LineLengthCheck.class);
checkConfig.addProperty("max", "75");

final DefaultConfiguration checkerConfig = createRootConfig(checkConfig);
checkerConfig.addProperty("charset", "IBM1098");

verify(checkerConfig, getPath("InputCheckerTestCharset.java"), expected);

verifyWithInlineXmlConfig(getPath("InputCheckerTestCharset.xml"), expected);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*xml
<module name="Checker">
<module name="com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck">
<property name="max" value="80"/>
</module>
<property name="charset" value="IBM1098"/>
</module>
*/

package com.puppycrawl.tools.checkstyle.checker;

public class InputCheckerTestCharset {
Expand Down

0 comments on commit 85ff7cc

Please sign in to comment.