1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 |
|
---|
6 | import org.junit.jupiter.api.BeforeEach;
|
---|
7 | import org.junit.jupiter.api.Test;
|
---|
8 | import org.junit.jupiter.api.extension.RegisterExtension;
|
---|
9 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
10 |
|
---|
11 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
12 | import net.trajano.commons.testing.UtilityClassTestUtil;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * Unit tests for class {@link PreferencesUtils}.
|
---|
16 | */
|
---|
17 | class PreferencesUtilsTest {
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Setup test.
|
---|
21 | */
|
---|
22 | @RegisterExtension
|
---|
23 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
24 | public JOSMTestRules test = new JOSMTestRules().preferences();
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Setup test.
|
---|
28 | */
|
---|
29 | @BeforeEach
|
---|
30 | public void setUp() {
|
---|
31 | PreferencesUtils.resetLog();
|
---|
32 | }
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Test method for {@link PreferencesUtils#log}.
|
---|
36 | */
|
---|
37 | @Test
|
---|
38 | void testLog() {
|
---|
39 | assertEquals("", PreferencesUtils.getLog());
|
---|
40 | PreferencesUtils.log("test");
|
---|
41 | assertEquals("test\n", PreferencesUtils.getLog());
|
---|
42 | PreferencesUtils.log("%d\n", 100);
|
---|
43 | assertEquals("test\n100\n", PreferencesUtils.getLog());
|
---|
44 | PreferencesUtils.log("test");
|
---|
45 | assertEquals("test\n100\ntest\n", PreferencesUtils.getLog());
|
---|
46 | }
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Tests that {@code PreferencesUtils} satisfies utility class criteria.
|
---|
50 | * @throws ReflectiveOperationException if an error occurs
|
---|
51 | */
|
---|
52 | @Test
|
---|
53 | void testUtilityClass() throws ReflectiveOperationException {
|
---|
54 | UtilityClassTestUtil.assertUtilityClassWellDefined(PreferencesUtils.class);
|
---|
55 | }
|
---|
56 | }
|
---|