-
-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f46b4d5
commit b2e382a
Showing
6 changed files
with
105 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/test/java/com/fasterxml/jackson/core/io/NumberOutputTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.fasterxml.jackson.core.io; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class NumberOutputTest | ||
{ | ||
@Test | ||
public void testDivBy1000Small() | ||
{ | ||
for (int number = 0; number <= 999_999; ++number) { | ||
int expected = number / 1000; | ||
int actual = NumberOutput.divBy1000(number); | ||
if (expected != actual) { // only construct String if fail | ||
fail("With "+number+" should get "+expected+", got: "+actual); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void testDivBy1000Sampled() | ||
{ | ||
for (int number = 1_000_000; number > 0; number += 7) { | ||
int expected = number / 1000; | ||
int actual = NumberOutput.divBy1000(number); | ||
if (expected != actual) { // only construct String if fail | ||
fail("With "+number+" should get "+expected+", got: "+actual); | ||
} | ||
} | ||
} | ||
|
||
// And then full range, not included in CI since code shouldn't change; | ||
// but has been run to verify full range manually | ||
@Test | ||
// Comment out for manual testing: | ||
@Disabled | ||
public void testDivBy1000FullRange() { | ||
for (int number = 0; number <= Integer.MAX_VALUE; ++number) { | ||
int expected = number / 1000; | ||
int actual = NumberOutput.divBy1000(number); | ||
if (expected != actual) { // only construct String if fail | ||
fail("With "+number+" should get "+expected+", got: "+actual); | ||
} | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/test/java/com/fasterxml/jackson/core/sym/ByteQuadsCanonicalizerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.fasterxml.jackson.core.sym; | ||
|
||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class ByteQuadsCanonicalizerTest { | ||
@Test | ||
@Ignore | ||
public void testMultiplyByFourFifths() { | ||
for (long i = 0; i <= Integer.MAX_VALUE; i++) { | ||
int number = (int) i; | ||
int expected = (int) (number * 0.80); | ||
int actual = ByteQuadsCanonicalizer.multiplyByFourFifths(number); | ||
assertEquals("input=" + number, expected, actual); | ||
} | ||
} | ||
} |