[SOLVED] CSCI1302 - TextLine Test Plans

30.00 $

Category:

Description

5/5 - (2 votes)

TextLine Test Plans

Operation Purpose Object State Expected Result
EditableTextLine empty = new EditableTextLine(); To create an empty

EditableTextLine instance.

lineLength = 0; arr = {}; capacity = 80 A new

EditableTextLine with an empty array.

EditableTextLine t1 = new new

EditableTextLine(“Bulldawg” );

To create an EditableTextLine instance containing a line less than 80 characters, less characters than the default capacity of a TextLine. lineLength = 8 arr = {“B”, “u”, … ,

“g”} capacity = 80

A new

EditableTextLine with an array containing the characters of “Bulldawg”.

To create an EditableTextLine instance containing a line more than 80 characters, more characters than the default capacity of a TextLine. lineLength = 122 arr = {“W”, “e”, “l”, … , “g”, “e”, “!”} capacity = 160 A new

EditableTextLine with a char array containing a string with more than 80 characters.

TextLine duplicate = t2; To verify whether late-binding applies between

EditableTextLine and Textline

lineLength = 8 arr = {“B”, “u”, … ,

“g”} capacity = 80

A new

EditableTextLine copy of t2 with the type TextLine.

EditableTextLine t3 = new EditableTextLine(“I am trying my best to make this string as long as I can. What else can I add?” ); To create an EditableTextLine instance containing a string just below the DEFAULT_SIZE. lineLength = 78

arr = {“I”, “a”, “m”,

…, “?”} capacity = 80

A new

EditableTextLine with a char array containing a string just below 80 characters.

t1.length(); t2.length(); t3.length(); To verify the getter method for the length of a TextLine instance. 8

86

78

t1.capacity(); t2.capacity(); t3.capacity(); To verify the getter method for the capacity of a TextLine. 80

160

80

t1.indexOf(“dawg”); t2.indexOf(“depart”); To verify the indexOf method without a start index 4

59

t1.indexOf(“ll”, 1); t2.indexOf(“fast”, 10); To verify the indexOf method with a start index. 2

79

 

t1.indexOf(“ll”, 1); t2.indexOf(“fast”, 10); To verify the indexOf method throws an exception. TextLineIndexOutOf Bounds
t1.equals(duplicate); t2.equals(duplicate); To verify that the equals method makes the correct comparison. False True
t1.toString(); To verify that the toString method produces the proper String representation. “Bulldawg”
t1.append(“ Bucks”) To verify that this method properly appends characters to the end of the line. lineLength = 14 arr = {“B”, “u”, … , “c”, “k”, “s”} capacity = 80 “Bulldawg Bucks”
t3.append(“ I can add this sentence!”); To verify proper reallocation of the internal buffer when append adds more characters than the original capacity. lineLength = 103 arr = {“I”, “a”, “m”, …, “c”,“e”,“.”} capacity = 160 An extended TextLine that now exceeds the initial capacity of 80.
t1.insert(0, “UGA ”); To verify that the insert method properly inserts a fragment at the beginning of the TextLine. lineLength = 12 arr = {“U”, “G”, … ,

“g”} capacity = 80

An extended

TextLine containing

“UGA Bulldawg”

t1.insert(5, “horn”); To verify that the insert method properly inserts a fragment in the middle of the TextLine. lineLength = 12 arr = {“B”, … , “h”,

“o”, “r”, “n” , … ,

“g”} capacity = 80

An extended

TextLine containing

“Bullhorndawg”

t1.insert(t1.length(), “ House” To verify that the insert method properly inserts a fragment at the end of a TextLine. lineLength = 14 arr = {“B”, … , “u”,

“s”, “e”} capacity = 80

An extended

TextLine containing

“Bulldawg House”

t3.insert(t3.length(), “ I can add something like this!”) To verify that the insert method properly reallocates memory if the new TextLine exceeds initial capacity. lineLength = 109 arr = {“I”, “a”, “m”,

…, “t” “h”, “i”, “s”,

“!”} capacity = 160

An extended

TextLine whose length extends the default size.

t1.insert(100, “hello”); t2.insert(2346, “nice”); t3.insert(356, “wow”); To verify that the insert method throws an exception when the given index (beyond the length TextLineIndexOutOf Bounds

 

of the textline) is illegal.
t1.insert( -24, “America”); t2.insert(-193, “USA”); t3.insert(-12, “Georgia”); To verify that the insert method throws an exception when the given index (before index 0) is illegal. TextLineIndexOutOf Bounds
t1.replace(4, t1.length(), “cat”); To verify that the replace method can work with a fragment that is smaller than the text being replaced. lineLength = 7 arr = {“B”, “u”, … , “c”, “a”, “t”} capacity = 80 A new TextLine where “dawg” is replaced with “cat” bullcat
t2.replace(79, 86, “slowest”); To verify that the replace method can work with a fragment that is the same size as the text being replaced. lineLength = 122 arr = {“W”, “e”, “l”, … , “g”, “e”, “!”} capacity = 160 A new TextLine where the word

“fastest” is replaced with “slowest”

t2.replace(15, 36, To verify that the replace method can work with a fragment that is longer than the text being replaced. lineLength = 132 arr = {“W”, “e”, “l”, … , “g”, “e”, “!”} capacity = 160
t3.replace(74, 78, “not add?”); To verify that the replace method properly reallocates memory if the new TextLine exceeds initial capacity. lineLength = 82

arr = {“I”, “a”, “m”,

…, “?”} capacity = 160

A new TextLine where the word “add” is replaced with “not add”
t1.replace(-6, 3, “cat”); t2.replace(-10, 15, To verify that the replace method will throw an exception if the given start index is illegal. TextLineIndexOutOf Bounds
t1.replace(4, t1.length() + 17,

“cat”);

t2.replace(15, 123456,

To verify that the replace method will throw an exception if the given end index is illegal. TextLineIndexOutOf Bounds