@@ -0,0 +1,2047 @@
+/*%0A * Copyright (C) 2012 Fabian Hirschmann %3Cfabian@hirschm.net%3E%0A *%0A * This program is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU General Public License%0A * as published by the Free Software Foundation; either version 2%0A * of the License, or (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU General Public License for more details.%0A *%0A * You should have received a copy of the GNU General Public License%0A * along with this program; if not, write to the Free Software%0A * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.%0A */%0Apackage com.github.fhirschmann.clozegen.lib.frequency;%0A%0Aimport com.google.common.collect.Lists;%0Aimport java.util.List;%0Aimport junit.framework.TestCase;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0A/**%0A *%0A * @author Fabian Hirschmann %3Cfabian@hirschm.net%3E%0A */%0Apublic class FrequencyStructureTest extends TestCase %7B%0A    private FrequencyStructure%3CString%3E fs;%0A    private List%3CFrequencyPair%3CString%3E%3E fplist;%0A%0A    private final static String%5B%5D WORDS = new%0A            String%5B%5D %7B%22why%22, %22are%22, %22you%22, %22reading%22, %22this%22%7D;%0A%0A    @Before%0A    public void setUp() %7B%0A        fs = new FrequencyStructure%3CString%3E();%0A        fplist = Lists.newLinkedList();%0A%0A        for (int i=0; i%3C WORDS.length; i++) %7B%0A            fs.add(WORDS%5Bi%5D, i);%0A            fplist.add(new FrequencyPair%3CString%3E(WORDS%5Bi%5D, i));%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void testGetFrequency() %7B%0A        for (int i=0; i%3C WORDS.length; i++) %7B%0A            assertEquals(i, fs.getFrequency(WORDS%5Bi%5D));%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void testZeroFrequency() %7B%0A        assertEquals(0, fs.getFrequency(%22---%22));%0A    %7D%0A%0A    @Test%0A    public void testGetAdjacentTo() %7B%0A        assertEquals(fplist.subList(1, 4), fs.getAdjacentTo(%22you%22, 1));%0A        assertEquals(fplist, fs.getAdjacentTo(%22you%22, 2));%0A    %7D%0A%7D%0A

Test FrequencyStructure