Skip to content

Commit

Permalink
Automatic code cleanup.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 604705523
  • Loading branch information
cpovirk authored and google-java-format Team committed Feb 6, 2024
1 parent e260fa9 commit c8e8679
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Range;
import com.google.common.truth.Truth8;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -181,11 +180,11 @@ public void paramsFile() throws IOException {

@Test
public void assumeFilename() {
Truth8.assertThat(
assertThat(
CommandLineOptionsParser.parse(Arrays.asList("--assume-filename", "Foo.java"))
.assumeFilename())
.hasValue("Foo.java");
Truth8.assertThat(CommandLineOptionsParser.parse(Arrays.asList("Foo.java")).assumeFilename())
assertThat(CommandLineOptionsParser.parse(Arrays.asList("Foo.java")).assumeFilename())
.isEmpty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import static com.google.common.truth.Truth.assertThat;

import com.google.common.truth.Truth8;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ServiceLoader;
Expand All @@ -33,7 +32,7 @@ public class GoogleJavaFormatToolProviderTest {
public void testUsageOutputAfterLoadingViaToolName() {
String name = "google-java-format";

Truth8.assertThat(
assertThat(
ServiceLoader.load(ToolProvider.class).stream()
.map(ServiceLoader.Provider::get)
.map(ToolProvider::name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.common.truth.Truth8;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
Expand All @@ -35,7 +34,7 @@ public class GoogleJavaFormatToolTest {
public void testUsageOutputAfterLoadingViaToolName() {
String name = "google-java-format";

Truth8.assertThat(
assertThat(
ServiceLoader.load(Tool.class).stream()
.map(ServiceLoader.Provider::get)
.map(Tool::name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;

import com.google.common.base.Splitter;
import com.google.common.truth.Truth8;
import com.google.googlejavaformat.java.TypeNameClassifier.JavaCaseFormat;
import java.util.Optional;
import org.junit.Test;
Expand Down Expand Up @@ -52,26 +51,25 @@ private static Optional<Integer> getPrefix(String qualifiedName) {

@Test
public void typePrefixLength() {
Truth8.assertThat(getPrefix("fieldName")).isEmpty();
Truth8.assertThat(getPrefix("CONST")).isEmpty();
Truth8.assertThat(getPrefix("ClassName")).hasValue(0);
Truth8.assertThat(getPrefix("com.ClassName")).hasValue(1);
Truth8.assertThat(getPrefix("ClassName.foo")).hasValue(1);
Truth8.assertThat(getPrefix("com.ClassName.foo")).hasValue(2);
Truth8.assertThat(getPrefix("ClassName.foo.bar")).hasValue(1);
Truth8.assertThat(getPrefix("com.ClassName.foo.bar")).hasValue(2);
Truth8.assertThat(getPrefix("ClassName.CONST")).hasValue(1);
Truth8.assertThat(getPrefix("ClassName.varName")).hasValue(1);
Truth8.assertThat(getPrefix("ClassName.Inner.varName")).hasValue(2);
Truth8.assertThat(getPrefix("com.R.foo")).hasValue(2);
assertThat(getPrefix("fieldName")).isEmpty();
assertThat(getPrefix("CONST")).isEmpty();
assertThat(getPrefix("ClassName")).hasValue(0);
assertThat(getPrefix("com.ClassName")).hasValue(1);
assertThat(getPrefix("ClassName.foo")).hasValue(1);
assertThat(getPrefix("com.ClassName.foo")).hasValue(2);
assertThat(getPrefix("ClassName.foo.bar")).hasValue(1);
assertThat(getPrefix("com.ClassName.foo.bar")).hasValue(2);
assertThat(getPrefix("ClassName.CONST")).hasValue(1);
assertThat(getPrefix("ClassName.varName")).hasValue(1);
assertThat(getPrefix("ClassName.Inner.varName")).hasValue(2);
assertThat(getPrefix("com.R.foo")).hasValue(2);
}

@Test
public void ambiguousClass() {
Truth8.assertThat(getPrefix("com.google.security.acl.proto2api.ACL.Entry.newBuilder"))
.hasValue(7);
assertThat(getPrefix("com.google.security.acl.proto2api.ACL.Entry.newBuilder")).hasValue(7);
// A human would probably identify this as "class-shaped", but just looking
// at the case we have to assume it could be something like `field1.field2.CONST`.
Truth8.assertThat(getPrefix("com.google.security.acl.proto2api.ACL.newBuilder")).isEmpty();
assertThat(getPrefix("com.google.security.acl.proto2api.ACL.newBuilder")).isEmpty();
}
}

0 comments on commit c8e8679

Please sign in to comment.