Skip to content

Commit

Permalink
added test for remove_accents null scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
iulian0512 committed Feb 9, 2024
1 parent 472c3c5 commit 2ebff55
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ android {

publishing {
singleVariant("release") {
version = "2.0.8"
version = "2.0.9"
}
}

Expand Down
20 changes: 15 additions & 5 deletions app/src/androidTest/java/org/spatialite/DatabaseLocaleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

@RunWith(AndroidJUnit4.class)
Expand Down Expand Up @@ -144,18 +145,27 @@ public void testHoge() throws Exception {
@Test
public void testRemoveAccents() {
// Insert a record with accented text
mDatabase.execSQL("INSERT INTO test (id,data) VALUES (141,'álphá béttá gámmá')");
mDatabase.execSQL("INSERT INTO test (id,data) VALUES (141,'álphá béttá gámmá'),(142,null)");

// Query the database using your custom remove_accents function
Cursor cursor = mDatabase.rawQuery("SELECT remove_accents(data) FROM test WHERE id = 141", null);
Cursor cursor = mDatabase.rawQuery("SELECT id,remove_accents(data) FROM test", null);

// Move to the first (and only) row in the result set
if (cursor != null && cursor.moveToFirst()) {
if (cursor != null && cursor.moveToNext()) {
int id=cursor.getInt(0);
// Get the string from the query result
String data = cursor.getString(0);
String data = cursor.getString(1);

// Compare the modified string to the expected string
assertEquals("alpha betta gamma", data);
switch (id)
{
case 141:
assertEquals("alpha betta gamma", data);
break;
case 142:
assertNull(data);
break;
}

// Close the cursor
cursor.close();
Expand Down

0 comments on commit 2ebff55

Please sign in to comment.