1 /* 2 * $Header: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/util/FlagsTest.java,v 1.5 2004/02/21 17:10:30 rleland Exp $ 3 * $Revision: 1.5 $ 4 * $Date: 2004/02/21 17:10:30 $ 5 * 6 * ==================================================================== 7 * Copyright 2003-2004 The Apache Software Foundation 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 */ 21 22 package org.apache.commons.validator.util; 23 24 import junit.framework.TestCase; 25 26 /*** 27 * Test the Flags class. 28 */ 29 public class FlagsTest extends TestCase { 30 31 /*** 32 * Declare some flags for testing. 33 */ 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 /*** 39 * Constructor for FlagsTest. 40 */ 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 /*** 93 * Test for Object clone() 94 */ 95 public void testClone() { 96 } 97 98 /*** 99 * Test for boolean equals(Object) 100 */ 101 public void testEqualsObject() { 102 } 103 104 /*** 105 * Test for String toString() 106 */ 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 }

This page was automatically generated by Maven