Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume a developer writes the following source code to concatenate two strings. /* the method is used to concatenate too strings into one. It returns

Assume a developer writes the following source code to concatenate two strings.

/* the method is used to concatenate too strings into one. It returns a string that represents the concatenation of this object's characters followed by the string argument's characters.*/

public String concat(String str) {

int otherLen = str.length();

int len = value.length;

char buf[ ] = Arrays.copyOf(value, len + otherLen);

str.getChars(buf, len);

return new String(buf, true);

}

The expected behavior of the method is to concatenate two strings into one. For example, assume we have two strings s1 and s2. s1= John and s2= Smith.

The concat( ) method can be used to concatenate s1 and s1into s3---the full name of the person (John Smith) by the following statement:

String s3= s1.concat (s2);

Write a unit test to test the methods behavior (do not focus on the source code itself, instead, your unit test will test the behavior/outcome of the method). Write the unit test using

1) any programming languages, or

2) pseudo code, or

3) English statements, or

4) combination of the above.

The unit test needs to include the steps/statements of how it tests the behavior of the concat() method.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions