mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-06-20 22:00:07 -04:00
added additional error checking and unit test
This commit is contained in:
@@ -20,6 +20,7 @@ package org.fdroid.fdroid;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -35,6 +36,7 @@ import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.shadows.ShadowLog;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@@ -157,4 +159,16 @@ public class PreferencesTest {
|
||||
assertNotEquals(Long.parseLong(defaults.getString(Preferences.PREF_KEEP_CACHE_TIME, null)),
|
||||
Preferences.get().getKeepCacheTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMirrorErrorMethods() {
|
||||
Preferences.setupForTests(CONTEXT);
|
||||
Preferences preferences = Preferences.get();
|
||||
// serialize an empty map
|
||||
preferences.setMirrorErrorData(new HashMap<>(0));
|
||||
HashMap<String, Integer> result = preferences.getMirrorErrorData();
|
||||
// deserializing should return an empty map without throwing any exceptions
|
||||
assertNotNull(result);
|
||||
assertEquals(result.size(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user