forked from iSoron/uhabits
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
49 additions
and
59 deletions.
There are no files selected for viewing
59 changes: 0 additions & 59 deletions
59
uhabits-android/src/androidTest/java/org/isoron/uhabits/database/AndroidDatabaseTest.java
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
uhabits-android/src/androidTest/java/org/isoron/uhabits/database/AndroidDatabaseTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org> | ||
* | ||
* This file is part of Loop Habit Tracker. | ||
* | ||
* Loop Habit Tracker is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. | ||
* | ||
* Loop Habit Tracker is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.isoron.uhabits.database | ||
|
||
import android.database.sqlite.SQLiteDatabase | ||
import org.hamcrest.MatcherAssert | ||
import org.hamcrest.core.IsEqual | ||
import org.isoron.uhabits.BaseAndroidTest | ||
import org.isoron.uhabits.core.database.Cursor | ||
import org.junit.Test | ||
import java.util.HashMap | ||
|
||
class AndroidDatabaseTest : BaseAndroidTest() { | ||
private var db: AndroidDatabase? = null | ||
override fun setUp() { | ||
super.setUp() | ||
db = AndroidDatabase(SQLiteDatabase.create(null), null) | ||
db!!.execute("create table test(color int, name string)") | ||
} | ||
|
||
@Test | ||
@Throws(Exception::class) | ||
fun testInsert() { | ||
val map = HashMap<String, Any?>() | ||
map["name"] = "asd" | ||
map["color"] = null | ||
db!!.insert("test", map) | ||
val c: Cursor = db!!.query("select * from test") | ||
c.moveToNext() | ||
assertNull(c.getInt(0)) | ||
MatcherAssert.assertThat(c.getString(1), IsEqual.equalTo("asd")) | ||
} | ||
} |