Skip to content

Commit aa2e779

Browse files
Tests for rawQuery support of Object array parameter binding
1 parent b5df25f commit aa2e779

15 files changed

+601
-73
lines changed

.idea/workspace.xml

Lines changed: 426 additions & 73 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/arm64-v8a/libsqlcipher.so

0 Bytes
Binary file not shown.

libs/armeabi-v7a/libsqlcipher.so

-108 Bytes
Binary file not shown.

libs/armeabi/libsqlcipher.so

-108 Bytes
Binary file not shown.

libs/sqlcipher-javadoc.jar

478 Bytes
Binary file not shown.

libs/sqlcipher.jar

2.24 KB
Binary file not shown.

libs/x86/libsqlcipher.so

-8.11 KB
Binary file not shown.

libs/x86_64/libsqlcipher.so

0 Bytes
Binary file not shown.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package net.zetetic.tests;
2+
3+
import net.sqlcipher.Cursor;
4+
import net.sqlcipher.database.SQLiteDatabase;
5+
6+
public class BindBooleanRawQueryTest extends SQLCipherTest {
7+
@Override
8+
public boolean execute(SQLiteDatabase database) {
9+
database.execSQL("create table t1(a,b);");
10+
database.execSQL("insert into t1(a,b) values(?, ?);", new Object[]{"one for the money", true});
11+
Cursor cursor = database.rawQuery("select * from t1 where b = ?;", new Object[]{true});
12+
if(cursor != null){
13+
if(cursor.moveToFirst()) {
14+
String a = cursor.getString(0);
15+
int b = cursor.getInt(1);
16+
cursor.close();
17+
return a.equals("one for the money") && b == 1;
18+
}
19+
}
20+
return false;
21+
}
22+
23+
@Override
24+
public String getName() {
25+
return "Bind Boolean for RawQuery Test";
26+
}
27+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package net.zetetic.tests;
2+
3+
import net.sqlcipher.Cursor;
4+
import net.sqlcipher.database.SQLiteDatabase;
5+
6+
import java.security.SecureRandom;
7+
import java.util.Arrays;
8+
9+
public class BindByteArrayRawQueryTest extends SQLCipherTest {
10+
@Override
11+
public boolean execute(SQLiteDatabase database) {
12+
13+
SecureRandom random = new SecureRandom();
14+
byte[] randomData = new byte[20];
15+
random.nextBytes(randomData);
16+
database.execSQL("create table t1(a,b);");
17+
database.execSQL("insert into t1(a,b) values(?, ?);", new Object[]{"one for the money", randomData});
18+
Cursor cursor = database.rawQuery("select * from t1 where b = ?;", new Object[]{randomData});
19+
if(cursor != null){
20+
if(cursor.moveToFirst()) {
21+
String a = cursor.getString(0);
22+
byte[] b = cursor.getBlob(1);
23+
cursor.close();
24+
return a.equals("one for the money") && Arrays.equals(randomData, b);
25+
}
26+
}
27+
return false;
28+
}
29+
30+
@Override
31+
public String getName() {
32+
return "Bind Byte Array for RawQuery Test";
33+
}
34+
}

0 commit comments

Comments
 (0)