-
Notifications
You must be signed in to change notification settings - Fork 12
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
Showing
6 changed files
with
131 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#Tue Aug 16 15:42:19 EDT 2016 | ||
#Tue Aug 16 18:32:29 EDT 2016 | ||
BUILD_VERSION=1.1.0 | ||
BUILD_DATE=2016-08-16T19\:42\:19Z | ||
BUILD_NUMBER=518 | ||
BUILD_DATE=2016-08-16T22\:32\:29Z | ||
BUILD_NUMBER=556 |
65 changes: 65 additions & 0 deletions
65
src/test/java/me/doubledutch/lazyjson/compressor/CompressionTest.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,65 @@ | ||
package me.doubledutch.lazyjson.compressor; | ||
|
||
import java.io.File; | ||
import org.junit.*; | ||
import static org.junit.Assert.*; | ||
import java.util.List; | ||
import java.util.ArrayList; | ||
import java.net.*; | ||
import java.nio.ByteBuffer; | ||
|
||
import me.doubledutch.lazyjson.*; | ||
|
||
|
||
public class CompressionTest{ | ||
@Test | ||
public void testInOut() throws Exception{ | ||
String str="{\"foo\":42}"; | ||
Compressor c=new Compressor("./ctest",1000,0); | ||
byte[] out=c.compress(str); | ||
// System.out.println(out.length+" vs "+str.length()); | ||
String str2=c.decompress(out); | ||
assertEquals(str,str2); | ||
} | ||
|
||
@Test | ||
public void testSet() throws Exception{ | ||
Compressor c=new Compressor("./ctest",1000,3); | ||
List<byte[]> list=new ArrayList<byte[]>(); | ||
for(int i=0;i<100;i++){ | ||
String str="{\"foo\":"+i+"}"; | ||
list.add(c.compress(str)); | ||
} | ||
for(int i=0;i<100;i++){ | ||
String str=c.decompress(list.get(i)); | ||
LazyObject obj=new LazyObject(str); | ||
assertEquals(i,obj.getInt("foo")); | ||
} | ||
} | ||
|
||
@Test | ||
public void testBadCompression() throws Exception{ | ||
String str="{\"foo\":[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]}"; | ||
Compressor c=new Compressor("./ctest",1000,0); | ||
byte[] out=c.compress(str); | ||
// System.out.println(out.length+" vs "+str.length()); | ||
String str2=c.decompress(out); | ||
assertEquals(str,str2); | ||
} | ||
|
||
@Test | ||
public void testCommitAndReload() throws Exception{ | ||
String str="{\"foo\":42,\"bar\":\"Hello World!\"}"; | ||
Compressor c=new Compressor("./ctest",10,0); | ||
byte[] out=c.compress(str); | ||
c.commit(); | ||
c=new Compressor("./ctest",10,0); | ||
// System.out.println(out.length+" vs "+str.length()); | ||
String str2=c.decompress(out); | ||
assertEquals(str,str2); | ||
File ftest=new File("./ctest.templates"); | ||
ftest.delete(); | ||
ftest=new File("./ctest.dictionary"); | ||
ftest.delete(); | ||
} | ||
} |
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