* FYI: New tests for new class
@ 2005-11-22 19:48 Anthony Balkissoon
2005-11-22 20:14 ` Anthony Balkissoon
0 siblings, 1 reply; 2+ messages in thread
From: Anthony Balkissoon @ 2005-11-22 19:48 UTC (permalink / raw)
To: mauve-patches
[-- Attachment #1: Type: text/plain, Size: 189 bytes --]
New tests for the class MaskFormatter in javax.swing.text.
2005-11-22 Anthony Balkissoon <abalkiss@redhat.com>
* gnu/testlet/javax/swing/text/MaskFormatterTest.java: New test.
--Tony
[-- Attachment #2: MaskFormatterTest.java --]
[-- Type: text/x-java, Size: 3093 bytes --]
// Tags: JDK1.2
// Copyright (C) 2005 Red Hat.
// This file is part of Mauve.
// Mauve is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.
// Mauve is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Mauve; see the file COPYING. If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
package gnu.testlet.javax.swing.text.MaskFormatter;
import gnu.testlet.Testlet;
import gnu.testlet.TestHarness;
import java.text.ParseException;
import javax.swing.text.MaskFormatter;
/**
* Several tests related to MaskFormatter.
*/
public class MaskFormatterTest
implements Testlet
{
public void test(TestHarness harness)
{
MaskFormatter formatter = null;
try
{
formatter = new MaskFormatter("RE'*B**KS");
// Default value checks
harness.checkPoint("defaults");
harness.check (formatter.getValueContainsLiteralCharacters());
harness.check (!formatter.getAllowsInvalid());
harness.check (formatter.getPlaceholder() == null);
harness.check (formatter.getPlaceholderCharacter() == ' ');
harness.check (formatter.getValidCharacters() == null);
harness.check (formatter.getInvalidCharacters() == null);
// Checks to see whether the appropriate characters are being used to pad
harness.checkPoint("padding");
formatter.setPlaceholder("MMMMMMMMM");
formatter.setPlaceholderCharacter('$');
harness.check (formatter.valueToString("RE"),"RE*BMMKS");
formatter.setPlaceholder("8");
harness.check (formatter.valueToString("RE"),"RE*B$$KS");
formatter.setPlaceholder("12345");
harness.check (formatter.valueToString("RE"),"RE*B5$KS");
// Checks to see if valid output is produced
harness.checkPoint("valid output");
formatter.setMask("(###) ###-####");
harness.check (formatter.valueToString("(555) 807-9090"),"(555) 807-9090");
harness.check (formatter.stringToValue("(555) 807-9090"),"(555) 807-9090");
formatter.setValueContainsLiteralCharacters(false);
harness.check (formatter.stringToValue("(555) 807-9090"),"5558079090");
boolean exception = false;
try
{
harness.check (formatter.valueToString("(555) 807-9090"),"(555) 807-9090");
}
catch (ParseException pe)
{
exception = true;
}
harness.check (exception);
}
catch (java.text.ParseException ex)
{
harness.fail ("an exception was thrown that shouldn't have been");
}
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: FYI: New tests for new class
2005-11-22 19:48 FYI: New tests for new class Anthony Balkissoon
@ 2005-11-22 20:14 ` Anthony Balkissoon
0 siblings, 0 replies; 2+ messages in thread
From: Anthony Balkissoon @ 2005-11-22 20:14 UTC (permalink / raw)
To: mauve-patches
[-- Attachment #1: Type: text/plain, Size: 431 bytes --]
I added more tests to this file.
2005-11-22 Anthony Balkissoon <abalkiss@redhat.com>
* gnu/testlet/javax/swing/text/MaskFormatterTest.java: Added more
tests.
On Tue, 2005-11-22 at 14:48 -0500, Anthony Balkissoon wrote:
> New tests for the class MaskFormatter in javax.swing.text.
>
> 2005-11-22 Anthony Balkissoon <abalkiss@redhat.com>
>
> * gnu/testlet/javax/swing/text/MaskFormatterTest.java: New test.
>
> --Tony
[-- Attachment #2: MaskFormatterNewTests.diff --]
[-- Type: text/x-patch, Size: 1243 bytes --]
Index: gnu/testlet/javax/swing/text/MaskFormatter/MaskFormatterTest.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/text/MaskFormatter/MaskFormatterTest.java,v
retrieving revision 1.1
diff -u -r1.1 MaskFormatterTest.java
--- gnu/testlet/javax/swing/text/MaskFormatter/MaskFormatterTest.java 22 Nov 2005 19:46:25 -0000 1.1
+++ gnu/testlet/javax/swing/text/MaskFormatter/MaskFormatterTest.java 22 Nov 2005 20:12:10 -0000
@@ -78,6 +78,23 @@
exception = true;
}
harness.check (exception);
+
+ // Checks to see if valid/invalid character sets work
+ formatter = new MaskFormatter("T##'FA");
+ formatter.setInvalidCharacters("T");
+ formatter.setValidCharacters("4");
+ harness.check(formatter.valueToString("T44F4"), "T44F4");
+ harness.check(formatter.stringToValue("T44F4"), "T44F4");
+ exception = false;
+ try
+ {
+ formatter.valueToString("T33F3");
+ }
+ catch (ParseException pe2)
+ {
+ exception = true;
+ }
+ harness.check(exception);
}
catch (java.text.ParseException ex)
{
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-11-22 20:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-22 19:48 FYI: New tests for new class Anthony Balkissoon
2005-11-22 20:14 ` Anthony Balkissoon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).