Examples of PrefixHash


Examples of org.toubassi.femtozip.substring.PrefixHash

    @Test
    public void testPrefixHash() throws IOException {
        String str = "a man a clan a canal panama";
        byte[] bytes = str.getBytes("UTF-8");
       
        PrefixHash hash = new PrefixHash(bytes, false);
        for (int i = 0; i < 12; i++) {
            hash.put(i);
        }
       
        Match match = hash.getBestMatch(12, bytes);
       
        Assert.assertEquals(5, match.bestMatchIndex);
        Assert.assertEquals(4, match.bestMatchLength);
    }
View Full Code Here

Examples of org.toubassi.femtozip.substring.PrefixHash

    @Test
    public void testPrefixHashWithTargetBuf() throws IOException {
        String str = "a man a clan a canal panama";
        byte[] bytes = str.getBytes("UTF-8");
       
        PrefixHash hash = new PrefixHash(bytes, true);       
       
        String target = "xxx a ca";
        byte[] targetBytes = target.getBytes("UTF-8");       
        Match match = hash.getBestMatch(3, targetBytes);
       
        Assert.assertEquals(12, match.bestMatchIndex);
        Assert.assertEquals(5, match.bestMatchLength);
    }
View Full Code Here

Examples of org.toubassi.femtozip.substring.PrefixHash

    @Test
    public void testMatchMiss() throws IOException {
        String str = "a man a clan a canal panama";
        byte[] bytes = str.getBytes("UTF-8");
       
        PrefixHash hash = new PrefixHash(bytes, true);       
       
        String target = "blah!";
        byte[] targetBytes = target.getBytes("UTF-8");       
        Match match = hash.getBestMatch(0, targetBytes);
       
        Assert.assertEquals(0, match.bestMatchIndex);
        Assert.assertEquals(0, match.bestMatchLength);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.