* [Fwd: [cp-patches] FYI: New GapContent test]
@ 2005-10-18 19:19 Robert Schuster
0 siblings, 0 replies; only message in thread
From: Robert Schuster @ 2005-10-18 19:19 UTC (permalink / raw)
To: mauve-patches
[-- Attachment #1: Type: text/plain, Size: 30 bytes --]
Was posted to the wrong list.
[-- Attachment #2: [cp-patches] FYI: New GapContent test --]
[-- Type: message/rfc822, Size: 10440 bytes --]
[-- Attachment #2.1.1: Type: text/plain, Size: 263 bytes --]
I committed a test for GapContent that I wrote some time ago and that was
still lurking uncommitted on my HD.
2005-10-18 Roman Kennke <kennke@aicas.com>
* gnu/testlet/javax/swing/text/GapContent/insertString.java:
New test.
/Roman
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2.1.2: insertString.java --]
[-- Type: text/x-java; name="insertString.java", Size: 4524 bytes --]
// Tags: JDK1.2
// Copyright (C) 2005 Roman Kennke <kennke@aicas.com>
// 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.GapContent;
import javax.swing.text.BadLocationException;
import javax.swing.text.GapContent;
import gnu.testlet.TestHarness;
import gnu.testlet.Testlet;
/**
* Tests if GapContent.insertString works correctly.
*
* @author Roman Kennke (kennke@aicas.com)
*/
public class insertString implements Testlet
{
/**
* A subclass of GapContent that provides access to the protected methods.
*/
class TestGapContent extends GapContent
{
public int getArrayLength()
{
return super.getArrayLength();
}
public int getTestGapStart()
{
return super.getGapStart();
}
public int getTestGapEnd()
{
return super.getGapEnd();
}
}
/**
* Start the test run.
*
* @see gnu.testlet.Testlet#test(gnu.testlet.TestHarness)
*/
public void test(TestHarness harness)
{
testSmallInsert(harness);
testBiggerInsert(harness);
testBigInsert(harness);
testComplexInsert(harness);
}
/**
* Tests the insertion of a small (< gapsize) chunk of text.
*
* @param harness the test harness to use
*/
void testSmallInsert(TestHarness harness)
{
harness.checkPoint("smallInsert");
try
{
TestGapContent c = new TestGapContent();
checkBuffer(harness, c, 10, 1, 10);
c.insertString(0, "abcdefgh");
checkBuffer(harness, c, 10, 8, 9);
}
catch (BadLocationException ex)
{
harness.fail("BadLocationException thrown.");
}
}
/**
* Tests the insertion of a bigger (= gapsize) chunk of text.
*
* @param harness the test harness to use
*/
void testBiggerInsert(TestHarness harness)
{
harness.checkPoint("biggerInsert");
try
{
TestGapContent c = new TestGapContent();
checkBuffer(harness, c, 10, 1, 10);
c.insertString(0, "abcdefghi");
checkBuffer(harness, c, 22, 9, 21);
}
catch (BadLocationException ex)
{
harness.fail("BadLocationException thrown.");
}
}
/**
* Tests the insertion of a bigger (= gapsize) chunk of text.
*
* @param harness the test harness to use
*/
void testBigInsert(TestHarness harness)
{
harness.checkPoint("bigInsert");
try
{
TestGapContent c = new TestGapContent();
checkBuffer(harness, c, 10, 1, 10);
c.insertString(0, "abcdefghijkl");
checkBuffer(harness, c, 28, 12, 27);
}
catch (BadLocationException ex)
{
harness.fail("BadLocationException thrown.");
}
}
/**
* Tests a more complex insertion.
*
* @param harness the test harness to use
*/
void testComplexInsert(TestHarness harness)
{
harness.checkPoint("complexInsert");
try
{
TestGapContent c = new TestGapContent();
checkBuffer(harness, c, 10, 1, 10);
c.insertString(0, "abcdefghijklmno");
checkBuffer(harness, c, 34, 15, 33);
c.insertString(5, "12345");
checkBuffer(harness, c, 34, 10, 23);
}
catch (BadLocationException ex)
{
harness.fail("BadLocationException thrown.");
}
}
/**
* Checks the state of the GapContent's buffer array.
*
* @param harness the test harness to use
* @param c the gap content to check
* @param arrayLength the expected array length
* @param gapStart the expected gap start
* @param gapEnd the expected gap end
*/
void checkBuffer(TestHarness harness, TestGapContent c, int arrayLength,
int gapStart, int gapEnd)
{
harness.check(c.getArrayLength(), arrayLength);
harness.check(c.getTestGapStart(), gapStart);
harness.check(c.getTestGapEnd(), gapEnd);
}
}
[-- Attachment #2.1.3: Type: text/plain, Size: 161 bytes --]
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-10-18 19:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-18 19:19 [Fwd: [cp-patches] FYI: New GapContent test] Robert Schuster
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).