If you think the Android project android-sqlite-helper listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package net.ichigotake.sqlitehelper.ddl;
/*fromwww.java2s.com*/import junit.framework.Assert;
import net.ichigotake.sqlitehelper.MockTable;
import net.ichigotake.sqlitehelper.schema.Index;
import net.ichigotake.sqlitehelper.schema.TableField;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.util.Arrays;
@Config(emulateSdk = 18)
@RunWith(RobolectricTestRunner.class)
publicclass CreateIndexTest {
@Test
publicvoid testClause() {
MockTable mock = new MockTable();
CreateIndex createIndex = new CreateIndex(null, mock.getTableSchema());
{
Index sample = new Index(mock.getTableName(), Arrays.<TableField>asList(MockTable.Field.ID));
String query = createIndex.buildCreateIndexClause(sample);
String expected = "CREATE INDEX IF NOT EXISTS mock__id ON mock(_id)";
Assert.assertEquals(expected, query);
}
{
Index sample = new Index(
mock.getTableName(),
Arrays.<TableField>asList(MockTable.Field.ITEM_TYPE, MockTable.Field.ITEM_NAME)
);
String query = createIndex.buildCreateIndexClause(sample);
String expected = "CREATE INDEX IF NOT EXISTS mock_item_type_and_item_name" +
" ON mock(item_type,item_name)";
Assert.assertEquals(expected, query);
}
}
}