Skip to content

Test crash scenario due to Unicode emoji characters #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 12, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/main/java/net/zetetic/tests/UnicodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,32 @@

import android.database.Cursor;
import net.sqlcipher.database.SQLiteDatabase;
import net.sqlcipher.database.SQLiteStatement;

public class UnicodeTest extends SQLCipherTest {
@Override
public boolean execute(SQLiteDatabase database) {

String expected = "КАКОЙ-ТО КИРИЛЛИЧЕСКИЙ ТЕКСТ"; // SOME Cyrillic TEXT
String actual = "";

Cursor result = database.rawQuery("select UPPER('Какой-то кириллический текст') as u1", new String[]{});
if(result != null){
if (result != null) {
result.moveToFirst();
actual = result.getString(0);
result.close();
}
return actual.equals(expected);
if (!actual.equals(expected)) return false;

if (android.os.Build.VERSION.SDK_INT >= 23) { // Android M
// This will crash on Android releases 1.X-5.X due the following Android bug:
// https://code.google.com/p/android/issues/detail?id=81341
SQLiteStatement st = database.compileStatement("SELECT '\uD83D\uDE03'"); // SMILING FACE (MOUTH OPEN)
String res = st.simpleQueryForString();
if (!res.equals("\uD83D\uDE03")) return false;
}

// all ok:
return true;
}

@Override
Expand Down