You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by aa...@apache.org on 2020/08/06 00:35:30 UTC
[hadoop] branch trunk updated: MAPREDUCE-7288. Fix
TestLongLong#testRightShift (#2183)
This is an automated email from the ASF dual-hosted git repository.
aajisaka pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new dc5470a MAPREDUCE-7288. Fix TestLongLong#testRightShift (#2183)
dc5470a is described below
commit dc5470ae86b96d6f84abd7354c3c056d3627871b
Author: Wanqiang Ji <ji...@apache.org>
AuthorDate: Thu Aug 6 08:35:15 2020 +0800
MAPREDUCE-7288. Fix TestLongLong#testRightShift (#2183)
---
.../hadoop/examples/pi/math/TestLongLong.java | 32 ++++++++++------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/pi/math/TestLongLong.java b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/pi/math/TestLongLong.java
index d6f284e..232c53f 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/pi/math/TestLongLong.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/pi/math/TestLongLong.java
@@ -53,32 +53,28 @@ public class TestLongLong {
verifyMultiplication(max, max);
}
- static void verifyRightShift(long a, long b) {
+ @Test
+ public void testRightShift() {
+ for(int i = 0; i < 1000; i++) {
+ final long a = nextPositiveLong();
+ final long b = nextPositiveLong();
+ verifyRightShift(a, b);
+ }
+ }
+
+ private static void verifyRightShift(long a, long b) {
final LongLong ll = new LongLong().set(a, b);
final BigInteger bi = ll.toBigInteger();
- for (int i = 0; i < LongLong.SIZE >> 1; i++) {
- final long result = ll.shiftRight(i) & MASK;
- final long expected = bi.shiftRight(i).longValue() & MASK;
- final String s = String.format(
- "\na = %x\nb = %x\nll= " + ll + "\nbi= " + bi.toString(16) + "\n", a,
- b);
- Assert.assertEquals(s, expected, result);
- }
-
final String s = String.format(
"\na = %x\nb = %x\nll= " + ll + "\nbi= " + bi.toString(16) + "\n", a,
b);
- //System.out.println(s);
Assert.assertEquals(s, bi, ll.toBigInteger());
- }
- @Test
- public void testRightShift() {
- for(int i = 0; i < 1000; i++) {
- final long a = nextPositiveLong();
- final long b = nextPositiveLong();
- verifyMultiplication(a, b);
+ for (int i = 0; i < LongLong.SIZE >> 1; i++) {
+ final long result = ll.shiftRight(i) & MASK;
+ final long expected = bi.shiftRight(i).longValue() & MASK;
+ Assert.assertEquals(s, expected, result);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org