Skip to content

Commit 0cafc5a

Browse files
cushoncopybara-github
authored andcommitted
Automated Code Change
PiperOrigin-RevId: 831891685 Change-Id: Ib6ead6d780d964c364824a1cdc8013abd9abd63f
1 parent a9d529f commit 0cafc5a

7 files changed

Lines changed: 43 additions & 53 deletions

File tree

src/tools/javatests/com/google/devtools/build/android/DesugarDexShardingActionTest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,8 @@ private void runDesugarDexSharding(int shardCount) throws Exception {
8686
DesugarDexShardingAction.main(args.toArray(new String[0]));
8787

8888
for (Path out : outs) {
89-
assertWithMessage("Output zip " + out + " does not exist")
90-
.that(out.toFile().exists())
91-
.isTrue();
92-
assertWithMessage("Output zip " + out + " is empty")
93-
.that(out.toFile().length())
94-
.isGreaterThan(0);
89+
assertWithMessage("Output zip %s does not exist", out).that(out.toFile().exists()).isTrue();
90+
assertWithMessage("Output zip %s is empty", out).that(out.toFile().length()).isGreaterThan(0);
9591
}
9692
}
9793

src/tools/javatests/com/google/devtools/build/android/UnwrittenMergedAndroidDataSubject.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ public void isEqualTo(UnwrittenMergedAndroidData expected) {
5050

5151
private void compareDataSets(
5252
String identifier, ParsedAndroidData subject, ParsedAndroidData expected) {
53-
assertWithMessage("Overwriting " + identifier)
53+
assertWithMessage("Overwriting %s", identifier)
5454
.that(subject.getOverwritingResources())
5555
.containsExactlyEntriesIn(expected.getOverwritingResources());
56-
assertWithMessage("Combining " + identifier)
56+
assertWithMessage("Combining %s", identifier)
5757
.that(subject.getCombiningResources())
5858
.containsExactlyEntriesIn(expected.getCombiningResources());
59-
assertWithMessage("Assets " + identifier)
59+
assertWithMessage("Assets %s", identifier)
6060
.that(subject.getAssets())
6161
.containsExactlyEntriesIn(expected.getAssets());
6262
}

src/tools/javatests/com/google/devtools/build/android/ziputils/BufferedFileTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,24 +191,24 @@ void assertException(String msg, FileChannel file, long off, long len, int maxAl
191191
msg + " - no exception",
192192
Exception.class,
193193
() -> new BufferedFile(file, off, len, maxAlloc));
194-
assertWithMessage(msg + " - exception, ").that(expect).isSameInstanceAs(ex.getClass());
194+
assertWithMessage("%s - exception, ", msg).that(expect).isSameInstanceAs(ex.getClass());
195195
}
196196

197197
void assertException(String msg, BufferedFile instance, long off, int len, Class<?> expect) {
198198
Exception ex =
199199
assertThrows(msg + " - no exception", Exception.class, () -> instance.getBuffer(off, len));
200-
assertWithMessage(msg + " - exception, ").that(expect).isSameInstanceAs(ex.getClass());
200+
assertWithMessage("%s - exception, ", msg).that(expect).isSameInstanceAs(ex.getClass());
201201
}
202202

203203
void assertCase(String msg, BufferedFile instance, long off, int len, int expectLimit,
204204
int capacityBound) throws IOException {
205205
ByteBuffer buf = instance.getBuffer(off, len);
206-
assertWithMessage(msg + " - position, ").that(0).isEqualTo(buf.position());
207-
assertWithMessage(msg + " - limit, ").that(expectLimit).isEqualTo(buf.limit());
208-
assertWithMessage(msg + " - capacity, ").that(buf.capacity()).isAtLeast(expectLimit);
209-
assertWithMessage(msg + " - capacity, ").that(buf.capacity()).isAtMost(capacityBound);
206+
assertWithMessage("%s - position, ", msg).that(0).isEqualTo(buf.position());
207+
assertWithMessage("%s - limit, ", msg).that(expectLimit).isEqualTo(buf.limit());
208+
assertWithMessage("%s - capacity, ", msg).that(buf.capacity()).isAtLeast(expectLimit);
209+
assertWithMessage("%s - capacity, ", msg).that(buf.capacity()).isAtMost(capacityBound);
210210
if (len > 0 && expectLimit > 0) {
211-
assertWithMessage(msg + " - value, ").that(buf.get(0)).isEqualTo((byte) off);
211+
assertWithMessage("%s - value, ", msg).that(buf.get(0)).isEqualTo((byte) off);
212212
}
213213
}
214214

