Skip to content

Commit b2ffcfe

Browse files
committed
Tweaks.
1 parent 638c6e8 commit b2ffcfe

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ public void usageExample() {
3232
compressor.throwException = true;
3333
// Compressor overwrites the original string ("inputStr") to reduce memory usage.
3434
// Set to true to prevent this. Default is false.
35-
compressor.preserveOriginal = false;
35+
compressor.preserveOriginal = true;
3636

3737
byte[] compressed = compressor.compress(inputStr);
3838
byte[] decompressed = compressor.decompress(compressed);
3939

4040
assertEquals("HELLO-COMPRESSOR", new String(decompressed, US_ASCII));
41+
assertArrayEquals(inputStr, decompressed); // If preserveOriginal is false, this will fail because inputStr has been modified.
4142
}
4243

4344
@Test

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ public void usageExample() {
3232
compressor.throwException = true;
3333
// Compressor overwrites the original string ("inputStr") to reduce memory usage.
3434
// Set to true to prevent this. Default is false.
35-
compressor.preserveOriginal = false;
35+
compressor.preserveOriginal = true;
3636

3737
byte[] compressed = compressor.compress(inputStr);
3838
byte[] decompressed = compressor.decompress(compressed);
3939

4040
assertEquals("0123456789", new String(decompressed, US_ASCII));
41+
assertArrayEquals(inputStr, decompressed); // If preserveOriginal is false, this will fail because inputStr has been modified.
4142
}
4243

4344
@Test

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ public void usageExample() {
3232
compressor.throwException = true;
3333
// Compressor overwrites the original string ("inputStr") to reduce memory usage.
3434
// Set to true to prevent this. Default is false.
35-
compressor.preserveOriginal = false;
35+
compressor.preserveOriginal = true;
3636

3737
byte[] compressed = compressor.compress(inputStr);
3838
byte[] decompressed = compressor.decompress(compressed);
3939

4040
assertEquals("HELLO, COMPRESSOR", new String(decompressed, US_ASCII));
41+
assertArrayEquals(inputStr, decompressed); // If preserveOriginal is false, this will fail because inputStr has been modified.
4142
}
4243

4344
@Test

0 commit comments

Comments
 (0)