TrailingCommentCheckTest.java :  » Code-Analyzer » checkstyle-5.1 » com » puppycrawl » tools » checkstyle » checks » Java Open Source

Java Open Source » Code Analyzer » checkstyle 5.1 
checkstyle 5.1 » com » puppycrawl » tools » checkstyle » checks » TrailingCommentCheckTest.java
package com.puppycrawl.tools.checkstyle.checks;

import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Before;
import org.junit.Test;

public class TrailingCommentCheckTest extends BaseCheckTestSupport
{
    DefaultConfiguration mCheckConfig;

    @Before
    public void setUp() {
        mCheckConfig = createCheckConfig(TrailingCommentCheck.class);
    }

    @Test
    public void testDefaults() throws Exception
    {
        final String[] expected = {
            "2: Don't use trailing comments.",
            "5: Don't use trailing comments.",
            "6: Don't use trailing comments.",
            "16: Don't use trailing comments.",
            "17: Don't use trailing comments.",
            "27: Don't use trailing comments.",
        };
        verify(mCheckConfig, getPath("InputTrailingComment.java"), expected);
    }

    @Test
    public void testLegalComment() throws Exception
    {
        mCheckConfig.addAttribute("legalComment", "^NOI18N$");
        final String[] expected = {
            "2: Don't use trailing comments.",
            "5: Don't use trailing comments.",
            "6: Don't use trailing comments.",
            "16: Don't use trailing comments.",
            "17: Don't use trailing comments.",
        };
        verify(mCheckConfig, getPath("InputTrailingComment.java"), expected);
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.