Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
