### Question:
RateLimitedLogger { @VisibleForTesting static @Nullable Object[] newArgsWithCountSinceLastWarning( Object[] args, int countSinceLastWarning) { if (args.length == 0) { return new Object[] {countSinceLastWarning}; } @Nullable Object[] argsPlus = new Object[args.length + 1]; if (args[args.length - 1] instanceof Throwable) { System.arraycopy(args, 0, argsPlus, 0, args.length - 1); argsPlus[args.length - 1] = countSinceLastWarning; argsPlus[args.length] = args[args.length - 1]; return argsPlus; } else { System.arraycopy(args, 0, argsPlus, 0, args.length); argsPlus[args.length] = countSinceLastWarning; return argsPlus; } } RateLimitedLogger(Class<?> clazz);  RateLimitedLogger(Class<?> clazz, boolean willKeepTrying); void warn(String format, /*@Nullable*/ Object... args);  }### Answer:
@Test public void testEmpty() { Object[] args = RateLimitedLogger.newArgsWithCountSinceLastWarning(new Object[] {}, 0); assertThat(args).containsExactly(0); }
@Test public void testSingle() { Object[] args = RateLimitedLogger.newArgsWithCountSinceLastWarning(new Object[] {1}, 0); assertThat(args).containsExactly(1, 0); }
@Test public void testSingleException() { Exception exception = new Exception(); Object[] args = RateLimitedLogger.newArgsWithCountSinceLastWarning(new Object[] {exception}, 0); assertThat(args).containsExactly(0, exception); }
@Test public void testMultiple() { Object[] args = RateLimitedLogger.newArgsWithCountSinceLastWarning(new Object[] {1, 2}, 0); assertThat(args).containsExactly(1, 2, 0); }
@Test public void testMultipleException() { Exception exception = new Exception(); Object[] args = RateLimitedLogger.newArgsWithCountSinceLastWarning(new Object[] {1, exception}, 0); assertThat(args).containsExactly(1, 0, exception); }