8000 Add json test case · ETS-Android4/sqlcipher-android@821303c · GitHub
[go: up one dir, main page]

Skip to content

Commit 821303c

Browse files
Add json test case
1 parent cec6d4e commit 821303c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package net.zetetic.database.sqlcipher_cts;
2+
3+
import static org.hamcrest.Matchers.is;
4+
import static org.junit.Assert.assertThat;
5+
6+
import android.database.Cursor;
7+
8+
import org.junit.Test;
9+
10+
public class JsonCastTest extends AndroidSQLCipherTestCase {
11+
12+
@Test
13+
public void shouldExtractUsernameFromQuery(){
14+
String name = "Bob Smith", queryName = "";
15+
String query = String.format("select cast(json_extract('{\"user\":\"%s\"}','$.user') as TEXT);", name);
16+
Cursor cursor = database.rawQuery(query);
17+
if(cursor != null && cursor.moveToFirst()){
18+
queryName = cursor.getString(0);
19+
cursor.close();
20+
}
21+
assertThat(queryName, is(name));
22+
}
23+
24+
}

0 commit comments

Comments
 (0)
0