Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions guava-tests/test/com/google/common/primitives/BooleansTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,19 @@ public void testRotate_multiElementArray() {
new boolean[] {true, true, false, true, false});
}

public void testRotate_minValueDistance() {
testRotate(
new boolean[] {true, false, false},
Integer.MIN_VALUE,
new boolean[] {false, true, false});
testRotate(
new boolean[] {false, true, false, false, true},
Integer.MIN_VALUE,
1,
4,
new boolean[] {false, false, true, false, true});
}

public void testRotateIndexed_emptyRange() {
boolean[] empty = {};
boolean[] expectedEmpty = {};
Expand Down
10 changes: 10 additions & 0 deletions guava-tests/test/com/google/common/primitives/BytesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,16 @@ public void testRotate_multiElementArray() {
testRotate(new byte[] {1, 2, 3, 4, 5}, 6, new byte[] {5, 1, 2, 3, 4});
}

public void testRotate_minValueDistance() {
testRotate(new byte[] {1, 2, 3}, Integer.MIN_VALUE, new byte[] {3, 1, 2});
testRotate(
new byte[] {0, 1, 2, 3, 4},
Integer.MIN_VALUE,
1,
4,
new byte[] {0, 3, 1, 2, 4});
}

public void testRotateIndexed_emptyRange() {
byte[] empty = {};
byte[] expectedEmpty = {};
Expand Down
10 changes: 10 additions & 0 deletions guava-tests/test/com/google/common/primitives/CharsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,16 @@ public void testRotate_multiElementArray() {
testRotate(new char[] {'1', '2', '3', '4', '5'}, 6, new char[] {'5', '1', '2', '3', '4'});
}

public void testRotate_minValueDistance() {
testRotate(new char[] {'1', '2', '3'}, Integer.MIN_VALUE, new char[] {'3', '1', '2'});
testRotate(
new char[] {'0', '1', '2', '3', '4'},
Integer.MIN_VALUE,
1,
4,
new char[] {'0', '3', '1', '2', '4'});
}

public void testRotateIndexed_emptyRange() {
char[] empty = {};
char[] expectedEmpty = {};
Expand Down
10 changes: 10 additions & 0 deletions guava-tests/test/com/google/common/primitives/DoublesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,16 @@ public void testRotate_multiElementArray() {
testRotate(new double[] {1, 2, 3, 4, 5}, 6, new double[] {5, 1, 2, 3, 4});
}

public void testRotate_minValueDistance() {
testRotate(new double[] {1, 2, 3}, Integer.MIN_VALUE, new double[] {3, 1, 2});
testRotate(
new double[] {0, 1, 2, 3, 4},
Integer.MIN_VALUE,
1,
4,
new double[] {0, 3, 1, 2, 4});
}

public void testRotateIndexed_emptyRange() {
double[] empty = {};
double[] expectedEmpty = {};
Expand Down
10 changes: 10 additions & 0 deletions guava-tests/test/com/google/common/primitives/FloatsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,16 @@ public void testRotate_multiElementArray() {
testRotate(new float[] {1, 2, 3, 4, 5}, 6, new float[] {5, 1, 2, 3, 4});
}

public void testRotate_minValueDistance() {
testRotate(new float[] {1, 2, 3}, Integer.MIN_VALUE, new float[] {3, 1, 2});
testRotate(
new float[] {0, 1, 2, 3, 4},
Integer.MIN_VALUE,
1,
4,
new float[] {0, 3, 1, 2, 4});
}

public void testRotateIndexed_emptyRange() {
float[] empty = {};
float[] expectedEmpty = {};
Expand Down
10 changes: 10 additions & 0 deletions guava-tests/test/com/google/common/primitives/IntsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,16 @@ public void testRotate_multiElementArray() {
testRotate(new int[] {1, 2, 3, 4, 5}, 6, new int[] {5, 1, 2, 3, 4});
}

public void testRotate_minValueDistance() {
testRotate(new int[] {1, 2, 3}, Integer.MIN_VALUE, new int[] {3, 1, 2});
testRotate(
new int[] {0, 1, 2, 3, 4},
Integer.MIN_VALUE,
1,
4,
new int[] {0, 3, 1, 2, 4});
}

public void testRotateIndexed_emptyRange() {
int[] empty = {};
int[] expectedEmpty = {};
Expand Down
10 changes: 10 additions & 0 deletions guava-tests/test/com/google/common/primitives/LongsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,16 @@ public void testRotate_multiElementArray() {
testRotate(new long[] {1, 2, 3, 4, 5}, 6, new long[] {5, 1, 2, 3, 4});
}

public void testRotate_minValueDistance() {
testRotate(new long[] {1, 2, 3}, Integer.MIN_VALUE, new long[] {3, 1, 2});
testRotate(
new long[] {0, 1, 2, 3, 4},
Integer.MIN_VALUE,
1,
4,
new long[] {0, 3, 1, 2, 4});
}

public void testRotateIndexed_emptyRange() {
long[] empty = {};
long[] expectedEmpty = {};
Expand Down
10 changes: 10 additions & 0 deletions guava-tests/test/com/google/common/primitives/ShortsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,16 @@ public void testRotate_multiElementArray() {
testRotate(new short[] {1, 2, 3, 4, 5}, 6, new short[] {5, 1, 2, 3, 4});
}

public void testRotate_minValueDistance() {
testRotate(new short[] {1, 2, 3}, Integer.MIN_VALUE, new short[] {3, 1, 2});
testRotate(
new short[] {0, 1, 2, 3, 4},
Integer.MIN_VALUE,
1,
4,
new short[] {0, 3, 1, 2, 4});
}

public void testRotateIndexed_emptyRange() {
short[] empty = {};
short[] expectedEmpty = {};
Expand Down
2 changes: 1 addition & 1 deletion guava/src/com/google/common/primitives/Booleans.java
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ public static void rotate(boolean[] array, int distance, int fromIndex, int toIn

// Obtain m = (-distance mod length), a non-negative value less than "length". This is how many
// places left to rotate.
int m = -distance % length;
int m = -(distance % length);
m = (m < 0) ? m + length : m;
// The current index of what will become the first element of the rotated section.
int newFirstIndex = m + fromIndex;
Expand Down
2 changes: 1 addition & 1 deletion guava/src/com/google/common/primitives/Bytes.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public static void rotate(byte[] array, int distance, int fromIndex, int toIndex

// Obtain m = (-distance mod length), a non-negative value less than "length". This is how many
// places left to rotate.
int m = -distance % length;
int m = -(distance % length);
m = (m < 0) ? m + length : m;
// The current index of what will become the first element of the rotated section.
int newFirstIndex = m + fromIndex;
Expand Down
2 changes: 1 addition & 1 deletion guava/src/com/google/common/primitives/Chars.java
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ public static void rotate(char[] array, int distance, int fromIndex, int toIndex

// Obtain m = (-distance mod length), a non-negative value less than "length". This is how many
// places left to rotate.
int m = -distance % length;
int m = -(distance % length);
m = (m < 0) ? m + length : m;
// The current index of what will become the first element of the rotated section.
int newFirstIndex = m + fromIndex;
Expand Down
2 changes: 1 addition & 1 deletion guava/src/com/google/common/primitives/Doubles.java
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public static void rotate(double[] array, int distance, int fromIndex, int toInd

// Obtain m = (-distance mod length), a non-negative value less than "length". This is how many
// places left to rotate.
int m = -distance % length;
int m = -(distance % length);
m = (m < 0) ? m + length : m;
// The current index of what will become the first element of the rotated section.
int newFirstIndex = m + fromIndex;
Expand Down
2 changes: 1 addition & 1 deletion guava/src/com/google/common/primitives/Floats.java
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ public static void rotate(float[] array, int distance, int fromIndex, int toInde

// Obtain m = (-distance mod length), a non-negative value less than "length". This is how many
// places left to rotate.
int m = -distance % length;
int m = -(distance % length);
m = (m < 0) ? m + length : m;
// The current index of what will become the first element of the rotated section.
int newFirstIndex = m + fromIndex;
Expand Down
2 changes: 1 addition & 1 deletion guava/src/com/google/common/primitives/Ints.java
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ public static void rotate(int[] array, int distance, int fromIndex, int toIndex)

// Obtain m = (-distance mod length), a non-negative value less than "length". This is how many
// places left to rotate.
int m = -distance % length;
int m = -(distance % length);
m = (m < 0) ? m + length : m;
// The current index of what will become the first element of the rotated section.
int newFirstIndex = m + fromIndex;
Expand Down
2 changes: 1 addition & 1 deletion guava/src/com/google/common/primitives/Longs.java
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ public static void rotate(long[] array, int distance, int fromIndex, int toIndex

// Obtain m = (-distance mod length), a non-negative value less than "length". This is how many
// places left to rotate.
int m = -distance % length;
int m = -(distance % length);
m = (m < 0) ? m + length : m;
// The current index of what will become the first element of the rotated section.
int newFirstIndex = m + fromIndex;
Expand Down
2 changes: 1 addition & 1 deletion guava/src/com/google/common/primitives/Shorts.java
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public static void rotate(short[] array, int distance, int fromIndex, int toInde

// Obtain m = (-distance mod length), a non-negative value less than "length". This is how many
// places left to rotate.
int m = -distance % length;
int m = -(distance % length);
m = (m < 0) ? m + length : m;
// The current index of what will become the first element of the rotated section.
int newFirstIndex = m + fromIndex;
Expand Down
Loading