@@ -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
0 commit comments