Add removeAll to preferences (#987)

This removes all keys except for .type.
This commit is contained in:
Austin Shalit
2018-05-16 22:50:35 -04:00
committed by Peter Johnson
parent 2e0709f05b
commit f90e429bf9
4 changed files with 43 additions and 0 deletions

View File

@@ -7,6 +7,7 @@
package edu.wpi.first.wpilibj;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
@@ -88,6 +89,25 @@ public class PreferencesTest extends AbstractComsSetup {
m_pref.putBoolean("checkedValueBoolean", true);
}
/**
* Just checking to make sure our helper method works.
*/
@Test
public void testRemove() {
remove();
assertEquals("Preferences was not empty! Preferences in table: "
+ Arrays.toString(m_pref.getKeys().toArray()),
1, m_pref.getKeys().size());
}
@Test
public void testRemoveAll() {
m_pref.removeAll();
assertEquals("Preferences was not empty! Preferences in table: "
+ Arrays.toString(m_pref.getKeys().toArray()),
1, m_pref.getKeys().size());
}
@Test
public void testAddRemoveSave() {
assertEquals(m_pref.getLong("checkedValueLong", 0), 172L);