Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions