This is the mail archive of the mauve-patches@sources.redhat.com mailing list for the Mauve project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Attached is a patch to add tests for the javax.swing.SpinnerListModel class. Okay to commit? Cheers, -- Andrew :-) Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html Value your freedom, or you will lose it, teaches history. `Don't bother us with politics' respond those who don't want to learn.
? spinnerlistmodel-tests.diff Index: ArrayModel.java =================================================================== RCS file: ArrayModel.java diff -N ArrayModel.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ArrayModel.java 12 Oct 2004 19:07:14 -0000 @@ -0,0 +1,62 @@ +// Tags: JDK1.4 + +// Copyright (C) 2004 Andrew John Hughes <gnu_andrew@member.fsf.org> + +// 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.SpinnerListModel; + +import gnu.testlet.Testlet; +import gnu.testlet.TestHarness; +import javax.swing.SpinnerListModel; + +public class ArrayModel implements Testlet +{ + + public void test(TestHarness harness) + { + SpinnerListModel model; + Object[] array; + + /* Create array */ + array = new Object[]{"GNU", "Classpath"}; + /* Create model */ + model = new SpinnerListModel(array); + /* Check retrieval */ + harness.check(model.getList() != null, "Array model creation check"); + harness.check(model.getValue(), "GNU", "Array model current value check"); + harness.check(model.getNextValue(), "Classpath", "Array model next value check"); + harness.check(model.getValue(), "GNU", "Array model no change of current value after next check"); + harness.check(model.getPreviousValue(), null, "Array model previous value check"); + /* Value change check */ + array[0] = "GNU's Not UNIX"; + harness.check(model.getValue(), "GNU's Not UNIX", "Array model backing list change check"); + /* Value setting check */ + model.setValue("Classpath"); + harness.check(model.getValue(), "Classpath", "Array model successful set check"); + try + { + model.setValue("Sun"); + harness.fail("Exception not thrown for non-existant value with array model."); + } + catch (IllegalArgumentException exception) + { + /* Success */ + } + } +} Index: Constructors.java =================================================================== RCS file: Constructors.java diff -N Constructors.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Constructors.java 12 Oct 2004 19:07:14 -0000 @@ -0,0 +1,73 @@ +// Tags: JDK1.4 + +// Copyright (C) 2004 Andrew John Hughes <gnu_andrew@member.fsf.org> + +// 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.SpinnerListModel; + +import gnu.testlet.Testlet; +import gnu.testlet.TestHarness; +import java.util.ArrayList; +import javax.swing.SpinnerListModel; + +public class Constructors implements Testlet +{ + + public void test(TestHarness harness) + { + SpinnerListModel model; + + /* Invalid values */ + try + { + model = new SpinnerListModel((Object[]) null); + harness.fail("Null array supplied to constructor failed to throw an exception."); + } + catch (IllegalArgumentException exception) + { + /* Success */ + } + try + { + model = new SpinnerListModel(new ArrayList()); + harness.fail("Empty list supplied to constructor failed to throw an exception."); + } + catch (IllegalArgumentException exception) + { + /* Success */ + } + try + { + model = new SpinnerListModel(new Object[]{}); + harness.fail("Empty array supplied to constructor failed to throw an exception."); + } + catch (IllegalArgumentException exception) + { + /* Success */ + } + + /* Test the default model */ + model = new SpinnerListModel(); + harness.check(model.getList() != null, "Default list construction check."); + harness.check(model.getValue(), "empty", "Default list current value check."); + harness.check(model.getNextValue(), null, "Default list next value check."); + harness.check(model.getPreviousValue(), null, "Default list previous value check."); + + } +} Index: ListModel.java =================================================================== RCS file: ListModel.java diff -N ListModel.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ListModel.java 12 Oct 2004 19:07:14 -0000 @@ -0,0 +1,66 @@ +// Tags: JDK1.4 + +// Copyright (C) 2004 Andrew John Hughes <gnu_andrew@member.fsf.org> + +// 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.SpinnerListModel; + +import gnu.testlet.Testlet; +import gnu.testlet.TestHarness; +import java.util.ArrayList; +import java.util.List; +import javax.swing.SpinnerListModel; + +public class ListModel implements Testlet +{ + + public void test(TestHarness harness) + { + SpinnerListModel model; + List list; + + /* Create list */ + list = new ArrayList(); + list.add("GNU"); + list.add("Classpath"); + /* Create model */ + model = new SpinnerListModel(list); + /* Check retrieval */ + harness.check(model.getList() != null, "List model creation check"); + harness.check(model.getValue(), "GNU", "List model current value check"); + harness.check(model.getNextValue(), "Classpath", "List model next value check"); + harness.check(model.getValue(), "GNU", "List model no change of current value after next check"); + harness.check(model.getPreviousValue(), null, "List model previous value check"); + /* Value change check */ + list.set(0, "GNU's Not UNIX"); + harness.check(model.getValue(), "GNU's Not UNIX", "List model backing list change check"); + /* Value setting check */ + model.setValue("Classpath"); + harness.check(model.getValue(), "Classpath", "List model successful set check"); + try + { + model.setValue("Sun"); + harness.fail("Exception not thrown for non-existant value with list model."); + } + catch (IllegalArgumentException exception) + { + /* Success */ + } + } +} Index: Ordering.java =================================================================== RCS file: Ordering.java diff -N Ordering.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Ordering.java 12 Oct 2004 19:07:14 -0000 @@ -0,0 +1,58 @@ +// Tags: JDK1.4 + +// Copyright (C) 2004 Andrew John Hughes <gnu_andrew@member.fsf.org> + +// 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.SpinnerListModel; + +import gnu.testlet.Testlet; +import gnu.testlet.TestHarness; +import java.util.ArrayList; +import java.util.List; +import javax.swing.SpinnerListModel; + +public class Ordering implements Testlet +{ + + public void test(TestHarness harness) + { + SpinnerListModel model; + List list; + + /* Create list */ + list = new ArrayList(); + list.add("a"); + list.add("z"); + list.add("a"); + list.add("b"); + /* Create model */ + model = new SpinnerListModel(list); + /* Check retrieval */ + harness.check(model.getList() != null, "Array model ordering creation check"); + harness.check(model.getValue(), "a", "Array model ordering current value check"); + harness.check(model.getNextValue(), "z", "Array model ordering next value check"); + harness.check(model.getValue(), "a", "Array model ordering no change of current value after next check"); + harness.check(model.getPreviousValue(), null, "Array model ordering previous value check"); + /* Value ordering of setting check */ + model.setValue("a"); + harness.check(model.getValue(), "a", "Array model ordering successful set check"); + harness.check(model.getPreviousValue(), null, "Array model ordering post-set previous value check"); + harness.check(model.getNextValue(), "z", "Array model ordering post-set next value check"); + } +} Index: SetList.java =================================================================== RCS file: SetList.java diff -N SetList.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ SetList.java 12 Oct 2004 19:07:14 -0000 @@ -0,0 +1,67 @@ +// Tags: JDK1.4 + +// Copyright (C) 2004 Andrew John Hughes <gnu_andrew@member.fsf.org> + +// 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.SpinnerListModel; + +import gnu.testlet.Testlet; +import gnu.testlet.TestHarness; +import java.util.ArrayList; +import java.util.List; +import javax.swing.SpinnerListModel; + +public class SetList implements Testlet +{ + +public void test(TestHarness harness) +{ + SpinnerListModel model; + List list; + + /* Create default model */ + model = new SpinnerListModel(); + /* Invalid values */ + try + { + model.setList((ArrayList) null); + harness.fail("Null list supplied to setList failed to throw an exception."); + } + catch (IllegalArgumentException exception) + { + /* Success */ + } + try + { + model.setList(new ArrayList()); + harness.fail("Empty list supplied to setList failed to throw an exception."); + } + catch (IllegalArgumentException exception) + { + /* Success */ + } + + /* Test a successful change */ + list = new ArrayList(); + list.add("GNU"); + model.setList(list); + harness.check(model.getList(), list, "Model allowed successful change of list."); + } + +}
Attachment:
signature.asc
Description: This is a digitally signed message part
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |