xref: /aosp_15_r20/external/snakeyaml/src/test/java/org/yaml/snakeyaml/nodes/NodeTest.java (revision ac2a7c1bf4e14d82f3bd566dcc2d76d5b42faf34)
1 /**
2  * Copyright (c) 2008, SnakeYAML
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the License
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11  * or implied. See the License for the specific language governing permissions and limitations under
12  * the License.
13  */
14 package org.yaml.snakeyaml.nodes;
15 
16 import junit.framework.TestCase;
17 import org.yaml.snakeyaml.DumperOptions;
18 import org.yaml.snakeyaml.error.Mark;
19 
20 public class NodeTest extends TestCase {
21 
testNode()22   public void testNode() {
23     try {
24       new ScalarNode(new Tag("!foo"), null, null, null, DumperOptions.ScalarStyle.DOUBLE_QUOTED);
25       fail("Value must be required.");
26     } catch (Exception e) {
27       assertEquals("value in a Node is required.", e.getMessage());
28     }
29   }
30 
testSetTag()31   public void testSetTag() {
32     try {
33       ScalarNode node = new ScalarNode(new Tag("!foo"), "Value1", null, null,
34           DumperOptions.ScalarStyle.DOUBLE_QUOTED);
35       node.setTag(null);
36       fail("Value must be required.");
37     } catch (Exception e) {
38       assertEquals("tag in a Node is required.", e.getMessage());
39     }
40   }
41 
testGetEndMark()42   public void testGetEndMark() {
43     Mark mark1 = new Mark("name", 0, 2, 12, "afd asd asd".toCharArray(), 7);
44     Mark mark2 = new Mark("name", 0, 3, 13, "afd asd asd".toCharArray(), 8);
45     Node node = new ScalarNode(new Tag("!foo"), "bla-bla", mark1, mark2,
46         DumperOptions.ScalarStyle.DOUBLE_QUOTED);
47     assertEquals(mark1, node.getStartMark());
48     assertEquals(mark2, node.getEndMark());
49   }
50 
51 }
52