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 $
4
* $Date: 2004/02/21 17:10:30 $
6
* ====================================================================
7
* Copyright 2003-2004 The Apache Software Foundation
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
13
* http://www.apache.org/licenses/LICENSE-2.0
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.
22
package org.apache.commons.validator.util;
24
import junit.framework.TestCase;
27
* Test the Flags class.
29
public class FlagsTest extends TestCase {
32
* Declare some flags for testing.
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;
39
* Constructor for FlagsTest.
41
public FlagsTest(String name) {
45
public void testHashCode() {
46
Flags f = new Flags(45);
47
assertEquals(f.hashCode(), 45);
50
public void testGetFlags() {
51
Flags f = new Flags(45);
52
assertEquals(f.getFlags(), 45);
55
public void testIsOnOff() {
56
Flags f = new Flags();
59
assertTrue(f.isOn(LONG_FLAG));
60
assertTrue(!f.isOff(LONG_FLAG));
62
assertTrue(f.isOn(INT_FLAG));
63
assertTrue(!f.isOff(INT_FLAG));
65
assertTrue(f.isOff(LONG_FLAG_2));
68
public void testTurnOnOff() {
71
public void testTurnOff() {
74
public void testTurnOffAll() {
75
Flags f = new Flags(98432);
77
assertEquals(0, f.getFlags());
80
public void testClear() {
81
Flags f = new Flags(98432);
83
assertEquals(0, f.getFlags());
86
public void testTurnOnAll() {
87
Flags f = new Flags();
89
assertEquals(Long.MAX_VALUE, f.getFlags());
93
* Test for Object clone()
95
public void testClone() {
99
* Test for boolean equals(Object)
101
public void testEqualsObject() {
105
* Test for String toString()
107
public void testToString() {
108
Flags f = new Flags();
109
String s = f.toString();
110
assertEquals(64, s.length());
114
assertEquals(64, s.length());
117
"0000000000000000000000000000000000000000000000000000000000000100",