Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I ' m trying to run some test cases as you can see below for my isValidPostalCode function but for some reason it keeps failing
Im trying to run some test cases as you can see below for my isValidPostalCode function but for some reason it keeps failing with the code C I need some help figuring this out to help get my test to pass. its telling me that the problem is within my isValidPostalCode function particularly this line of code postalCodei toupperpostalCodei so I need some help to figure it out.
#define CRTSECURENOWARNINGS
#include
#include
#include
#include
#include "customer.h
struct Customer getCustomerInfovoid
struct Customer customer;
printfEnter your first name: ;
fgetscustomerfirstName, sizeofcustomerfirstName stdin;
customer.firstNamestrcspncustomerfirstName,
;
while
printfEnter your last name: ;
fgetscustomerlastName, sizeofcustomerlastName stdin;
customer.lastNamestrcspncustomerlastName,
;
if strlencustomerlastName
break;
else
printfInvalid Entry: ;
printfEnter your street address: ;
fgetscustomeraddress, sizeofcustomeraddress stdin;
customer.addressstrcspncustomeraddress,
;
printfEnter your city: ;
fgetscustomercity, sizeofcustomercity stdin;
customer.citystrcspncustomercity,
;
printfEnter your province: ;
fgetscustomerprovince, sizeofcustomerprovince stdin;
customer.provincestrcspncustomerprovince,
;
int c;
while c getchar
&& c EOF;
while
printfEnter your postal code: ;
fgetscustomerpostalCode, sizeofcustomerpostalCode stdin;
customer.postalCodestrcspncustomerpostalCode,
;
if isValidPostalCodecustomerpostalCode
break;
else
printfInvalid Entry: ;
return customer;
int isValidPostalCodechar postalCode
int i;
for i ; i ; i
postalCodei toupperpostalCodei;
if isalphapostalCode && isdigitpostalCode && isalphapostalCode &&
postalCode &&
isdigitpostalCode && isalphapostalCode &&
strlenpostalCode
return ;
else
return ;
int mainvoid
struct Customer customer getCustomerInfo;
printf
You entered:
s s
s
ss
s
customer.firstName, customer.lastName,
customer.address,
customer.city, customer.province,
customer.postalCode;
return ;
#pragma once
#ifndef CUSTOMERH
#define CUSTOMERH
struct Customer
char firstName;
char lastName;
char address;
char city;
char province;
char postalCode;
;
int isValidPostalCodechar postalcode;
struct Customer getCustomerInfovoid;
#endif
#include pchh
#include "CppUnitTest.h
#include "CustomerTestrh
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
TESTCLASSCustomerInfoTestBlackbox
public:
TESTMETHODBlackBoxValidPostalCode
Assert::IsTrueisValidPostalCodeKM G;
TESTMETHODBlackBoxInvalidLength
Assert::IsFalseisValidPostalCodeAB RX;
TESTMETHODBlackBoxExtraSpace
Assert::IsFalseisValidPostalCodeAB R;
TESTMETHODBlackBoxMissingSpace
Assert::IsFalseisValidPostalCodeABR;
TESTMETHODBlackBoxAlphanumericCharacters
Assert::IsFalseisValidPostalCodeAB RX;
TESTMETHODBlackBoxSpecialCharacters
Assert::IsFalseisValidPostalCodeAB R#;
;
TESTCLASSCustomerInfoTestWhitebox
public:
TESTMETHODWhiteBoxUppercaseConversion
Assert::IsTrueisValidPostalCodeab r;
TESTMETHODWhiteBoxEmptyString
Assert::IsFalseisValidPostalCode;
TESTMETHODWhiteBoxNullPointer
Assert::IsFalseisValidPostalCodenullptr;
TESTMETHODWhiteBoxIndividualChecksNumericOnly
Assert::IsFalseisValidPostalCode;
TESTMETHODWhiteBoxIndividualChecksAlphabeticOnly
Assert::IsFalseisValidPostalCodeABC DEF";
TESTMETHODWhiteBoxIndividualChecksSpaceOnly
Assert::IsFalseisValidPostalCode;
TESTMETHODWhiteBoxLongInvalidPostalCode
Assert::IsFalseisValidPostalCodeMA AX;
TESTMETHODWhiteBoxCaseSensitivityUppercase
Assert::IsTrueisValidPostalCodeab r;
TESTMETHODWhiteBoxCaseSensitivityLowercase
Assert::IsTrueisValidPostalCodeAB R;
;
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