/**
 * Copyright (c) 2008, http://www.snakeyaml.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.yaml.snakeyaml;

import java.io.StringReader;

import junit.framework.TestCase;

import org.yaml.snakeyaml.events.Event;
import org.yaml.snakeyaml.events.StreamEndEvent;
import org.yaml.snakeyaml.events.StreamStartEvent;

public class YamlParseTest extends TestCase {

    public void testParse() {
        Yaml yaml = new Yaml();
        Event e = null;
        int counter = 0;
        for (Event event : yaml.parse(new StringReader("abc: 56"))) {
            if (e == null) {
                assertTrue(event instanceof StreamStartEvent);
            }
            e = event;
            counter++;
        }
        assertTrue(e instanceof StreamEndEvent);
        assertEquals(8, counter);
    }

    public void testParseManyDocuments() {
        Yaml yaml = new Yaml();
        Event e = null;
        int counter = 0;
        for (Event event : yaml.parse(new StringReader("abc: 56\n---\n4\n---\nqwe\n"))) {
            if (e == null) {
                assertTrue(event instanceof StreamStartEvent);
            }
            e = event;
            counter++;
        }
        assertTrue(e instanceof StreamEndEvent);
        assertEquals(14, counter);
    }
}

@@ -665,25 +665,24 @@
 Reader;%0A
-%0A
 import j
 unit.fra
@@ -677,73 +677,109 @@
 rt j
-unit.framework.TestCase;%0A%0Aimport org.yaml.snakeyaml.events.Event;
+ava.util.HashMap;%0Aimport java.util.Iterator;%0Aimport java.util.Map;%0A%0Aimport junit.framework.TestCase;%0A
 %0Aimp
@@ -808,30 +808,17 @@
 .events.
-StreamEndEvent
+*
 ;%0Aimport
@@ -841,31 +841,17 @@
 aml.
-events.StreamStartEvent
+nodes.Tag
 ;%0A%0Ap
@@ -1329,16 +1329,1195 @@
 %0A    %7D%0A%0A
+    public void testParseEvents() %7B%0A        Yaml yaml = new Yaml();%0A        Iterator%3CEvent%3E events = yaml.parse(new StringReader(%22%25YAML 1.1%5Cn---%5Cna%22)).iterator();%0A        assertTrue(events.next() instanceof StreamStartEvent);%0A        DocumentStartEvent documentStartEvent = (DocumentStartEvent) events.next();%0A        assertTrue(documentStartEvent.getExplicit());%0A        assertEquals(DumperOptions.Version.V1_1, documentStartEvent.getVersion());%0A        Map%3CString, String%3E DEFAULT_TAGS = new HashMap%3CString, String%3E();%0A        DEFAULT_TAGS.put(%22!%22, %22!%22);%0A        DEFAULT_TAGS.put(%22!!%22, Tag.PREFIX);%0A        assertEquals(DEFAULT_TAGS, documentStartEvent.getTags());%0A        ScalarEvent scalarEvent = (ScalarEvent) events.next();%0A        assertNull(scalarEvent.getAnchor());%0A        assertNull(scalarEvent.getTag());%0A        assertEquals(new ImplicitTuple(true, false).toString(), scalarEvent.getImplicit().toString());%0A        DocumentEndEvent documentEndEvent = (DocumentEndEvent) events.next();%0A        assertFalse(documentEndEvent.getExplicit());%0A        assertTrue(%22Unexpected event.%22, events.next() instanceof StreamEndEvent);%0A        assertFalse(events.hasNext());%0A    %7D%0A%0A
     publ

Add a test to parse events