1 21 22 package org.apache.commons.validator.util; 23 24 import junit.framework.TestCase; 25 26 29 public class FlagsTest extends TestCase { 30 31 34 private static final long LONG_FLAG = 1; 35 private static final long LONG_FLAG_2 = 2; 36 private static final int INT_FLAG = 4; 37 38 41 public FlagsTest(String name) { 42 super(name); 43 } 44 45 public void testHashCode() { 46 Flags f = new Flags(45); 47 assertEquals(f.hashCode(), 45); 48 } 49 50 public void testGetFlags() { 51 Flags f = new Flags(45); 52 assertEquals(f.getFlags(), 45); 53 } 54 55 public void testIsOnOff() { 56 Flags f = new Flags(); 57 f.turnOn(LONG_FLAG); 58 f.turnOn(INT_FLAG); 59 assertTrue(f.isOn(LONG_FLAG)); 60 assertTrue(!f.isOff(LONG_FLAG)); 61 62 assertTrue(f.isOn(INT_FLAG)); 63 assertTrue(!f.isOff(INT_FLAG)); 64 65 assertTrue(f.isOff(LONG_FLAG_2)); 66 } 67 68 public void testTurnOnOff() { 69 } 70 71 public void testTurnOff() { 72 } 73 74 public void testTurnOffAll() { 75 Flags f = new Flags(98432); 76 f.turnOffAll(); 77 assertEquals(0, f.getFlags()); 78 } 79 80 public void testClear() { 81 Flags f = new Flags(98432); 82 f.clear(); 83 assertEquals(0, f.getFlags()); 84 } 85 86 public void testTurnOnAll() { 87 Flags f = new Flags(); 88 f.turnOnAll(); 89 assertEquals(Long.MAX_VALUE, f.getFlags()); 90 } 91 92 95 public void testClone() { 96 } 97 98 101 public void testEqualsObject() { 102 } 103 104 107 public void testToString() { 108 Flags f = new Flags(); 109 String s = f.toString(); 110 assertEquals(64, s.length()); 111 112 f.turnOn(INT_FLAG); 113 s = f.toString(); 114 assertEquals(64, s.length()); 115 116 assertEquals( 117 "0000000000000000000000000000000000000000000000000000000000000100", 118 s); 119 } 120 121 } 122 | Popular Tags |