Skip to content

Commit 670be78

Browse files
committed
Fix some Error Prone warnings
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=186912758
1 parent fe20610 commit 670be78

File tree

1 file changed

+11
-35
lines changed

1 file changed

+11
-35
lines changed

core/src/test/java/com/google/googlejavaformat/java/CommandLineFlagsTest.java

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class CommandLineFlagsTest {
3030
// TODO(eaftan): Disallow passing both -lines and -offset/-length, like clang-format.
3131

3232
@Test
33-
public void formatInPlaceRequiresAtLeastOneFile() {
33+
public void formatInPlaceRequiresAtLeastOneFile() throws UsageException {
3434
try {
3535
Main.processArgs("-i");
3636
fail();
@@ -45,21 +45,13 @@ public void formatInPlaceRequiresAtLeastOneFile() {
4545
// expected
4646
}
4747

48-
try {
49-
Main.processArgs("-i", "Foo.java");
50-
Main.processArgs("-i", "Foo.java", "Bar.java");
51-
} catch (UsageException e) {
52-
fail();
53-
}
48+
Main.processArgs("-i", "Foo.java");
49+
Main.processArgs("-i", "Foo.java", "Bar.java");
5450
}
5551

5652
@Test
57-
public void formatASubsetRequiresExactlyOneFile() {
58-
try {
59-
Main.processArgs("-lines", "10", "Foo.java");
60-
} catch (UsageException e) {
61-
fail();
62-
}
53+
public void formatASubsetRequiresExactlyOneFile() throws UsageException {
54+
Main.processArgs("-lines", "10", "Foo.java");
6355

6456
try {
6557
Main.processArgs("-lines", "10");
@@ -75,11 +67,7 @@ public void formatASubsetRequiresExactlyOneFile() {
7567
// expected
7668
}
7769

78-
try {
79-
Main.processArgs("-offset", "10", "-length", "10", "Foo.java");
80-
} catch (UsageException e) {
81-
fail();
82-
}
70+
Main.processArgs("-offset", "10", "-length", "10", "Foo.java");
8371

8472
try {
8573
Main.processArgs("-offset", "10", "-length", "10");
@@ -99,12 +87,8 @@ public void formatASubsetRequiresExactlyOneFile() {
9987
// TODO(eaftan): clang-format allows a single offset with no length, which means to format
10088
// up to the end of the file. We should match that behavior.
10189
@Test
102-
public void numberOfOffsetsMustMatchNumberOfLengths() {
103-
try {
104-
Main.processArgs("-offset", "10", "-length", "20", "Foo.java");
105-
} catch (UsageException e) {
106-
fail();
107-
}
90+
public void numberOfOffsetsMustMatchNumberOfLengths() throws UsageException {
91+
Main.processArgs("-offset", "10", "-length", "20", "Foo.java");
10892

10993
try {
11094
Main.processArgs("-offset", "10", "-length", "20", "-offset", "50", "Foo.java");
@@ -122,18 +106,10 @@ public void numberOfOffsetsMustMatchNumberOfLengths() {
122106
}
123107

124108
@Test
125-
public void noFilesToFormatRequiresEitherHelpOrVersion() {
126-
try {
127-
Main.processArgs("-version");
128-
} catch (UsageException e) {
129-
fail();
130-
}
109+
public void noFilesToFormatRequiresEitherHelpOrVersion() throws UsageException {
110+
Main.processArgs("-version");
131111

132-
try {
133-
Main.processArgs("-help");
134-
} catch (UsageException e) {
135-
fail();
136-
}
112+
Main.processArgs("-help");
137113

138114
try {
139115
Main.processArgs();

0 commit comments

Comments
 (0)