mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-20 20:03:05 +02:00
Migrate NamedJSONComparatorTest to Kotlin
This commit is contained in:
parent
dda860a7a0
commit
baab194362
@ -42,8 +42,8 @@ permission notice:
|
||||
|
||||
// Example of class name: "/com/ichi2/anki/UIUtils.kt"
|
||||
// Ensure that it starts with '/' (slash)
|
||||
def source = Source.TEST
|
||||
def className = "/com/ichi2/utils/NamedJSONComparatorTest.kt"
|
||||
def source = Source.MAIN
|
||||
def className = ""
|
||||
|
||||
enum Source {
|
||||
MAIN("/src/main/java"),
|
||||
|
@ -15,39 +15,32 @@
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
****************************************************************************************/
|
||||
|
||||
package com.ichi2.utils;
|
||||
package com.ichi2.utils
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.lessThan;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class NamedJSONComparatorTest {
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import org.hamcrest.CoreMatchers
|
||||
import org.hamcrest.MatcherAssert
|
||||
import org.hamcrest.Matchers
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class NamedJSONComparatorTest {
|
||||
@Test
|
||||
public void checkIfReturnsCorrectValueForSameNames() {
|
||||
JSONObject firstObject = new JSONObject();
|
||||
firstObject.put("name", "TestName");
|
||||
|
||||
JSONObject secondObject = new JSONObject();
|
||||
secondObject.put("name", "TestName");
|
||||
|
||||
assertThat(NamedJSONComparator.INSTANCE.compare(firstObject, secondObject), equalTo(0));
|
||||
fun checkIfReturnsCorrectValueForSameNames() {
|
||||
val firstObject = JSONObject()
|
||||
firstObject.put("name", "TestName")
|
||||
val secondObject = JSONObject()
|
||||
secondObject.put("name", "TestName")
|
||||
MatcherAssert.assertThat(NamedJSONComparator.INSTANCE.compare(firstObject, secondObject), CoreMatchers.equalTo(0))
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkIfReturnsCorrectValueForDifferentNames() {
|
||||
JSONObject firstObject = new JSONObject();
|
||||
firstObject.put("name", "TestName1");
|
||||
|
||||
JSONObject secondObject = new JSONObject();
|
||||
secondObject.put("name", "TestName2");
|
||||
|
||||
assertThat(NamedJSONComparator.INSTANCE.compare(firstObject, secondObject), lessThan(0));
|
||||
fun checkIfReturnsCorrectValueForDifferentNames() {
|
||||
val firstObject = JSONObject()
|
||||
firstObject.put("name", "TestName1")
|
||||
val secondObject = JSONObject()
|
||||
secondObject.put("name", "TestName2")
|
||||
MatcherAssert.assertThat(NamedJSONComparator.INSTANCE.compare(firstObject, secondObject), Matchers.lessThan(0))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user