summaryrefslogtreecommitdiff
path: root/android_icu4j/src/main/tests/android/icu/dev/test/message2/IcuFunctionsTest.java
blob: 7b95f442dcfb7daf5beca69a661ef43e67802b1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* GENERATED SOURCE. DO NOT MODIFY. */
// © 2024 and later: Unicode, Inc. and others.
// License & terms of use: https://www.unicode.org/copyright.html

package android.icu.dev.test.message2;

import java.io.Reader;
import java.lang.reflect.Type;
import java.util.Date;
import java.util.Map;
import java.util.Map.Entry;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import com.google.gson.reflect.TypeToken;
import android.icu.dev.test.CoreTestFmwk;
import android.icu.testsharding.MainTestShard;

@MainTestShard
@SuppressWarnings({"static-method", "javadoc"})
@RunWith(JUnit4.class)
public class IcuFunctionsTest extends CoreTestFmwk {
    private static final String JSON_FILE = "icu-test-functions.json";

    // Some default parameters for all messages, to use if the message does not have its own
    private static final Map<String, Object> ARGS =
            Args.of(
                    "user", "John",
                    "exp", new Date(2024 - 1900, 7, 3, 21, 43, 57), // Aug 3, 2024, at 9:43:57 pm
                    "tsOver", "full");

    @Test
    public void test() throws Exception {
        try (Reader reader = TestUtils.jsonReader(JSON_FILE)) {
            Type mapType =
                    new TypeToken<Map<String, Unit[]>>() {
                        /* not code */
                    }.getType();
            Map<String, Unit[]> unitList = TestUtils.GSON.fromJson(reader, mapType);
            for (Entry<String, Unit[]> testGroup : unitList.entrySet()) {
                for (Unit unit : testGroup.getValue()) {
                    TestUtils.runTestCase(unit, ARGS);
                }
            }
        }
    }
}