Skip to content

Commit

Permalink
Add testcase for index function.
Browse files Browse the repository at this point in the history
  • Loading branch information
zcc1234567 committed Aug 2, 2020
1 parent f64c02a commit e08de47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Cellphone extends LitePalSupport {

private Long id;

@Column(index = true)
public String brand;

private Character inStock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.database.sqlite.SQLiteDatabase;
import android.support.test.filters.SmallTest;
import android.util.Pair;

import com.litepaltest.model.Book;
import com.litepaltest.model.Cellphone;
Expand All @@ -28,12 +29,18 @@ public void setUp() {
}

@Test
public void testFindUniqueColumns() {
Set<String> uniqueColumns = DBUtility.findUniqueColumns(DBUtility.getTableNameByClassName(
Cellphone.class.getName()), db);
public void testFindIndexedColumns() {
Pair<Set<String>, Set<String>> pair = DBUtility.findIndexedColumns(DBUtility.getTableNameByClassName(Cellphone.class.getName()), db);
Set<String> indexColumns = pair.first;
Set<String> uniqueColumns = pair.second;
assertEquals(1, indexColumns.size());
assertEquals(1, uniqueColumns.size());
assertTrue(indexColumns.contains("brand"));
assertTrue(uniqueColumns.contains("serial"));
uniqueColumns = DBUtility.findUniqueColumns(DBUtility.getTableNameByClassName(Book.class.getName()), db);
pair = DBUtility.findIndexedColumns(DBUtility.getTableNameByClassName(Book.class.getName()), db);
indexColumns = pair.first;
uniqueColumns = pair.second;
assertEquals(0, indexColumns.size());
assertEquals(0, uniqueColumns.size());
}

Expand Down

0 comments on commit e08de47

Please sign in to comment.