You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
etesync-android/app/src/test/java/at/bitfire/davdroid/ArrayUtilsTest.java

43 lines
1.2 KiB

/*
* Copyright © 2013 2015 Ricki Hirner (bitfire web engineering).
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*/
package at.bitfire.davdroid;
import org.junit.Test;
import java.util.Arrays;
8 years ago
import static org.junit.Assert.assertTrue;
public class ArrayUtilsTest {
@Test
public void testPartition() {
// n == 0
8 years ago
assertTrue(Arrays.deepEquals(
new Long[0][0],
ArrayUtils.partition(new Long[] {}, 5)));
// n < max
8 years ago
assertTrue(Arrays.deepEquals(
new Long[][] { { 1l, 2l } },
ArrayUtils.partition(new Long[] { 1l, 2l }, 5)));
// n == max
8 years ago
assertTrue(Arrays.deepEquals(
new Long[][] { { 1l, 2l }, { 3l, 4l } },
ArrayUtils.partition(new Long[] { 1l, 2l, 3l, 4l }, 2)));
// n > max
8 years ago
assertTrue(Arrays.deepEquals(
new Long[][] { { 1l, 2l, 3l, 4l, 5l }, { 6l, 7l, 8l, 9l, 10l }, { 11l } },
ArrayUtils.partition(new Long[] { 1l, 2l, 3l, 4l, 5l, 6l, 7l, 8l, 9l, 10l, 11l }, 5)));
}
}