src/tools/javatests/com/google/devtools/build/android/ziputils/DataDescriptorTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ public void testViewOf() {
4949
int expSize = marker == DataDescriptor.SIGNATURE ? ZipInputStream.EXTHDR
5050
: ZipInputStream.EXTHDR - 4;
5151
int expPos = 0;
52-
assertWithMessage("not based at current position[" + marker + "]")
52+
assertWithMessage("not based at current position[%s]", marker)
5353
.that(view.get(EXTSIG))
5454
.isEqualTo(expMark);
55-
assertWithMessage("Not slice with position 0[" + marker + "]")
55+
assertWithMessage("Not slice with position 0[%s]", marker)
5656
.that(view.buffer.position())
5757
.isEqualTo(expPos);
58-
assertWithMessage("Not sized with comment[" + marker + "]")
58+
assertWithMessage("Not sized with comment[%s]", marker)
5959
.that(view.getSize())
6060
.isEqualTo(expSize);
61-
assertWithMessage("Not limited to size[" + marker + "]")
61+
assertWithMessage("Not limited to size[%s]", marker)
6262
.that(view.buffer.limit())
6363
.isEqualTo(expSize);
6464
}

src/tools/javatests/com/google/devtools/build/android/ziputils/ScanUtilTest.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void testScanBackwardsTo() {
7979

8080
private void assertLocation(byte[] target, byte[] domain, int expected) {
8181
int pos = ScanUtil.scanTo(target, domain != null ? ByteBuffer.wrap(domain) : null);
82-
assertWithMessage("Position of " + Arrays.toString(target) + " in " + Arrays.toString(domain))
82+
assertWithMessage("Position of %s in %s", Arrays.toString(target), Arrays.toString(domain))
8383
.that(pos)
8484
.isEqualTo(expected);
8585
}
@@ -92,14 +92,8 @@ private void assertBackwardsLocation(byte[] target, byte[] domain, int expected)
9292
}
9393
int pos = ScanUtil.scanBackwardsTo(target, buf);
9494
assertWithMessage(
95-
"Position of "
96-
+ Arrays.toString(target)
97-
+ " in "
98-
+ Arrays.toString(domain)
99-
+ ", "
100-
+ buf.position()
101-
+ ", "
102-
+ buf.limit())
95+
"Position of %s in %s, %s, %s",
96+
Arrays.toString(target), Arrays.toString(domain), buf.position(), buf.limit())
10397
.that(pos)
10498
.isEqualTo(expected);
10599
}

src/tools/javatests/com/google/devtools/build/android/ziputils/SplitterTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ private void assertMaintainOrder(Collection<String> input, Map<String, Integer>
262262
*/
263263
private void assertNoSplit(String name, int packageSize, int[] counts) {
264264
for (int i = 1; i < counts.length; i++) {
265-
assertWithMessage(name + " shard " + i).that(counts[i]).isAtLeast(0);
265+
assertWithMessage("%s shard %s", name, i).that(counts[i]).isAtLeast(0);
266266
}
267267
}
268268

@@ -274,7 +274,7 @@ private void assertHasSplit(String name, int packageSize, int[] counts) {
274274
if (counts[i + 1] <= 1) {
275275
continue;
276276
}
277-
assertWithMessage(name + " shard " + i).that(counts[i]).isAtMost(packageSize);
277+
assertWithMessage("%s shard %s", name, i).that(counts[i]).isAtMost(packageSize);
278278
}
279279
}
280280

