PageRenderTime 13ms CodeModel.GetById 2ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

/testability-explorer/src/test/java/com/google/test/metric/LocalVariableStateTest.java

http://testability-explorer.googlecode.com/
Java | 61 lines | 36 code | 10 blank | 15 comment | 0 complexity | 28ece8fc82b49cde97245f1746a0df4f MD5 | raw file
 1/*
 2 * Copyright 2008 Google Inc.
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 5 * use this file except in compliance with the License. You may obtain a copy of
 6 * the License at
 7 *
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16package com.google.test.metric;
17
18import junit.framework.TestCase;
19
20public class LocalVariableStateTest extends TestCase {
21
22  VariableState globals = new VariableState();
23  LocalVariableState locals = new LocalVariableState(globals);
24  Variable instance = new Variable("var", null, false, false);
25  Variable lod = new Variable("lod", null, false, false);
26  FieldInfo field = new FieldInfo(null, "field", null, false, false, false);
27
28  public void testGlobalRouting() throws Exception {
29    locals.setGlobal(field);
30    locals.setInjectable(field);
31
32    assertTrue(globals.isGlobal(field));
33    assertTrue(globals.isInjectable(field));
34  }
35
36  public void testLocalRouting() throws Exception {
37    locals.setGlobal(instance);
38    locals.setInjectable(instance);
39
40    assertTrue(locals.isGlobal(instance));
41    assertTrue(locals.isInjectable(instance));
42  }
43
44  public void testToString() throws Exception {
45    locals.setGlobal(instance);
46    locals.setInjectable(field);
47    locals.setLoDCount(lod, 123);
48    String text = locals.toString();
49    assertTrue(text, text.contains("var"));
50    assertTrue(text, text.contains("field"));
51    assertTrue(text, text.contains("lod"));
52    assertTrue(text, text.contains("123"));
53  }
54
55  public void testLodCount() throws Exception {
56    locals.setLoDCount(lod, 123);
57    assertEquals(123, locals.getLoDCount(lod));
58    assertEquals(0, locals.getLoDCount(instance));
59  }
60
61}