summaryrefslogtreecommitdiff
path: root/icu4j/main/core/src/test/java/com/ibm/icu/dev/test/message2/ParserSmokeTest.java
blob: 7b2a3b988c9e0914d78aa12cd084b84b30527faa (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
// © 2024 and later: Unicode, Inc. and others.
// License & terms of use: https://www.unicode.org/copyright.html

package com.ibm.icu.dev.test.message2;

import java.io.Reader;
import java.lang.reflect.Type;
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 com.ibm.icu.dev.test.CoreTestFmwk;
import com.ibm.icu.message2.MFParser;

/*
 * A list of tests for the parser.
 */
@RunWith(JUnit4.class)
@SuppressWarnings({"static-method", "javadoc"})
public class ParserSmokeTest extends CoreTestFmwk {
    private static final String JSON_FILE = "icu-parser-tests.json";

    @Test(expected = IllegalArgumentException.class)
    public void testNullInput() throws Exception {
        MFParser.parse(null);
    }

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