2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.openecomp.sdc.heat.datatypes;
22 import static org.junit.jupiter.api.Assertions.assertTrue;
23 import static org.junit.jupiter.api.Assertions.assertFalse;
24 import org.junit.jupiter.api.Test;
26 public class HeatBooleanTest {
29 public void testEval() {
30 assertTrue(HeatBoolean.eval("true"));
31 assertTrue(HeatBoolean.eval("t"));
32 assertTrue(HeatBoolean.eval("on"));
33 assertTrue(HeatBoolean.eval("y"));
34 assertTrue(HeatBoolean.eval("yes"));
35 assertTrue(HeatBoolean.eval(1));
36 assertTrue(HeatBoolean.eval(true));
38 assertFalse(HeatBoolean.eval("false"));
39 assertFalse(HeatBoolean.eval("f"));
40 assertFalse(HeatBoolean.eval("off"));
41 assertFalse(HeatBoolean.eval("n"));
42 assertFalse(HeatBoolean.eval("no"));
43 assertFalse(HeatBoolean.eval(0));
44 assertFalse(HeatBoolean.eval(false));
48 public void testIsValueBoolean() {
49 assertTrue(HeatBoolean.isValueBoolean("y"));
50 assertTrue(HeatBoolean.isValueBoolean("off"));
51 assertTrue(HeatBoolean.isValueBoolean(false));
52 assertTrue(HeatBoolean.isValueBoolean(1));
53 assertTrue(HeatBoolean.isValueBoolean(true));
55 assertFalse(HeatBoolean.isValueBoolean("test"));
56 assertFalse(HeatBoolean.isValueBoolean(2));