@@ -310,25 +310,25 @@ private void assertBalanced(String name, int shards, int packageCount, int packa
310310
if (i < shards && counts[i + 1] > 1) {
311311
if (shards <= packageCount) {
312312
// if there are fewer shards than packages, expect shards contain at least 1 full package
313-
assertWithMessage(name + " dense shard " + i)
313+
assertWithMessage("%s dense shard %s", name, i)
314314
.that(counts[i])
315315
.isIn(Range.closed(packageSize, entries));
316316
} else {
317-
assertWithMessage(name + " sparse shard " + i)
317+
assertWithMessage("%s sparse shard %s", name, i)
318318
.that(counts[i])
319319
.isIn(Range.closed(0, packageSize));
320320
}
321321
if (noneClass == 0 && counts[0] == 0) {
322322
// Give some slack in minimal number of entries in a shard because Splitter recomputes
323323
// boundaries for each shard, so our computed bounds can be off for later shards.
324-
assertWithMessage(name + " shard " + i)
324+
assertWithMessage("%s shard %s", name, i)
325325
.that(counts[i])
326326
.isIn(Range.closed(lowerBound - i, entries));
327327
}
328328
}
329329
// Give some slack in maximum number of entries in a shard because Splitter recomputes
330330
// boundaries for each shard, so our computed bounds can be off for later shards.
331-
assertWithMessage(name + " shard " + i).that(adjusted).isAtMost(upperBound + i);
331+
assertWithMessage("%s shard %s", name, i).that(adjusted).isAtMost(upperBound + i);
332332
}
333333
}
334334

src/tools/javatests/com/google/devtools/build/android/ziputils/ZipInTest.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void testEndOfCentralDirectory_found() throws Exception {
7373
fileSystem.addFile(filename, bytes);
7474
ZipIn zipIn = newZipIn(filename);
7575
EndOfCentralDirectory result = zipIn.endOfCentralDirectory();
76-
assertWithMessage(subcase + "found").that(result).isNotNull();
76+
assertWithMessage("%sfound", subcase).that(result).isNotNull();
7777
}
7878

