Modified two test files
[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 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     @Before
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() {
42             @Override
43             public int read(char[] cbuf, int off, int len) throws IOException {
44                 return 0;
45             }
46
47             @Override
48             public void close() throws IOException {
49
50             }
51         };
52         inputStream = new InputStream() {
53             @Override
54             public int read() throws IOException {
55                 return 0;
56             }
57         };
58         reader_empty = null;
59
60     }
61
62     @Test
63     public void testInit()throws  Exception{
64         InputStream inputStream_empty = null;
65
66         simpleCharStream = new SimpleCharStream(reader,1,1,1);
67         Assert.assertTrue(simpleCharStream != null);
68         simpleCharStream.ReInit(reader_empty, 1, 1, 1);
69
70         simpleCharStream = new SimpleCharStream(reader,1,1);
71         Assert.assertTrue(simpleCharStream != null);
72         simpleCharStream.ReInit(reader_empty, 1, 1);
73
74         simpleCharStream = new SimpleCharStream(reader);
75         Assert.assertTrue(simpleCharStream != null);
76         simpleCharStream.ReInit(reader_empty);
77
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);
82
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);
87
88         simpleCharStream = new SimpleCharStream(inputStream,1,1);
89         Assert.assertTrue(simpleCharStream != null);
90         simpleCharStream.ReInit(inputStream, 1, 1);
91         simpleCharStream.ReInit(reader_empty);
92
93         simpleCharStream = new SimpleCharStream(inputStream,null);
94         Assert.assertTrue(simpleCharStream != null);
95         simpleCharStream.ReInit(inputStream, null);
96         simpleCharStream.ReInit(reader_empty);
97
98         simpleCharStream = new SimpleCharStream(inputStream);
99         Assert.assertTrue(simpleCharStream != null);
100         simpleCharStream.ReInit(inputStream);
101         simpleCharStream.ReInit(reader_empty);
102
103     }
104
105     @Test
106     public void testSetTabSize() throws Exception {
107
108     }
109
110     @Test
111     public void testGetTabSize() throws Exception {
112
113     }
114
115     @Test
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);
121
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);
128
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);
135
136     }
137
138
139
140 }