2 * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 /* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 5.0 */
9 /* JavaCCOptions:STATIC=true,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
10 package user.vnspacemanager.languagestyle.NEMOParse;
12 import junit.framework.TestCase;
13 import org.junit.Assert;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse.SimpleCharStream;
18 import java.io.IOException;
19 import java.io.InputStream;
20 import java.io.Reader;
21 import java.lang.reflect.Field;
23 import static org.junit.Assert.*;
24 import static org.mockito.Mockito.*;
26 * Created by zhangmeng on 2015/12/16.
28 public class SimpleCharStreamTest extends TestCase {
29 private SimpleCharStream simpleCharStream;
30 private Reader reader;
31 private InputStream inputStream;
32 private Reader reader_empty;
33 private Class<SimpleCharStream> class1 ;
36 public void setUp() throws Exception {
37 class1 = SimpleCharStream.class;
38 field = class1.getDeclaredField("inputStream");
39 field.setAccessible(true);
40 field.set(class1,null);
41 reader = new Reader() {
43 public int read(char[] cbuf, int off, int len) throws IOException {
48 public void close() throws IOException {
52 inputStream = new InputStream() {
54 public int read() throws IOException {
63 public void testInit()throws Exception{
64 InputStream inputStream_empty = null;
66 simpleCharStream = new SimpleCharStream(reader,1,1,1);
67 Assert.assertTrue(simpleCharStream != null);
68 simpleCharStream.ReInit(reader_empty, 1, 1, 1);
70 simpleCharStream = new SimpleCharStream(reader,1,1);
71 Assert.assertTrue(simpleCharStream != null);
72 simpleCharStream.ReInit(reader_empty, 1, 1);
74 simpleCharStream = new SimpleCharStream(reader);
75 Assert.assertTrue(simpleCharStream != null);
76 simpleCharStream.ReInit(reader_empty);
78 simpleCharStream = new SimpleCharStream(inputStream,null,1,1,1);
79 Assert.assertTrue(simpleCharStream != null);
80 simpleCharStream.ReInit(inputStream, null, 1, 1, 1);
81 simpleCharStream.ReInit(reader_empty);
83 simpleCharStream = new SimpleCharStream(inputStream,null,1,1);
84 Assert.assertTrue(simpleCharStream != null);
85 simpleCharStream.ReInit(inputStream, null, 1, 1);
86 simpleCharStream.ReInit(reader_empty);
88 simpleCharStream = new SimpleCharStream(inputStream,1,1);
89 Assert.assertTrue(simpleCharStream != null);
90 simpleCharStream.ReInit(inputStream, 1, 1);
91 simpleCharStream.ReInit(reader_empty);
93 simpleCharStream = new SimpleCharStream(inputStream,null);
94 Assert.assertTrue(simpleCharStream != null);
95 simpleCharStream.ReInit(inputStream, null);
96 simpleCharStream.ReInit(reader_empty);
98 simpleCharStream = new SimpleCharStream(inputStream);
99 Assert.assertTrue(simpleCharStream != null);
100 simpleCharStream.ReInit(inputStream);
101 simpleCharStream.ReInit(reader_empty);
106 public void testSetTabSize() throws Exception {
111 public void testGetTabSize() throws Exception {
116 public void testBeginToken_ReadChar_FillBuff_ExpandBuff() throws Exception {
117 Assert.assertTrue(simpleCharStream == null);
118 simpleCharStream = new SimpleCharStream(reader,1,1,1);
119 SimpleCharStream.BeginToken();
120 Assert.assertTrue(simpleCharStream != null);
122 // Assert.assertTrue(SimpleCharStream.getColumn() == 0);
123 // Assert.assertTrue(SimpleCharStream.getLine() == 0);
124 Assert.assertTrue(SimpleCharStream.getEndColumn() != 0);
125 Assert.assertTrue(SimpleCharStream.getEndLine() != 0);
126 Assert.assertTrue(SimpleCharStream.getBeginColumn() != 0);
127 Assert.assertTrue(SimpleCharStream.getBeginLine() != 0);
129 SimpleCharStream.backup(1);
130 Assert.assertTrue(SimpleCharStream.GetImage() != null);
131 Assert.assertTrue(SimpleCharStream.GetSuffix(1).length != 0);
132 SimpleCharStream.adjustBeginLineColumn(1, 1);
133 SimpleCharStream.Done();
134 simpleCharStream.ReInit(reader_empty);