The purpose of this activity is to become familiar with the Software Testing Practical, identify any relevant questions, think about what kind of information you might need to know, and to look at the code you are about to test. You should do the following (3 tasks):
sortStrings
method by changing only one character in the file and then try to work out a test that would uncover the error.
Source extract for Sorter : |
---|
public class Sorter { public static interface Swapper { public void swap(Vector values, int left, int right); } public static void sortStrings(Vector values , int left, int right, Swapper swapper) { int oleft= left; int oright= right; String mid= (String)values.elementAt((left + right) / 2); do { while (((String)(values.elementAt(left))).compareTo(mid) < 0) left++; while (mid.compareTo((String)(values.elementAt(right))) < 0) right--; if (left <= right) { swapper.swap(values, left, right); left++; right--; } } while (left <= right); if (oleft < right) sortStrings(values, oleft, right, swapper); if (left < oright) sortStrings(values, left, oright, swapper); } } |
Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, Scotland, UK
Tel: +44 131 651 5661, Fax: +44 131 651 1426, E-mail: school-office@inf.ed.ac.uk Please contact our webadmin with any comments or corrections. Logging and Cookies Unless explicitly stated otherwise, all material is copyright © The University of Edinburgh |