source: josm/trunk/test/unit/org/openstreetmap/josm/gui/preferences/advanced/PrefEntryTest.java

Last change on this file was 18853, checked in by taylor.smock, 7 months ago

See #16567: Update to JUnit 5

This removes new JOSMTestRules() with no additional setup and most
JOSMFixture calls.

Removing the bare JOSMTestRules speeds up the test suite since there are two
fewer System.gc() calls per test.

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences.advanced;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5import static org.junit.jupiter.api.Assertions.assertFalse;
6import static org.junit.jupiter.api.Assertions.assertTrue;
7
8import org.junit.jupiter.api.Test;
9import org.openstreetmap.josm.TestUtils;
10import org.openstreetmap.josm.spi.preferences.StringSetting;
11
12import nl.jqno.equalsverifier.EqualsVerifier;
13
14/**
15 * Unit tests of {@link PrefEntry} class.
16 */
17class PrefEntryTest {
18 /**
19 * Unit test of {@link PrefEntry#PrefEntry}.
20 */
21 @Test
22 void testPrefEntry() {
23 String key = "key";
24 StringSetting val = new StringSetting("value");
25 StringSetting def = new StringSetting("defaultValue");
26 PrefEntry pe = new PrefEntry(key, val, def, false);
27 assertFalse(pe.isDefault());
28 assertEquals(key, pe.getKey());
29 assertEquals(val, pe.getValue());
30 assertEquals(def, pe.getDefaultValue());
31 StringSetting val2 = new StringSetting("value2");
32 assertFalse(pe.isChanged());
33 pe.setValue(val2);
34 assertEquals(val2, pe.getValue());
35 assertEquals(val2.toString(), pe.toString());
36 assertTrue(pe.isChanged());
37 pe.reset();
38 pe.markAsChanged();
39 assertTrue(pe.isChanged());
40 }
41
42 /**
43 * Unit test of methods {@link PrefEntry#equals} and {@link PrefEntry#hashCode}.
44 */
45 @Test
46 void testEqualsContract() {
47 TestUtils.assumeWorkingEqualsVerifier();
48 EqualsVerifier.forClass(PrefEntry.class).usingGetClass()
49 .withIgnoredFields("value", "defaultValue", "isDefault", "changed")
50 .verify();
51 }
52}
Note: See TracBrowser for help on using the repository browser.