Skip to content

Commit 4480c79

Browse files
committed
Tweaks.
1 parent 0baa432 commit 4480c79

File tree

3 files changed

+10
-24
lines changed

3 files changed

+10
-24
lines changed

src/test/java/com/stringcompressor/FiveBitAsciiCompressorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void invalidCharCompressTest() {
7373
@Test
7474
public void compressDecompressTest() {
7575
AsciiCompressor compressor = new FiveBitAsciiCompressor();
76-
for (int length = 0; length <= 500; length++)
76+
for (int length = 0; length <= 1000; length++)
7777
for (int i = 0; i <= 50000; i++) {
7878
String str = createRandomString(length, DEFAULT_5BIT_CHARSET);
7979
byte[] compressed = compressor.compress(str.getBytes(US_ASCII));

src/test/java/com/stringcompressor/FourBitAsciiCompressorTest.java

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,16 @@ public void invalidCharCompressTest() {
6262
assertEquals("Character 'Z' (code point 90) is not defined in the supported characters array. String: \"Z\"", e.getMessage());
6363
}
6464

65-
@Test
66-
public void compressDecompressEdgeCasesTest() {
67-
doCompressDecompressTest("");
68-
doCompressDecompressTest(new String(new byte[]{DEFAULT_4BIT_CHARSET[0]}, US_ASCII));
69-
doCompressDecompressTest(new String(new byte[]{DEFAULT_4BIT_CHARSET[0], DEFAULT_4BIT_CHARSET[1]}, US_ASCII));
70-
doCompressDecompressTest(new String(new byte[]{DEFAULT_4BIT_CHARSET[0], DEFAULT_4BIT_CHARSET[1], DEFAULT_4BIT_CHARSET[2]}, US_ASCII));
71-
doCompressDecompressTest(new String(new byte[]{DEFAULT_4BIT_CHARSET[DEFAULT_4BIT_CHARSET.length - 1]}, US_ASCII));
72-
doCompressDecompressTest(new String(DEFAULT_4BIT_CHARSET, US_ASCII));
73-
}
74-
7565
@Test
7666
public void compressDecompressTest() {
77-
for (int length = 0; length < 500; length++)
78-
for (int i = 0; i < 50000; i++)
79-
doCompressDecompressTest(createRandomString(length, DEFAULT_4BIT_CHARSET));
80-
}
81-
82-
private static void doCompressDecompressTest(String str) {
83-
AsciiCompressor compressor = new FourBitAsciiCompressor(true);
84-
byte[] compressed = compressor.compress(str.getBytes(US_ASCII));
85-
assertEquals(str.length() / 2 + (str.length() % 2 != 0 ? 2 : 1), compressed.length);
86-
byte[] decompressed = compressor.decompress(compressed);
87-
assertEquals(str.length(), decompressed.length);
88-
assertEquals(str, new String(decompressed, US_ASCII));
67+
AsciiCompressor compressor = new FourBitAsciiCompressor();
68+
for (int length = 0; length <= 1000; length++)
69+
for (int i = 0; i <= 50000; i++) {
70+
String str = createRandomString(length, DEFAULT_4BIT_CHARSET);
71+
byte[] compressed = compressor.compress(str.getBytes(US_ASCII));
72+
byte[] decompressed = compressor.decompress(compressed);
73+
assertEquals(str, new String(decompressed, US_ASCII));
74+
}
8975
}
9076

9177
@Test

src/test/java/com/stringcompressor/SixBitAsciiCompressorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void invalidCharCompressTest() {
7373
@Test
7474
public void compressDecompressTest() {
7575
AsciiCompressor compressor = new SixBitAsciiCompressor();
76-
for (int length = 0; length <= 500; length++)
76+
for (int length = 0; length <= 1000; length++)
7777
for (int i = 0; i <= 50000; i++) {
7878
String str = createRandomString(length, DEFAULT_6BIT_CHARSET);
7979
byte[] compressed = compressor.compress(str.getBytes(US_ASCII));

0 commit comments

Comments
 (0)