View Javadoc
1   /*
2   RightCurly
3   option = (default)SAME
4   tokens = LITERAL_DO
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly;
10  
11  import java.util.Scanner;
12  
13  /*
14   * Test input for GitHub issue #3090.
15   * https://github.com/checkstyle/checkstyle/issues/3090
16   */
17  public class InputRightCurlyTestSameAndLiteralDo {
18  
19      public void foo1() {
20          do {
21          } while (true);
22      }
23  
24      public void foo2() {
25          int i = 1;
26          while (i < 5) {
27              String.CASE_INSENSITIVE_ORDER.equals(i + " ");
28              i++;
29          }
30      }
31  
32      public void foo3() {
33          int i = 1;
34          do {
35              i++;
36              String.CASE_INSENSITIVE_ORDER.equals(i + " ");
37          } while (i < 5);
38      }
39  
40      public void foo4() {
41          int prog, user;
42          prog = (int)(Math.random() * 10) + 1;
43          Scanner input = new Scanner(System.in, "utf-8");
44          if( input.hasNextInt() ) {
45              do {
46                  user = input.nextInt();
47                  if(user == prog) {
48                      String.CASE_INSENSITIVE_ORDER.equals("Good!");
49                  } else {
50                      if (user > 0 && user <= 10) {
51                          String.CASE_INSENSITIVE_ORDER.equals("Bad! ");
52                          if( prog < user ) {
53                              String.CASE_INSENSITIVE_ORDER.equals("My number is less than yours.");
54                          } else {
55                              String.CASE_INSENSITIVE_ORDER.equals("My number is greater than yours");
56                          }
57                      } else {
58                          String.CASE_INSENSITIVE_ORDER.equals("Error!");
59                      }
60                  }
61              } while( user != prog );
62          } else {
63              String.CASE_INSENSITIVE_ORDER.equals("Error!");
64          }
65          String.CASE_INSENSITIVE_ORDER.equals("Goodbye!");
66      }
67  
68      public void foo5() {
69          do {
70          } // violation ''}' at column 9 should be on the same line as .*/while'
71          while (true);
72      }
73  
74      public void foo6() {
75          do {} // violation ''}' at column 13 should be on the same line as .*/while'
76          while (true);
77      }
78  
79      public void foo7() {
80          do
81          {
82  
83          } while (true);
84      }
85  
86      public void foo8() {
87          do
88  
89          {
90  
91          } // violation ''}' at column 9 should be on the same line as .*/while'
92  
93          while
94  
95          (true);
96      }
97  
98      public void foo9() {
99          do {} while (true);
100     }
101 
102     public void foo10() {
103         do ; while (true);
104     }
105 }
106