Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create unit tests for functions using CppUnitTest, Execute the tests under Visual Studio. Instructions You will create code to store information on a customer including:
Create unit tests for functions using CppUnitTest,
Execute the tests under Visual Studio.
Instructions
You will create code to store information on a customer including:
The customers first and last name,
The customer street address,
The customer city,
The customer province,
The customer postal code.
You should:
Create a structure to store the information on the customer,
Create a function to prompt the user to enter the customer information on the command line
and store it in the structure. This function will ensure that every field has a value and that the
postal code is valid. If any are not valid, it will prompt the user until a valid value is entered. This
function will return a structure that is guaranteed to have values in each field and have a valid
postal code.
Create a function to test the validity of the postal code and return a Boolean true if the code is
valid and a Boolean false if the code is invalid. It should accept postal code in upper or lower
case and translate them all to upper case. It should also accept them with no spaces or several
spaces between the groups of characters. It will return the postal code in uppercase with one
space between the groups of characters.
Create a main that invokes the function to get the data into the structure and then prints out
the contents of the structure.
NOTE that the function fgets used with the stdin stream will read a string until end of line and add a
at the end of the string. This will reliably determine if an empty string was entered.
A typical use of the function to read customer data is:
Enter your first name: John
Enter your last name:
Invalid Entry: Enter your last name: Smith
Enter your street address: Elm St
Enter your city: Toronto
Enter your province: ON
Enter your postal code:mex
Invalid Entry: Enter your postal code: me x
You entered:
John Smith
Elm St
Toronto, ON
ME X
Once you complete the two or more functions and the main program, you should create a test project
in the same Visual Studio solution. Then design and build unit tests for the two functions you created.
You should include both black box and white box unit tests. Comment each test so that the instructor
knows what you are testing. Be sure to use appropriate test data.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started