Fix incorrect package names
[nemo.git] / nemo-impl / src / test / java / org / opendaylight / nemo / user / vnspacemanager / languagestyle / NEMOParse / SimpleCharStreamTest.java
1 /*
2  * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
3  *
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
7  */
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 org.opendaylight.nemo.user.vnspacemanager.languagestyle.NEMOParse;
11
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;
17
18 import java.io.IOException;
19 import java.io.InputStream;
20 import java.io.Reader;
21 import java.lang.reflect.Field;
22
23 import static org.junit.Assert.*;
24 import static org.mockito.Mockito.*;
25 /**
26  * Created by zhangmeng on 2015/12/16.
27  */
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 ;
34     private Field field;
35     @Override
36     @Before
37     public void setUp() throws Exception {
38         class1 = SimpleCharStream.class;
39         field = class1.getDeclaredField("inputStream");
40         field.setAccessible(true);
41         field.set(class1,null);
42         reader = new Reader() {
43             @Override
44             public int read(char[] cbuf, int off, int len) throws IOException {
45                 return 0;
46             }
47
48             @Override
49             public void close() throws IOException {
50
51             }
52         };
53         inputStream = new InputStream() {
54             @Override
55             public int read() throws IOException {
56                 return 0;
57             }
58         };
59         reader_empty = null;
60
61     }
62
63     @Test
64     public void testInit()throws  Exception{
65         InputStream inputStream_empty = null;
66
67         simpleCharStream = new SimpleCharStream(reader,1,1,1);
68         Assert.assertTrue(simpleCharStream != null);
69         simpleCharStream.ReInit(reader_empty, 1, 1, 1);
70
71         simpleCharStream = new SimpleCharStream(reader,1,1);
72         Assert.assertTrue(simpleCharStream != null);
73         simpleCharStream.ReInit(reader_empty, 1, 1);
74
75         simpleCharStream = new SimpleCharStream(reader);
76         Assert.assertTrue(simpleCharStream != null);
77         simpleCharStream.ReInit(reader_empty);
78
79         simpleCharStream = new SimpleCharStream(inputStream,null,1,1,1);
80         Assert.assertTrue(simpleCharStream != null);
81         simpleCharStream.ReInit(inputStream, null, 1, 1, 1);
82         simpleCharStream.ReInit(reader_empty);
83
84         simpleCharStream = new SimpleCharStream(inputStream,null,1,1);
85         Assert.assertTrue(simpleCharStream != null);
86         simpleCharStream.ReInit(inputStream, null, 1, 1);
87         simpleCharStream.ReInit(reader_empty);
88
89         simpleCharStream = new SimpleCharStream(inputStream,1,1);
90         Assert.assertTrue(simpleCharStream != null);
91         simpleCharStream.ReInit(inputStream, 1, 1);
92         simpleCharStream.ReInit(reader_empty);
93
94         simpleCharStream = new SimpleCharStream(inputStream,null);
95         Assert.assertTrue(simpleCharStream != null);
96         simpleCharStream.ReInit(inputStream, null);
97         simpleCharStream.ReInit(reader_empty);
98
99         simpleCharStream = new SimpleCharStream(inputStream);
100         Assert.assertTrue(simpleCharStream != null);
101         simpleCharStream.ReInit(inputStream);
102         simpleCharStream.ReInit(reader_empty);
103
104     }
105
106     @Test
107     public void testSetTabSize() throws Exception {
108
109     }
110
111     @Test
112     public void testGetTabSize() throws Exception {
113
114     }
115
116     @Test
117     public void testBeginToken_ReadChar_FillBuff_ExpandBuff() throws Exception {
118         Assert.assertTrue(simpleCharStream == null);
119         simpleCharStream = new SimpleCharStream(reader,1,1,1);
120         SimpleCharStream.BeginToken();
121         Assert.assertTrue(simpleCharStream != null);
122
123 //        Assert.assertTrue(SimpleCharStream.getColumn() == 0);
124 //        Assert.assertTrue(SimpleCharStream.getLine() == 0);
125         Assert.assertTrue(SimpleCharStream.getEndColumn() != 0);
126         Assert.assertTrue(SimpleCharStream.getEndLine() != 0);
127         Assert.assertTrue(SimpleCharStream.getBeginColumn() != 0);
128         Assert.assertTrue(SimpleCharStream.getBeginLine() != 0);
129
130         SimpleCharStream.backup(1);
131         Assert.assertTrue(SimpleCharStream.GetImage() != null);
132         Assert.assertTrue(SimpleCharStream.GetSuffix(1).length != 0);
133         SimpleCharStream.adjustBeginLineColumn(1, 1);
134         SimpleCharStream.Done();
135         simpleCharStream.ReInit(reader_empty);
136
137     }
138
139
140
141 }