PageRenderTime 75ms CodeModel.GetById 65ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

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

http://testability-explorer.googlecode.com/
Java | 63 lines | 37 code | 11 blank | 15 comment | 0 complexity | 409ed083bafd05ce1ca40d6ab42335eb 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 VariableStateTest extends TestCase {
21
22  VariableState state = new VariableState();
23  Variable instance = new Variable("var", null, false, false);
24  FieldInfo field = new FieldInfo(null, "field", null, false, false, false);
25  Variable localField = new LocalField(instance, field);
26
27
28  public void testGlobals() throws Exception {
29    state.setGlobal(instance);
30    assertTrue(state.isGlobal(instance));
31    assertFalse(state.isGlobal(null));
32  }
33
34  public void testInjectables() throws Exception {
35    state.setInjectable(instance);
36    assertTrue(state.isInjectable(instance));
37    assertFalse(state.isInjectable(null));
38  }
39
40  public void testToString() throws Exception {
41    state.setGlobal(instance);
42    state.setInjectable(field);
43    String text = state.toString();
44    assertTrue(text, text.contains("var"));
45    assertTrue(text, text.contains("field"));
46  }
47
48  public void testLocalFieldIsGlobalIfInstanceIsGlobal() throws Exception {
49    state.setGlobal(instance);
50    assertTrue(state.isGlobal(localField));
51  }
52
53  public void testLocalFieldIsGlobalIfFieldIsGlobal() throws Exception {
54    state.setGlobal(field);
55    assertTrue(state.isGlobal(localField));
56  }
57
58  public void testLocalFieldIsInjectableIfInstanceIsInjectable() throws Exception {
59    state.setInjectable(field);
60    assertTrue(state.isInjectable(localField));
61  }
62
63}