Skip to content

Commit

Permalink
Automatic code cleanup.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 605025464
  • Loading branch information
cpovirk authored and Error Prone Team committed Feb 7, 2024
1 parent 0bd7432 commit 3ff139f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.truth.Truth8;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand All @@ -38,10 +37,10 @@ public void parseAndGetStringValue() {
.parseFlag("-XepOpt:Other:Arg:More:Parts=Long")
.parseFlag("-XepOpt:EmptyArg=")
.build();
Truth8.assertThat(flags.get("SomeArg")).hasValue("SomeValue");
Truth8.assertThat(flags.get("Other:Arg:More:Parts")).hasValue("Long");
Truth8.assertThat(flags.get("EmptyArg")).hasValue("");
Truth8.assertThat(flags.get("absent")).isEmpty();
assertThat(flags.get("SomeArg")).hasValue("SomeValue");
assertThat(flags.get("Other:Arg:More:Parts")).hasValue("Long");
assertThat(flags.get("EmptyArg")).hasValue("");
assertThat(flags.get("absent")).isEmpty();
}

@Test
Expand All @@ -54,17 +53,17 @@ public void parseAndGetBoolean() {
.parseFlag("-XepOpt:Arg3=yes")
.parseFlag("-XepOpt:Arg4")
.build();
Truth8.assertThat(flags.getBoolean("Arg1")).hasValue(true);
Truth8.assertThat(flags.getBoolean("Arg2")).hasValue(false);
assertThat(flags.getBoolean("Arg1")).hasValue(true);
assertThat(flags.getBoolean("Arg2")).hasValue(false);
assertThrows(IllegalArgumentException.class, () -> flags.getBoolean("Arg3"));
Truth8.assertThat(flags.getBoolean("Arg4")).hasValue(true);
Truth8.assertThat(flags.getBoolean("absent")).isEmpty();
assertThat(flags.getBoolean("Arg4")).hasValue(true);
assertThat(flags.getBoolean("absent")).isEmpty();
}

@Test
public void parseAndGetImplicitTrue() {
ErrorProneFlags flags = ErrorProneFlags.builder().parseFlag("-XepOpt:SomeArg").build();
Truth8.assertThat(flags.getBoolean("SomeArg")).hasValue(true);
assertThat(flags.getBoolean("SomeArg")).hasValue(true);
}

@Test
Expand All @@ -75,10 +74,10 @@ public void parseAndGetInteger() {
.parseFlag("-XepOpt:Arg2=20.6")
.parseFlag("-XepOpt:Arg3=thirty")
.build();
Truth8.assertThat(flags.getInteger("Arg1")).hasValue(10);
assertThat(flags.getInteger("Arg1")).hasValue(10);
assertThrows(NumberFormatException.class, () -> flags.getInteger("Arg2"));
assertThrows(NumberFormatException.class, () -> flags.getInteger("Arg3"));
Truth8.assertThat(flags.getInteger("absent")).isEmpty();
assertThat(flags.getInteger("absent")).isEmpty();
}

@Test
Expand Down Expand Up @@ -145,13 +144,13 @@ public void enumFlags() {
.parseFlag("-XepOpt:CaseInsensitiveColours=yellow,green")
.parseFlag("-XepOpt:EmptyColours=")
.build();
Truth8.assertThat(flags.getEnum("Colour", Colour.class)).hasValue(Colour.RED);
Truth8.assertThat(flags.getEnumSet("Colours", Colour.class))
assertThat(flags.getEnum("Colour", Colour.class)).hasValue(Colour.RED);
assertThat(flags.getEnumSet("Colours", Colour.class))
.hasValue(ImmutableSet.of(Colour.YELLOW, Colour.GREEN));
Truth8.assertThat(flags.getEnumSet("CaseInsensitiveColours", Colour.class))
assertThat(flags.getEnumSet("CaseInsensitiveColours", Colour.class))
.hasValue(ImmutableSet.of(Colour.YELLOW, Colour.GREEN));
Truth8.assertThat(flags.getEnumSet("EmptyColours", Colour.class)).hasValue(ImmutableSet.of());
Truth8.assertThat(flags.getEnumSet("NoSuchColours", Colour.class)).isEmpty();
assertThat(flags.getEnumSet("EmptyColours", Colour.class)).hasValue(ImmutableSet.of());
assertThat(flags.getEnumSet("NoSuchColours", Colour.class)).isEmpty();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.google.common.truth.FailureMetadata;
import com.google.common.truth.MapSubject;
import com.google.common.truth.Subject;
import com.google.common.truth.Truth8;
import com.google.errorprone.BugCheckerInfo;
import com.google.errorprone.BugPattern;
import com.google.errorprone.BugPattern.SeverityLevel;
Expand Down Expand Up @@ -149,7 +148,7 @@ public void plusAllowsDuplicateClassLoading() throws Exception {
assertThat(class1).isNotEqualTo(class2);
ScannerSupplier ss = ss1.plus(ss2);
assertThat(ss.getAllChecks()).hasSize(2);
Truth8.assertThat(ss.getAllChecks().values().stream().map(c -> c.checkerClass()))
assertThat(ss.getAllChecks().values().stream().map(c -> c.checkerClass()))
.containsExactly(ArrayEquals.class, class1);
assertScanner(ss).hasEnabledChecks(class1);
}
Expand Down

0 comments on commit 3ff139f

Please sign in to comment.