PageRenderTime 23ms CodeModel.GetById 8ms RepoModel.GetById 0ms 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
Possible License(s): Apache-2.0
  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. */
  16. package com.google.test.metric;
  17. import junit.framework.TestCase;
  18. public class VariableStateTest extends TestCase {
  19. VariableState state = new VariableState();
  20. Variable instance = new Variable("var", null, false, false);
  21. FieldInfo field = new FieldInfo(null, "field", null, false, false, false);
  22. Variable localField = new LocalField(instance, field);
  23. public void testGlobals() throws Exception {
  24. state.setGlobal(instance);
  25. assertTrue(state.isGlobal(instance));
  26. assertFalse(state.isGlobal(null));
  27. }
  28. public void testInjectables() throws Exception {
  29. state.setInjectable(instance);
  30. assertTrue(state.isInjectable(instance));
  31. assertFalse(state.isInjectable(null));
  32. }
  33. public void testToString() throws Exception {
  34. state.setGlobal(instance);
  35. state.setInjectable(field);
  36. String text = state.toString();
  37. assertTrue(text, text.contains("var"));
  38. assertTrue(text, text.contains("field"));
  39. }
  40. public void testLocalFieldIsGlobalIfInstanceIsGlobal() throws Exception {
  41. state.setGlobal(instance);
  42. assertTrue(state.isGlobal(localField));
  43. }
  44. public void testLocalFieldIsGlobalIfFieldIsGlobal() throws Exception {
  45. state.setGlobal(field);
  46. assertTrue(state.isGlobal(localField));
  47. }
  48. public void testLocalFieldIsInjectableIfInstanceIsInjectable() throws Exception {
  49. state.setInjectable(field);
  50. assertTrue(state.isInjectable(localField));
  51. }
  52. }