CSCI 200 - Fall 2025
Foundational Programming Concepts & Design

Lab 3B - Strings Test Suite

This lab is due by Friday, October 10, 2025, Before Class.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.

Jump To: · Rubric · Submission ·


Concepts


This assignment introduces you to a simple form of "unit testing" as a mechanism for exploring the string API. Focus on learning what unit tests are, what an "API" is, and what you can do with string objects.


APIs (Application Programming Interface)


As you can see written above, the acronym API stands for Application Programming Interface. But what does that mean? In a nutshell, an API describes what you can do with a particular library or object that you are provided (or that you create). It describes how your code can "interface with" or "use" a particular library or object.

For example, the string API consists of member functions that tell you how long the string is, allow you to capitalize the string, tell you whether it contains a specific character, or allow you to extract a part of the string.

While the API really is the programmatic components that you can actually use, we often rely on API documentation to discover what you can do with a particular library or object. For example, in this lab you will use the string API, and you will need to look up some API documentation about how you can use string objects.


Unit Testing


As entire books have been written on unit testing, we will merely introduce the topic here. A "unit test" is a small piece of code designed to test a specific part of a program's functionality. In other words, they are bits of code that test the functionality of other code!

For this lab, that's all the preliminary information you really need to know about unit testing. You will actually write the unit tests, eventually getting the entire test suite to pass (at which point you should go outside and run a victory lap).


Instructions


A skeletal test suite (a collection of functions) has been provided for you in string_tests.zip. Notice that the functions in this code are defined across multiple files. The functions are grouped into files based on their application. In this case, each string function is performing a single test on a string. The function will need to return the result of the test.

When you first run the program, you will see output similar to below:

Testing your functions...

Test #  1                      Testing string_length():     PASSED   
Test #  2                      Testing string_length():     PASSED   
Test #  3                      Testing string_length():     PASSED   
Test #  4                      Testing string_length():     PASSED   
Test #  5                      Testing string_length():     PASSED

TODO: implement string_char_at("Elephant", 3)
Test #  6                     Testing string_char_at():  !!>FAILED<!! Returned: "" != Expected: "p"
TODO: implement string_char_at("Giraffe", 2)
Test #  7                     Testing string_char_at():  !!>FAILED<!! Returned: "" != Expected: "r"
TODO: implement string_char_at("Armadillo", 4)
Test #  8                     Testing string_char_at():  !!>FAILED<!! Returned: "" != Expected: "d"

[...]

Tests Passed:  34 / 134 (25%)

Not all tests are passing, errors remain...

Your job: complete each TODO using the string API such that all tests pass. You should not modify the contents of run_all_tests() in this lab, and instead only insert code at each TODO statement. When you have finished the task, remove the TODO comment.

You should start by reading the body of the function called run_all_tests() in order to see what your functions must accomplish. For example, the function string_length() must return the length of the string "Now" using the string API. Take a look at the function string_length() to see an example of a successful implementation.

When your program prints PASSED for a given unit test instead of FAILED, then you know that your function implementation for that test is complete.


Hints



Functional Requirements



Grading Rubric


Your submission will be graded according to the following rubric:

PointsRequirement Description
0.70Fully meets specifications
0.15Submitted correctly by Friday, October 10, 2025, Before Class
0.15Best Practices and Style Guide followed
1.00Total Points


Lab Submission


Always, always, ALWAYS update the header comments at the top of your main.cpp file. And if you ever get stuck, remember that there is LOTS of help available.

Zip together your main.cpp, string_functions.cpp, test_suite.cpp, string_functions.h, test_suite.h, LICENSE, README.txt, Makefile file(s) and name the zip file L3B_USERNAME.zip. Upload this zip file to Canvas under L3B.

This lab is due by Friday, October 10, 2025, Before Class.
As with all labs you may, and are encouraged, to pair program a solution to this lab. If you choose to pair program a solution, be sure that you individually understand how to generate the correct solution.