001: package com.puppycrawl.tools.checkstyle.checks.blocks;
002:
003: import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
004: import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
005:
006: public class LeftCurlyCheckTest extends BaseCheckTestCase {
007: private DefaultConfiguration mCheckConfig;
008:
009: public void setUp() {
010: mCheckConfig = createCheckConfig(LeftCurlyCheck.class);
011: }
012:
013: public void testDefault() throws Exception {
014: final String[] expected = {
015: "8:1: '{' should be on the previous line.",
016: "12:5: '{' should be on the previous line.",
017: "21:5: '{' should be on the previous line.",
018: "30:5: '{' should be on the previous line.",
019: "39:5: '{' should be on the previous line.", };
020: verify(mCheckConfig, getPath("InputScopeInnerInterfaces.java"),
021: expected);
022: }
023:
024: public void testNL() throws Exception {
025: mCheckConfig.addAttribute("option", LeftCurlyOption.NL
026: .toString());
027: final String[] expected = {
028: "49:14: '{' should be on a new line.",
029: "53:14: '{' should be on a new line.",
030: "58:18: '{' should be on a new line.",
031: "62:18: '{' should be on a new line.",
032: "67:12: '{' should be on a new line.",
033: "72:18: '{' should be on a new line.", };
034: verify(mCheckConfig, getPath("InputScopeInnerInterfaces.java"),
035: expected);
036: }
037:
038: public void testNLOW() throws Exception {
039: mCheckConfig.addAttribute("option", LeftCurlyOption.NLOW
040: .toString());
041: final String[] expected = {
042: "8:1: '{' should be on the previous line.",
043: "12:5: '{' should be on the previous line.",
044: "21:5: '{' should be on the previous line.",
045: "30:5: '{' should be on the previous line.",
046: "39:5: '{' should be on the previous line.",
047: "49:14: '{' should be on a new line.",
048: "53:14: '{' should be on a new line.",
049: "58:18: '{' should be on a new line.",
050: "62:18: '{' should be on a new line.",
051: "67:12: '{' should be on a new line.",
052: "72:18: '{' should be on a new line.", };
053: verify(mCheckConfig, getPath("InputScopeInnerInterfaces.java"),
054: expected);
055: }
056:
057: public void testDefault2() throws Exception {
058: final String[] expected = {
059: "12:1: '{' should be on the previous line.",
060: "17:5: '{' should be on the previous line.",
061: "24:5: '{' should be on the previous line.",
062: "31:5: '{' should be on the previous line.",
063: "39:1: '{' should be on the previous line.",
064: "41:5: '{' should be on the previous line.",
065: "46:9: '{' should be on the previous line.",
066: "53:9: '{' should be on the previous line.",
067: "69:5: '{' should be on the previous line.",
068: "77:5: '{' should be on the previous line.",
069: "84:5: '{' should be on the previous line.", };
070: verify(mCheckConfig, getPath("InputLeftCurlyMethod.java"),
071: expected);
072: }
073:
074: public void testNL2() throws Exception {
075: mCheckConfig.addAttribute("option", LeftCurlyOption.NL
076: .toString());
077: final String[] expected = {
078: "14:39: '{' should be on a new line.",
079: "21:20: '{' should be on a new line.",
080: "34:31: '{' should be on a new line.",
081: "43:24: '{' should be on a new line.",
082: "56:35: '{' should be on a new line.",
083: "60:24: '{' should be on a new line.",
084: "74:20: '{' should be on a new line.",
085: "87:31: '{' should be on a new line.", };
086: verify(mCheckConfig, getPath("InputLeftCurlyMethod.java"),
087: expected);
088: }
089:
090: public void testDefault3() throws Exception {
091: final String[] expected = {
092: "12:1: '{' should be on the previous line.",
093: "15:5: '{' should be on the previous line.",
094: "19:9: '{' should be on the previous line.",
095: "21:13: '{' should be on the previous line.",
096: "23:17: '{' should be on the previous line.",
097: "30:17: '{' should be on the previous line.",
098: "34:17: '{' should be on the previous line.",
099: "42:13: '{' should be on the previous line.",
100: "46:13: '{' should be on the previous line.",
101: "52:9: '{' should be on the previous line.",
102: "54:13: '{' should be on the previous line.",
103: "63:9: '{' should be on the previous line.",
104: "83:5: '{' should be on the previous line.",
105: "89:5: '{' should be on the previous line.", };
106: verify(mCheckConfig, getPath("InputLeftCurlyOther.java"),
107: expected);
108: }
109:
110: public void testNL3() throws Exception {
111: mCheckConfig.addAttribute("option", LeftCurlyOption.NL
112: .toString());
113: final String[] expected = {
114: "26:33: '{' should be on a new line.",
115: "91:19: '{' should be on a new line.",
116: "97:19: '{' should be on a new line.", };
117: verify(mCheckConfig, getPath("InputLeftCurlyOther.java"),
118: expected);
119: }
120:
121: public void testMissingBraces() throws Exception {
122: final String[] expected = {
123: "12:1: '{' should be on the previous line.",
124: "15:5: '{' should be on the previous line.",
125: "21:5: '{' should be on the previous line.",
126: "34:5: '{' should be on the previous line.",
127: "51:5: '{' should be on the previous line.",
128: "69:5: '{' should be on the previous line.",
129: "105:5: '{' should be on the previous line.", };
130: verify(mCheckConfig, getPath("InputBraces.java"), expected);
131: }
132: }
|