Return-Path:
Delivered-To: apmail-jakarta-commons-dev-archive@apache.org
Received: (qmail 92427 invoked from network); 3 May 2003 02:16:41 -0000
Received: from exchange.sun.com (192.18.33.10)
by daedalus.apache.org with SMTP; 3 May 2003 02:16:41 -0000
Received: (qmail 29373 invoked by uid 97); 3 May 2003 02:18:51 -0000
Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org
Received: (qmail 29366 invoked from network); 3 May 2003 02:18:51 -0000
Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12)
by nagoya.betaversion.org with SMTP; 3 May 2003 02:18:51 -0000
Received: (qmail 92174 invoked by uid 500); 3 May 2003 02:16:38 -0000
Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm
Precedence: bulk
List-Unsubscribe:
List-Subscribe:
List-Help:
List-Post:
List-Id: "Jakarta Commons Developers List"
Reply-To: "Jakarta Commons Developers List"
Delivered-To: mailing list commons-dev@jakarta.apache.org
Received: (qmail 92141 invoked by uid 500); 3 May 2003 02:16:38 -0000
Received: (qmail 92128 invoked from network); 3 May 2003 02:16:38 -0000
Received: from icarus.apache.org (208.185.179.13)
by daedalus.apache.org with SMTP; 3 May 2003 02:16:38 -0000
Received: (qmail 81736 invoked by uid 1581); 3 May 2003 02:16:37 -0000
Date: 3 May 2003 02:16:37 -0000
Message-ID: <20030503021637.81735.qmail@icarus.apache.org>
From: dgraham@apache.org
To: jakarta-commons-cvs@apache.org
Subject: cvs commit:
jakarta-commons/validator/src/test/org/apache/commons/validator/util
FlagsTest.java
X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N
X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N
dgraham 2003/05/02 19:16:37
Modified: validator/src/share/org/apache/commons/validator/util
Flags.java
validator/src/test/org/apache/commons/validator
ValidatorTestSuite.java
Added: validator/src/test/org/apache/commons/validator/util
FlagsTest.java
Log:
Added FlagsTest.
Revision Changes Path
1.2 +63 -3 jakarta-commons/validator/src/share/org/apache/commons/validator/util/Flags.java
Index: Flags.java
===================================================================
RCS file: /home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/util/Flags.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Flags.java 2 May 2003 23:38:00 -0000 1.1
+++ Flags.java 3 May 2003 02:16:37 -0000 1.2
@@ -1,3 +1,64 @@
+/*
+ * $Header$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+
package org.apache.commons.validator.util;
import java.io.Serializable;
@@ -14,7 +75,7 @@
* 2 both being on/true.
*
*
- * Typically this class will be used in support of another class with integer constants
+ * Typically this class will be used in support of another class with constants
* and not directly by clients.
*
*
@@ -138,9 +199,8 @@
* the left. A 1 indicates the flag is on, a 0 means it's off.
*/
public String toString() {
- // TODO make sure this is right
StringBuffer bin = new StringBuffer(Long.toBinaryString(this.flags));
- for (int i = 0; i < 64 - bin.length(); i++) {
+ for (int i = 64 - bin.length(); i >0 ; i--) {
bin.insert(0, "0");
}
return bin.toString();
1.8 +10 -7 jakarta-commons/validator/src/test/org/apache/commons/validator/ValidatorTestSuite.java
Index: ValidatorTestSuite.java
===================================================================
RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/ValidatorTestSuite.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ValidatorTestSuite.java 30 Apr 2003 18:47:33 -0000 1.7
+++ ValidatorTestSuite.java 3 May 2003 02:16:37 -0000 1.8
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -66,6 +66,8 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.apache.commons.validator.util.FlagsTest;
+
/**
* Test suite for org.apache.commons.validator
@@ -95,10 +97,11 @@
suite.addTest(DoubleTest.suite());
suite.addTest(TypeTest.suite());
suite.addTest(EmailTest.suite());
- suite.addTest(UrlTest.suite());
suite.addTest(ValidatorTest.suite());
suite.addTest(LocaleTest.suite());
-
+ suite.addTestSuite(FlagsTest.class);
+ suite.addTest(UrlTest.suite());
+
return suite;
}
1.1 jakarta-commons/validator/src/test/org/apache/commons/validator/util/FlagsTest.java
Index: FlagsTest.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/util/FlagsTest.java,v 1.1 2003/05/03 02:16:37 dgraham Exp $
* $Revision: 1.1 $
* $Date: 2003/05/03 02:16:37 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* .
*
*/
package org.apache.commons.validator.util;
import junit.framework.TestCase;
/**
* Test the Flags class.
*
* @author David Graham
*/
public class FlagsTest extends TestCase {
/**
* Declare some flags for testing.
*/
private static final long LONG_FLAG = 1;
private static final long LONG_FLAG_2 = 2;
private static final int INT_FLAG = 4;
/**
* Constructor for FlagsTest.
* @param arg0
*/
public FlagsTest(String arg0) {
super(arg0);
}
public void testHashCode() {
Flags f = new Flags(45);
assertEquals(f.hashCode(), 45);
}
public void testGetFlags() {
Flags f = new Flags(45);
assertEquals(f.getFlags(), 45);
}
public void testIsOnOff() {
Flags f = new Flags();
f.turnOn(LONG_FLAG);
f.turnOn(INT_FLAG);
assertTrue(f.isOn(LONG_FLAG));
assertTrue(!f.isOff(LONG_FLAG));
assertTrue(f.isOn(INT_FLAG));
assertTrue(!f.isOff(INT_FLAG));
assertTrue(f.isOff(LONG_FLAG_2));
}
public void testTurnOnOff() {
}
public void testTurnOff() {
}
public void testTurnOffAll() {
Flags f = new Flags(98432);
f.turnOffAll();
assertEquals(0, f.getFlags());
}
public void testTurnOnAll() {
Flags f = new Flags();
f.turnOnAll();
assertEquals(Long.MAX_VALUE, f.getFlags());
}
/**
* Test for Object clone()
*/
public void testClone() {
}
/**
* Test for boolean equals(Object)
*/
public void testEqualsObject() {
}
/**
* Test for String toString()
*/
public void testToString() {
Flags f = new Flags();
String s = f.toString();
assertEquals(64, s.length());
f.turnOn(INT_FLAG);
s = f.toString();
assertEquals(64, s.length());
assertEquals(
"0000000000000000000000000000000000000000000000000000000000000100",
s);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org