001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.commons.validator.util;
018:
019: import junit.framework.TestCase;
020:
021: /**
022: * Test the Flags class.
023: *
024: * @version $Revision: 478334 $ $Date: 2006-11-22 21:31:54 +0000 (Wed, 22 Nov 2006) $
025: */
026: public class FlagsTest extends TestCase {
027:
028: /**
029: * Declare some flags for testing.
030: */
031: private static final long LONG_FLAG = 1;
032: private static final long LONG_FLAG_2 = 2;
033: private static final int INT_FLAG = 4;
034:
035: /**
036: * Constructor for FlagsTest.
037: */
038: public FlagsTest(String name) {
039: super (name);
040: }
041:
042: public void testHashCode() {
043: Flags f = new Flags(45);
044: assertEquals(f.hashCode(), 45);
045: }
046:
047: public void testGetFlags() {
048: Flags f = new Flags(45);
049: assertEquals(f.getFlags(), 45);
050: }
051:
052: public void testIsOnOff() {
053: Flags f = new Flags();
054: f.turnOn(LONG_FLAG);
055: f.turnOn(INT_FLAG);
056: assertTrue(f.isOn(LONG_FLAG));
057: assertTrue(!f.isOff(LONG_FLAG));
058:
059: assertTrue(f.isOn(INT_FLAG));
060: assertTrue(!f.isOff(INT_FLAG));
061:
062: assertTrue(f.isOff(LONG_FLAG_2));
063: }
064:
065: public void testTurnOnOff() {
066: }
067:
068: public void testTurnOff() {
069: }
070:
071: public void testTurnOffAll() {
072: Flags f = new Flags(98432);
073: f.turnOffAll();
074: assertEquals(0, f.getFlags());
075: }
076:
077: public void testClear() {
078: Flags f = new Flags(98432);
079: f.clear();
080: assertEquals(0, f.getFlags());
081: }
082:
083: public void testTurnOnAll() {
084: Flags f = new Flags();
085: f.turnOnAll();
086: assertEquals(Long.MAX_VALUE, f.getFlags());
087: }
088:
089: /**
090: * Test for Object clone()
091: */
092: public void testClone() {
093: }
094:
095: /**
096: * Test for boolean equals(Object)
097: */
098: public void testEqualsObject() {
099: }
100:
101: /**
102: * Test for String toString()
103: */
104: public void testToString() {
105: Flags f = new Flags();
106: String s = f.toString();
107: assertEquals(64, s.length());
108:
109: f.turnOn(INT_FLAG);
110: s = f.toString();
111: assertEquals(64, s.length());
112:
113: assertEquals(
114: "0000000000000000000000000000000000000000000000000000000000000100",
115: s);
116: }
117:
118: }
|