import org.junit.Test;

import java.util.Map;
import java.util.TreeMap;

import static org.junit.Assert.*;

public class StringReductionTest {
    Map<String, Integer> m = new TreeMap<String, Integer>();

    Map<String, Integer> e1 = new TreeMap<String, Integer>();
    public StringReductionTest() {
        m.put("this is a test", 6);
        m.put("is a test", 6);
        m.put("this is a", 6);

        e1.put("this is a test", 6);
    }
    @Test
    public void reduce() throws Exception {
        Map<String, Integer> res = StringReduction.reduce(m, 5);
        assert(res.toString().equals(e1.toString()));
    }

}
@@ -1,12 +1,1143 @@
+/*%0A * Copyright 2016 Jim O'Regan %3Cjaoregan@tcd.ie%3E%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining a%0A * copy of this software and associated documentation files (the %22Software%22),%0A * to deal in the Software without restriction, including without limitation%0A * the rights to use, copy, modify, merge, publish, distribute, sublicense,%0A * and/or sell copies of the Software, and to permit persons to whom the%0A * Software is furnished to do so, subject to the following conditions:%0A *%0A * The above copyright notice and this permission notice shall be included in%0A * all copies or substantial portions of the Software.%0A *%0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL%0A * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING%0A * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER%0A * DEALINGS IN THE SOFTWARE.%0A */%0A
 import org.j
@@ -1293,16 +1293,17 @@
 teger%3E m
+1
  = new T
@@ -1329,17 +1329,16 @@
 ger%3E();%0A
-%0A
     Map%3C
@@ -1387,24 +1387,149 @@
 Integer%3E();%0A
+    Map%3CString, Integer%3E m2 = new TreeMap%3CString, Integer%3E();%0A    Map%3CString, Integer%3E e2 = new TreeMap%3CString, Integer%3E();%0A%0A
     public S
@@ -1552,32 +1552,33 @@
 st() %7B%0A        m
+1
 .put(%22this is a 
@@ -1593,24 +1593,25 @@
 );%0A        m
+1
 .put(%22is a t
@@ -1629,16 +1629,17 @@
        m
+1
 .put(%22th
@@ -1652,17 +1652,16 @@
 a%22, 6);%0A
-%0A
         
@@ -1684,24 +1684,195 @@
 a test%22, 6);
+%0A%0A        m2.put(%22this is a test%22, 6);%0A        m2.put(%22is a test%22, 8);%0A        m2.put(%22this is a%22, 2);%0A        e2.put(%22this is a test%22, 6);%0A        e2.put(%22is a test%22, 2);
 %0A    %7D%0A    @
@@ -1952,16 +1952,17 @@
 ger%3E res
+1
  = Strin
@@ -1980,16 +1980,17 @@
 reduce(m
+1
 , 5);%0A  
@@ -2005,16 +2005,17 @@
 sert(res
+1
 .toStrin
@@ -2042,16 +2042,212 @@
 ng()));%0A
+        //reduce1's algorithm seems to not reduce in the way I expect%0A        //Map%3CString, Integer%3E res2 = StringReduction.reduce(m2, 5);%0A        //assert(res2.toString().equals(e2.toString()));%0A
     %7D%0A%0A%7D

add commented test: reduce1 works in a weird way, I think