Skip to content

Commit 24fd6bc

Browse files
rishipalcopybara-github
authored andcommitted
Refactor: Simplify tests using (obj.size()).isEqualTo() to use obj.hasSize()
PiperOrigin-RevId: 324269359
1 parent dae748d commit 24fd6bc

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

test/com/google/debugging/sourcemap/SourceMapGeneratorV3Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ public void testSourceMapExtensions() throws Exception {
583583
assertThat(sourceMap.has("google_test")).isFalse();
584584
assertThat(sourceMap.get("x_google_test").getAsJsonObject().get("number").getAsInt())
585585
.isEqualTo(1);
586-
assertThat(sourceMap.get("x_google_array").getAsJsonArray().size()).isEqualTo(0);
586+
assertThat(sourceMap.get("x_google_array").getAsJsonArray()).hasSize(0);
587587
assertThat(sourceMap.get("x_google_int").getAsInt()).isEqualTo(2);
588588
assertThat(sourceMap.get("x_google_str").getAsString()).isEqualTo("Some text");
589589
}

test/com/google/javascript/jscomp/JSModuleGraphTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ public void testToJson() {
470470
makeDeps();
471471
makeGraph();
472472
JsonArray modules = graph.toJson();
473-
assertThat(modules.size()).isEqualTo(7);
473+
assertThat(modules).hasSize(7);
474474
for (int i = 0; i < modules.size(); i++) {
475475
JsonObject m = modules.get(i).getAsJsonObject();
476476
assertThat(m.get("name")).isNotNull();
@@ -481,7 +481,7 @@ public void testToJson() {
481481
JsonObject m = modules.get(3).getAsJsonObject();
482482
assertThat(m.get("name").getAsString()).isEqualTo("moduleD");
483483
assertThat(m.get("dependencies").getAsJsonArray().toString()).isEqualTo("[\"moduleB\"]");
484-
assertThat(m.get("transitive-dependencies").getAsJsonArray().size()).isEqualTo(2);
484+
assertThat(m.get("transitive-dependencies").getAsJsonArray()).hasSize(2);
485485
assertThat(m.get("inputs").getAsJsonArray().toString()).isEqualTo("[]");
486486
}
487487

test/com/google/javascript/jscomp/SymbolTableTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ public void testPrototypeReferences() {
565565
List<Reference> refs = table.getReferenceList(prototype);
566566

567567
// One of the refs is implicit in the declaration of the function.
568-
assertWithMessage(refs.toString()).that(refs.size()).isEqualTo(2);
568+
assertWithMessage(refs.toString()).that(refs).hasSize(2);
569569
}
570570

571571
@Test
@@ -635,7 +635,7 @@ public void testPrototypeReferences_es6Class() {
635635
List<Reference> refs = table.getReferenceList(prototype);
636636

637637
// The class declaration creates an implicit .prototype reference.
638-
assertWithMessage(refs.toString()).that(refs.size()).isEqualTo(1);
638+
assertWithMessage(refs.toString()).that(refs).hasSize(1);
639639
assertNode(refs.get(0).getNode().getParent()).hasToken(Token.CLASS);
640640
}
641641

0 commit comments

Comments
 (0)