/* * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ /* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 5.0 */ /* JavaCCOptions:STATIC=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package user.vnspacemanager.languagestyle.NEMOParse; import junit.framework.TestCase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse.SimpleCharStream; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.lang.reflect.Field; import static org.junit.Assert.*; import static org.mockito.Mockito.*; /** * Created by zhangmeng on 2015/12/16. */ public class SimpleCharStreamTest extends TestCase { private SimpleCharStream simpleCharStream; private Reader reader; private InputStream inputStream; private Reader reader_empty; private Class class1 ; private Field field; @Before public void setUp() throws Exception { class1 = SimpleCharStream.class; field = class1.getDeclaredField("inputStream"); field.setAccessible(true); field.set(class1,null); reader = new Reader() { @Override public int read(char[] cbuf, int off, int len) throws IOException { return 0; } @Override public void close() throws IOException { } }; inputStream = new InputStream() { @Override public int read() throws IOException { return 0; } }; reader_empty = null; } @Test public void testInit()throws Exception{ InputStream inputStream_empty = null; simpleCharStream = new SimpleCharStream(reader,1,1,1); Assert.assertTrue(simpleCharStream != null); simpleCharStream.ReInit(reader_empty, 1, 1, 1); simpleCharStream = new SimpleCharStream(reader,1,1); Assert.assertTrue(simpleCharStream != null); simpleCharStream.ReInit(reader_empty, 1, 1); simpleCharStream = new SimpleCharStream(reader); Assert.assertTrue(simpleCharStream != null); simpleCharStream.ReInit(reader_empty); simpleCharStream = new SimpleCharStream(inputStream,null,1,1,1); Assert.assertTrue(simpleCharStream != null); simpleCharStream.ReInit(inputStream, null, 1, 1, 1); simpleCharStream.ReInit(reader_empty); simpleCharStream = new SimpleCharStream(inputStream,null,1,1); Assert.assertTrue(simpleCharStream != null); simpleCharStream.ReInit(inputStream, null, 1, 1); simpleCharStream.ReInit(reader_empty); simpleCharStream = new SimpleCharStream(inputStream,1,1); Assert.assertTrue(simpleCharStream != null); simpleCharStream.ReInit(inputStream, 1, 1); simpleCharStream.ReInit(reader_empty); simpleCharStream = new SimpleCharStream(inputStream,null); Assert.assertTrue(simpleCharStream != null); simpleCharStream.ReInit(inputStream, null); simpleCharStream.ReInit(reader_empty); simpleCharStream = new SimpleCharStream(inputStream); Assert.assertTrue(simpleCharStream != null); simpleCharStream.ReInit(inputStream); simpleCharStream.ReInit(reader_empty); } @Test public void testSetTabSize() throws Exception { } @Test public void testGetTabSize() throws Exception { } @Test public void testBeginToken_ReadChar_FillBuff_ExpandBuff() throws Exception { Assert.assertTrue(simpleCharStream == null); simpleCharStream = new SimpleCharStream(reader,1,1,1); SimpleCharStream.BeginToken(); Assert.assertTrue(simpleCharStream != null); // Assert.assertTrue(SimpleCharStream.getColumn() == 0); // Assert.assertTrue(SimpleCharStream.getLine() == 0); Assert.assertTrue(SimpleCharStream.getEndColumn() != 0); Assert.assertTrue(SimpleCharStream.getEndLine() != 0); Assert.assertTrue(SimpleCharStream.getBeginColumn() != 0); Assert.assertTrue(SimpleCharStream.getBeginLine() != 0); SimpleCharStream.backup(1); Assert.assertTrue(SimpleCharStream.GetImage() != null); Assert.assertTrue(SimpleCharStream.GetSuffix(1).length != 0); SimpleCharStream.adjustBeginLineColumn(1, 1); SimpleCharStream.Done(); simpleCharStream.ReInit(reader_empty); } }