Skip to content

Commit

Permalink
Automatic code cleanup.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 602812501
  • Loading branch information
cpovirk authored and google-java-format Team committed Jan 30, 2024
1 parent 3366df2 commit c20a027
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
package com.google.googlejavaformat.java;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.fail;

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 +181,11 @@ public void paramsFile() throws IOException {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
package com.google.googlejavaformat.java;

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

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

assertThat(
Truth8.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 @@ -15,9 +15,9 @@
package com.google.googlejavaformat.java;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.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 +35,7 @@ public class GoogleJavaFormatToolTest {
public void testUsageOutputAfterLoadingViaToolName() {
String name = "google-java-format";

assertThat(
Truth8.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 @@ -15,9 +15,9 @@
package com.google.googlejavaformat.java;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.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,25 +52,26 @@ private static Optional<Integer> getPrefix(String qualifiedName) {

@Test
public void typePrefixLength() {
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);
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);
}

@Test
public void ambiguousClass() {
assertThat(getPrefix("com.google.security.acl.proto2api.ACL.Entry.newBuilder")).hasValue(7);
Truth8.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`.
assertThat(getPrefix("com.google.security.acl.proto2api.ACL.newBuilder")).isEmpty();
Truth8.assertThat(getPrefix("com.google.security.acl.proto2api.ACL.newBuilder")).isEmpty();
}
}

0 comments on commit c20a027

Please sign in to comment.