package com.google.android.apps.paco;

import java.util.List;

import android.test.AndroidTestCase;

public class PersistentAutocompleteDictionaryTest extends AndroidTestCase {

  public void testSplitterForStorageEasyCase() {
    assertEquals(2, new PersistentAutocompleteDictionary(getContext()).splitOnLastColon("hello:1").size());
    assertEqualParts("hello", "1", new PersistentAutocompleteDictionary(getContext()).splitOnLastColon("hello:1"));
  }


  public void testSplitterForStorageWithColonInAutocompleteText() {
    assertEquals(2, new PersistentAutocompleteDictionary(getContext()).splitOnLastColon("hello:1").size());
    assertEqualParts("list of stuff:one, two, three", "1", new PersistentAutocompleteDictionary(getContext()).splitOnLastColon("list of stuff:one, two, three:1"));
  }

  private void assertEqualParts(String expectedAutocompleteword, String expectedFrequency, List<String> splitOnLastColon) {
    assertEquals(expectedAutocompleteword, splitOnLastColon.get(0));
    assertEquals(expectedFrequency, splitOnLastColon.get(1));
  }

}

@@ -220,39 +220,56 @@
 ase() %7B%0A    
-assertEquals(2,
+List%3CString%3E autocompleteEntry =
  new Persist
@@ -327,32 +327,71 @@
 Colon(%22hello:1%22)
+;%0A    assertEquals(2, autocompleteEntry
 .size());%0A    as
@@ -423,86 +423,25 @@
 1%22, 
-new PersistentAutocompleteDictionary(getContext()).splitOnLastColon(%22hello:1%22)
+autocompleteEntry
 );%0A 
@@ -517,31 +517,48 @@
 ) %7B%0A    
-assertEquals(2,
+List%3CString%3E autocompleteEntry =
  new Per
@@ -623,188 +623,437 @@
 on(%22
-hello:1%22).size());%0A    assertEqualParts(%22list of stuff:one, two, three%22, %221%22, new PersistentAutocompleteDictionary(getContext()).splitOnLastColon(%22list of stuff:one, two, three:1%22)
+list of stuff:one, two, three:1%22);%0A    assertEquals(2, autocompleteEntry.size());%0A    assertEqualParts(%22list of stuff:one, two, three%22, %221%22, autocompleteEntry);%0A  %7D%0A%0A  public void testSplitterForEmptyCase() throws Exception %7B%0A    List%3CString%3E autocompletEntry = new PersistentAutocompleteDictionary(getContext()).splitOnLastColon(%22:1%22);%0A    assertEquals(2, autocompletEntry.size());%0A    assertEqualParts(%22%22, %221%22, autocompletEntry
 );%0A 

fix parsing of stored autocomplete entries to deal with embedded separator characters