7979
@Test
@@ -100,7 +100,7 @@ public void testEndOfCentralDirectory_notPresent() throws Exception {
100100
subcase + "expected IllegalStateException",
101101
Exception.class,
102102
() -> zipIn.endOfCentralDirectory());
103-
assertWithMessage(subcase + "caught exception")
103+
assertWithMessage("%scaught exception", subcase)
104104
.that(ex.getClass())
105105
.isSameInstanceAs(IllegalStateException.class);
106106
}
@@ -130,7 +130,7 @@ public void testEndOfCentralDirectory_tooLateToRead() throws Exception {
130130
subcase + "expected IndexOutOfBoundsException",
131131
Exception.class,
132132
() -> zipIn.endOfCentralDirectory());
133-
assertWithMessage(subcase + "caught exception")
133+
assertWithMessage("%scaught exception", subcase)
134134
.that(ex.getClass())
135135
.isSameInstanceAs(IndexOutOfBoundsException.class);
136136
}
@@ -161,7 +161,7 @@ public void testEndOfCentralDirectory_goodHidenByBad() throws Exception {
161161
subcase + "expected IndexOutOfBoundsException",
162162
Exception.class,
163163
() -> zipIn.endOfCentralDirectory());
164-
assertWithMessage(subcase + "caught exception")
164+
assertWithMessage("%scaught exception", subcase)
165165
.that(ex.getClass())
166166
.isSameInstanceAs(IndexOutOfBoundsException.class);
167167
}
@@ -188,7 +188,7 @@ public void testEndOfCentralDirectory_truncatedComment() throws Exception {
188188
subcase + "expected IllegalArgumentException",
189189
Exception.class,
190190
() -> zipIn.endOfCentralDirectory());
191-
assertWithMessage(subcase + "caught exception")
191+
assertWithMessage("%scaught exception", subcase)
192192
.that(ex.getClass())
193193
.isSameInstanceAs(IllegalArgumentException.class);
194194
}
@@ -207,9 +207,9 @@ public void testEndOfCentralDirectory_noComment() throws Exception {
207207
fileSystem.addFile(filename, bytes);
208208
ZipIn zipIn = newZipIn(filename);
209209
EndOfCentralDirectory result = zipIn.endOfCentralDirectory();
210-
assertWithMessage(subcase + "found").that(result).isNotNull();
211-
assertWithMessage(subcase + "comment").that(result.getComment()).isEqualTo("");
212-
assertWithMessage(subcase + "marker")
210+
assertWithMessage("%sfound", subcase).that(result).isNotNull();
211+
assertWithMessage("%scomment", subcase).that(result.getComment()).isEqualTo("");
212+
assertWithMessage("%smarker", subcase)
213213
.that((int) result.get(ENDSIG))
214214
.isEqualTo(ZipInputStream.ENDSIG);
215215
}
@@ -225,15 +225,15 @@ public void testEndOfCentralDirectory_comment() throws Exception {
225225
int offset = bytes.length - ZipInputStream.ENDHDR - commentLen;
226226
buffer.position(offset);
227227
EndOfCentralDirectory.view(buffer, comment);
228-
assertWithMessage(subcase + "setup")
228+
assertWithMessage("%ssetup", subcase)
229229
.that(new String(bytes, bytes.length - commentLen, commentLen, UTF_8))
230230
.isEqualTo(comment);
231231
fileSystem.addFile(filename, bytes);
232232
ZipIn zipIn = newZipIn(filename);
233233
EndOfCentralDirectory result = zipIn.endOfCentralDirectory();
234-
assertWithMessage(subcase + "found").that(result).isNotNull();
235-
assertWithMessage(subcase + "comment").that(result.getComment()).isEqualTo(comment);
236-
assertWithMessage(subcase + "marker")
234+
assertWithMessage("%sfound", subcase).that(result).isNotNull();
235+
assertWithMessage("%scomment", subcase).that(result.getComment()).isEqualTo(comment);
236+
assertWithMessage("%smarker", subcase)
237237
.that((int) result.get(ENDSIG))
238238
.isEqualTo(ZipInputStream.ENDSIG);
239239
}
@@ -253,9 +253,9 @@ public void testEndOfCentralDirectory_extraData() throws Exception {
253253
fileSystem.addFile(filename, bytes);
254254
ZipIn zipIn = newZipIn(filename);
255255
EndOfCentralDirectory result = zipIn.endOfCentralDirectory();
256-
assertWithMessage(subcase + "found").that(result).isNotNull();
257-
assertWithMessage(subcase + "comment").that(result.getComment()).isEqualTo("");
258-
assertWithMessage(subcase + "marker")
256+
assertWithMessage("%sfound", subcase).that(result).isNotNull();
257+
assertWithMessage("%scomment", subcase).that(result.getComment()).isEqualTo("");
258+
assertWithMessage("%smarker", subcase)
259259
.that((int) result.get(ENDSIG))
260260
.isEqualTo(ZipInputStream.ENDSIG);
261261
}
@@ -307,11 +307,11 @@ public void testCentralDirectory() throws Exception {
307307
fileSystem.addFile(filename, bytes);
308308
zipIn = newZipIn(filename);
309309
CentralDirectory result = zipIn.centralDirectory();
310-
assertWithMessage(subcase + "found").that(result).isNotNull();
310+
assertWithMessage("%sfound", subcase).that(result).isNotNull();
311311
List<DirectoryEntry> list = result.list();
312-
assertWithMessage(subcase + "size").that(list.size()).isEqualTo(count);
312+
assertWithMessage("%ssize", subcase).that(list.size()).isEqualTo(count);
313313
for (int i = 0; i < list.size(); i++) {
314-
assertWithMessage(subcase + "offset check[" + i + "]")
314+
assertWithMessage("%soffset check[%s]", subcase, i)
315315
.that(list.get(i).get(CENOFF))
316316
.isEqualTo(i);
317317
}

0 commit comments

Comments
 (0)