Skip to content

Commit

Permalink
Bases that should be case-insensitive weren't; fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyettinger committed Oct 30, 2021
1 parent ba544be commit 8de0c52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public Base(@Nonnull String digits, boolean caseInsensitive, char padding, char
char to = toEncoded[i];
fromEncoded[to & 127] = i;
if (caseInsensitive)
fromEncoded[Character.toUpperCase(to) & 127] = i;
fromEncoded[Character.toLowerCase(to) & 127] = i;
}
double logBase = 1.0 / Math.log(base);
length1Byte = (int) Math.ceil(Math.log(0x1p8) * logBase);
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/com/github/tommyettinger/ds/test/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ public void testSignedLong() {
Assert.assertArrayEquals(b.longSplit(" " + b.join(" ", inputs), " ", 1, Integer.MAX_VALUE), inputs);
Assert.assertArrayEquals(b.longSplit2D(b.appendJoined2D(new StringBuilder(), ";", ",", inputs2D).toString(), ";", ","), inputs2D);
Assert.assertArrayEquals(b.longSplit2D(" " + b.appendJoined2D(new StringBuilder(), ";", ",", inputs2D), ";", ",", 1, Integer.MAX_VALUE), inputs2D);

if(b.base > 10 && b.base <= 36)
{
Assert.assertEquals(Long.parseLong("aaa", b.base), b.readLong("aaa"));
Assert.assertEquals(Long.parseLong("AAA", b.base), b.readLong("AAA"));
Assert.assertEquals(Long.parseLong("Aaa", b.base), b.readLong("Aaa"));
}
}
}

Expand Down

0 comments on commit 8de0c52

Please sign in to comment.