Question: FIX CODE TO PASS TESTS: . / test Running main ( ) from / root / googletest _ project / _ deps / googletest -

FIX CODE TO PASS TESTS:
./test
Running main() from /root/googletest_project/_deps/googletest-src/googletest/src/gtest_main.cc
[==========] Running 11 tests from 1 test suite.
[----------] Global test environment set-up.
[----------]11 tests from A1
[ RUN ] A1.EncryptSimpleLowercase
[ OK ] A1.EncryptSimpleLowercase (0 ms)
[ RUN ] A1.EncryptSimpleUppercase
[ OK ] A1.EncryptSimpleUppercase (0 ms)
[ RUN ] A1.EncryptSpace
[ OK ] A1.EncryptSpace (0 ms)
[ RUN ] A1.EncryptYieldingSpace
tests/test_a1.cpp:21: Failure
Expected equality of these values:
encrypt('a',-1)
Which is: 'z'(122,0x7A)
''
Which is: ''(32,0x20)
[ FAILED ] A1.EncryptYieldingSpace (0 ms)
[ RUN ] A1.EncryptLargeLeftShift
tests/test_a1.cpp:25: Failure
Expected equality of these values:
encrypt('c',-200)
Which is: 'Q'(81,0x51)
's'
Which is: 's'(115,0x73)
[ FAILED ] A1.EncryptLargeLeftShift (0 ms)
[ RUN ] A1.EncryptLargeRightShift
tests/test_a1.cpp:29: Failure
Expected equality of these values:
encrypt('c',200)
Which is: 'u'(117,0x75)
'n'
Which is: 'n'(110,0x6E)
[ FAILED ] A1.EncryptLargeRightShift (0 ms)
[ RUN ] A1.DecryptSimple
[ OK ] A1.DecryptSimple (0 ms)
[ RUN ] A1.DecryptSpace
tests/test_a1.cpp:39: Failure
Expected equality of these values:
decrypt('',-1)
Which is: 'z'(122,0x7A)
'a'
Which is: 'a'(97,0x61)
[ FAILED ] A1.DecryptSpace (0 ms)
[ RUN ] A1.DecryptYieldingSpace
tests/test_a1.cpp:43: Failure
Expected equality of these values:
decrypt('z',-1)
Which is: 'a'(97,0x61)
''
Which is: ''(32,0x20)
[ FAILED ] A1.DecryptYieldingSpace (0 ms)
[ RUN ] A1.DecryptLargeLeftShift
tests/test_a1.cpp:48: Failure
Expected equality of these values:
decrypt('s',-200)
Which is: 'k'(107,0x6B)
'c'
Which is: 'c'(99,0x63)
[ FAILED ] A1.DecryptLargeLeftShift (0 ms)
[ RUN ] A1.DecryptLargeRightShift
tests/test_a1.cpp:52: Failure
Expected equality of these values:
decrypt('n',200)
Which is: '\\'(92,0x5C)
'c'
Which is: 'c'(99,0x63)
[ FAILED ] A1.DecryptLargeRightShift (0 ms)
[----------]11 tests from A1(0 ms total)
[----------] Global test environment tear-down
[==========]11 tests from 1 test suite ran. (0 ms total)
[ PASSED ]4 tests.
[ FAILED ]7 tests, listed below:
[ FAILED ] A1.EncryptYieldingSpace
[ FAILED ] A1.EncryptLargeLeftShift
[ FAILED ] A1.EncryptLargeRightShift
[ FAILED ] A1.DecryptSpace
[ FAILED ] A1.DecryptYieldingSpace
[ FAILED ] A1.DecryptLargeLeftShift
[ FAILED ] A1.DecryptLargeRightShift
7 FAILED TESTS
make: ***[makefile:9: test] Error 1
ENCRYPT.CPP:
#include
#include
#include
#include "encrypt.h"
// Function to shift characters \
char shift_char(char c, int shift){
if (c >='a' && c <='z'){
return static_cast('a'+(((c -'a')+ shift +26)%26));
} else if (c ==''){
return '';
}
return c;
}
// Encrypt single char \
char encrypt(char c, int shift){
return shift_char(c, shift);
}
// Decrypt single char \
char decrypt(char c, int shift){
return shift_char(c,-shift);
}
void process(char mode, int shift, char dir){
int effective_shift =(dir =='l')?-shift : shift;
std::string phrase;
std::cout << "Enter the phrase to "<<(mode =='e'? "encrypt: " : "decryp\
t: ");
std::getline(std::cin, phrase);
std::cout << "Result: ";
for (char c : phrase){
if (mode =='e'){
std::cout << encrypt(c, effective_shift);
} else {
std::cout << decrypt(c, effective_shift);
}
}
std::cout << std::endl;
}
// Define and use at least one useful private function
// Public functions
// Define and implement the functions declared in encrypt.h here.
MAIN.CPP:
#include
#include "encrypt.h"
#include
using namespace std;
// Function declarations \
char main_menu();
void get_opts(int &shift, char &dir);
// Display the main menu and return the selected option \
char main_menu(){
char choice;
do {
std::cou

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!