View Javadoc
1   package com.google.checkstyle.test.chapter2filebasic.rule232specialescape;
2   
3   /**
4    * Test for illegal tokens
5    */
6   public class InputIllegalTokenText
7   {
8   
9       public void methodWithLiterals()
10      {
11          final String ref = "<a href=\"";
12          final String refCase = "<A hReF=\"";
13      }
14      
15      public String wrongEscapeSequences() 
16      {
17          final String r1 = "\u0008"; //ok
18          final String r2 = "\u0009"; //warn
19          final String r3 = "\u000csssdfsd"; //warn
20          final String r4  = "\u1111sdfsd\444"; // ok
21          
22          final char r5 = '\012'; //warn
23          final char r6 = '\u0022'; //warn
24          final char r7 = '\b'; //ok
25          return "\u000csssdfsd"; //warn
26      }
27      
28      public void specialCharsWithoutWarn()
29      {
30          String r1 = "\b"; //ok
31          String r2 = "\t"; //ok
32          String r3 = "\n"; //ok
33          String r4 = "\f"; //ok
34          String r5 = "\r"; //ok
35          String r6 = "\""; //ok
36          String r7 = "\'"; //ok
37          String r8 = "\\"; //ok
38      }
39  
40      public void specialCharsWithWarn()
41      {
42          String r1 = "\\u0008"; //ok
43          String r2 = "\\u0009"; // warn
44          String r3 = "\\u000a"; // warn
45          String r4 = "\\u000c"; // warn
46          String r5 = "\\u000d"; // warn
47          String r6 = "\\u0022"; // warn
48          String r7 = "\\u0027"; // warn
49          String r8 = "\\u005c"; // warn
50      }
51      
52      public void specialCharsWithWarn2()
53      {
54          String r1 = "\\010"; // warn
55          String r2 = "\\011"; // warn
56          String r3 = "\\012"; // warn
57          String r4 = "\\014"; // warn
58          String r5 = "\\015"; // warn
59          String r6 = "\\042"; // warn
60          String r7 = "\\047"; // warn
61          String r8 = "\\134"; // warn
62      }
63      
64      class Inner
65      {
66          public String wrongEscapeSequences() 
67          {
68              final String r1 = "\u0008"; //ok
69              final String r2 = "\u0009"; //warn
70              final String r3 = "\u000csssdfsd"; //warn
71              final String r4  = "\u1111sdfsd\444"; //ok
72              
73              final char r5 = '\012'; //warn
74              final char r6 = '\u0022'; //warn
75              final char r7 = '\b'; //ok
76              return "\u000csssdfsd"; //warn
77          }
78          
79          public void specialCharsWithoutWarn()
80          {
81              String r1 = "\b"; //ok
82              String r2 = "\t"; //ok
83              String r3 = "\n"; //ok
84              String r4 = "\f"; //ok
85              String r5 = "\r"; //ok
86              String r6 = "\""; //ok
87              String r7 = "\'"; //ok
88              String r8 = "\\"; //ok
89          }
90  
91          public void specialCharsWithWarn()
92          {
93              String r1 = "\\u0008"; //ok
94              String r2 = "\\u0009"; // warn
95              String r3 = "\\u000a"; // warn
96              String r4 = "\\u000c"; // warn
97              String r5 = "\\u000d"; // warn
98              String r6 = "\\u0022"; // warn
99              String r7 = "\\u0027"; // warn
100             String r8 = "\\u005c"; // warn
101         }
102         
103         public void specialCharsWithWarn2()
104         {
105             String r1 = "\\010"; // warn
106             String r2 = "\\011"; // warn
107             String r3 = "\\012"; // warn
108             String r4 = "\\014"; // warn
109             String r5 = "\\015"; // warn
110             String r6 = "\\042"; // warn
111             String r7 = "\\047"; // warn
112             String r8 = "\\134"; // warn
113         }
114 
115         Inner anoInner = new Inner(){
116             public String wrongEscapeSequences() 
117             {
118                 final String r1 = "\u0008"; //ok
119                 final String r2 = "\u0009"; //warn
120                 final String r3 = "\u000csssdfsd"; //warn
121                 final String r4  = "\u1111sdfsd\444"; //ok
122                 
123                 final char r5 = '\012'; //warn
124                 final char r6 = '\u0022'; //warn
125                 final char r7 = '\b'; //ok
126                 return "\u000csssdfsd"; //warn
127             }
128             
129             public void specialCharsWithoutWarn()
130             {
131                 String r1 = "\b"; //ok
132                 String r2 = "\t"; //ok
133                 String r3 = "\n"; //ok
134                 String r4 = "\f"; //ok
135                 String r5 = "\r"; //ok
136                 String r6 = "\""; //ok
137                 String r7 = "\'"; //ok
138                 String r8 = "\\"; //ok
139             }
140 
141             public void specialCharsWithWarn()
142             {
143                 String r1 = "\\u0008"; //ok
144                 String r2 = "\\u0009"; // warn
145                 String r3 = "\\u000a"; // warn
146                 String r4 = "\\u000c"; // warn
147                 String r5 = "\\u000d"; // warn
148                 String r6 = "\\u0022"; // warn
149                 String r7 = "\\u0027"; // warn
150                 String r8 = "\\u005c"; // warn
151             }
152             
153             public void specialCharsWithWarn2()
154             {
155                 String r1 = "\\010"; // warn
156                 String r2 = "\\011"; // warn
157                 String r3 = "\\012"; // warn
158                 String r4 = "\\014"; // warn
159                 String r5 = "\\015"; // warn
160                 String r6 = "\\042"; // warn
161                 String r7 = "\\047"; // warn
162                 String r8 = "\\134"; // warn
163             }  
164         };
165     }
166 }