Skip to content

Commit

Permalink
Issue checkstyle#11446: Update checker test method testUnmappableChar…
Browse files Browse the repository at this point in the history
…acters

Issue checkstyle#11446: Update checker test method testUnmappableCharacters using xml config
  • Loading branch information
chrccl committed Feb 19, 2024
1 parent c1ca1b9 commit d021f7f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
9 changes: 9 additions & 0 deletions config/pitest-suppressions/pitest-common-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,13 @@
<description>replaced call to java/util/Collections::synchronizedList with argument</description>
<lineContent>private final List&lt;Throwable&gt; exceptions = Collections.synchronizedList(new ArrayList&lt;&gt;());</lineContent>
</mutation>

<mutation unstable="false">
<sourceFile>Checker.java</sourceFile>
<mutatedClass>com.puppycrawl.tools.checkstyle.Checker</mutatedClass>
<mutatedMethod>setCharset</mutatedMethod>
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.MemberVariableMutator</mutator>
<description>Removed assignment to member variable charset</description>
<lineContent>this.charset = charset;</lineContent>
</mutation>
</suppressedMutations>
2 changes: 2 additions & 0 deletions config/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
files="TokenTypes.java|IndentationCheckTest.java|XdocsPagesTest"
lines="1"/>

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

<!-- illegal words are part of Javadoc -->
<suppress checks="TodoComment" files=".*TodoCommentCheck\.java"/>

Expand Down
12 changes: 2 additions & 10 deletions src/test/java/com/puppycrawl/tools/checkstyle/CheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
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;

/**
* CheckerTest.
Expand Down Expand Up @@ -1659,20 +1658,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);
verifyWithInlineConfigParser(getPath("InputCheckerTestCharset.java"), expected);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*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 d021f7f

Please sign in to comment.