Question: C++ ONLY Given above is the main.cpp file. Create and implement string.hpp file. Compile main.cpp file (above file) and pass all the above given tests.

 C++ ONLY Given above is the main.cpp file. Create and implement

C++ ONLY

Given above is the main.cpp file. Create and implement string.hpp file.

Compile main.cpp file (above file) and pass all the above given tests.

#include "string.hpp.. #include 4 6 TEST_CASE "String basics", "[string]") using practice::string; 8 9 10 string const s; REQUIRE( s.empty); 12 13 14 15 16 17 18 19 20 21 char const* str-"Hello"; string const hello str ); REQUIRE( hello.length) 5); REQUIRE !hello.empty() ); REQUIRE( hello.c str) !-str ); REQUIRE( std::strcmp( hello.cstr), str string const hello_world( hello +", world") REQUIRE( hello_world"Hello, world"; REQUIRE "Hello, world"hello_world); 23 24 25 26 27 28 29 30 31 32 string hello_bob( hello); hello_bob +- ", Bob"; REQUIRE( hello_bob"Hello, Bob"); REQUIRE( hello_bob [0] 'H'; REQUIRE( hello_bob[1]e'; REQUIRE hello_bob [21 - REQUIRE_THROWS_AS( hello_bob [20], std::range_error); REQUIRE(hello bob.substr) hello bob REQUIRE ( hello, bob, substr( 0, 5 ) hello ); REQUIRE hello_bob.substr( 7, 100) - "Bob"; 34 35 #include "string.hpp.. #include 4 6 TEST_CASE "String basics", "[string]") using practice::string; 8 9 10 string const s; REQUIRE( s.empty); 12 13 14 15 16 17 18 19 20 21 char const* str-"Hello"; string const hello str ); REQUIRE( hello.length) 5); REQUIRE !hello.empty() ); REQUIRE( hello.c str) !-str ); REQUIRE( std::strcmp( hello.cstr), str string const hello_world( hello +", world") REQUIRE( hello_world"Hello, world"; REQUIRE "Hello, world"hello_world); 23 24 25 26 27 28 29 30 31 32 string hello_bob( hello); hello_bob +- ", Bob"; REQUIRE( hello_bob"Hello, Bob"); REQUIRE( hello_bob [0] 'H'; REQUIRE( hello_bob[1]e'; REQUIRE hello_bob [21 - REQUIRE_THROWS_AS( hello_bob [20], std::range_error); REQUIRE(hello bob.substr) hello bob REQUIRE ( hello, bob, substr( 0, 5 ) hello ); REQUIRE hello_bob.substr( 7, 100) - "Bob"; 34 35

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 Databases Questions!