|
| 1 | +/* |
| 2 | + * Tai-e: A Static Analysis Framework for Java |
| 3 | + * |
| 4 | + * Copyright (C) 2022 Tian Tan <tiantan@nju.edu.cn> |
| 5 | + * Copyright (C) 2022 Yue Li <yueli@nju.edu.cn> |
| 6 | + * |
| 7 | + * This file is part of Tai-e. |
| 8 | + * |
| 9 | + * Tai-e is free software: you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU Lesser General Public License |
| 11 | + * as published by the Free Software Foundation, either version 3 |
| 12 | + * of the License, or (at your option) any later version. |
| 13 | + * |
| 14 | + * Tai-e is distributed in the hope that it will be useful,but WITHOUT |
| 15 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 16 | + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General |
| 17 | + * Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU Lesser General Public |
| 20 | + * License along with Tai-e. If not, see <https://www.gnu.org/licenses/>. |
| 21 | + */ |
| 22 | + |
| 23 | +package pascal.taie.config; |
| 24 | + |
| 25 | +import org.junit.Assert; |
| 26 | +import org.junit.Test; |
| 27 | + |
| 28 | +import java.util.HashMap; |
| 29 | +import java.util.Map; |
| 30 | + |
| 31 | +public class AnalysisOptionsTest { |
| 32 | + |
| 33 | + @Test |
| 34 | + public void testNullOption() { |
| 35 | + AnalysisOptions options = new AnalysisOptions(getOptionValues()); |
| 36 | + Assert.assertNull(options.get("z")); |
| 37 | + } |
| 38 | + |
| 39 | + @Test(expected = ConfigException.class) |
| 40 | + public void testNonExistOption() { |
| 41 | + AnalysisOptions options = new AnalysisOptions(getOptionValues()); |
| 42 | + options.get("non-exist-key"); |
| 43 | + } |
| 44 | + |
| 45 | + private Map<String, Object> getOptionValues() { |
| 46 | + Map<String, Object> values = new HashMap<>(); |
| 47 | + values.put("x", 100); |
| 48 | + values.put("y", "666"); |
| 49 | + values.put("z", null); |
| 50 | + return values; |
| 51 | + } |
| 52 | +} |
0 commit comments