#include <string>
#include <testsuite_hooks.h>
enum want_value {lt=0, z=1, gt=2};
int
test_value(int result, want_value expected);
int
test_value(int result, want_value expected)
{
bool test __attribute__((unused)) = true;
bool pass = false;
switch (expected) {
case lt:
if (result < 0)
pass = true;
break;
case z:
if (!result)
pass = true;
break;
case gt:
if (result > 0)
pass = true;
break;
default:
pass = false; }
VERIFY(pass);
return 0;
}
int
test01()
{
using namespace std;
string str_0("costa rica");
string str_1("costa marbella");
string str_2;
test_value(strcmp("costa marbella", "costa rica"), lt);
test_value(strcmp("costa rica", "costa rica"), z);
test_value(strcmp(str_1.data(), str_0.data()), lt);
test_value(strcmp(str_0.data(), str_1.data()), gt);
test_value(strncmp(str_1.data(), str_0.data(), 6), z);
test_value(strncmp(str_1.data(), str_0.data(), 14), lt);
test_value(memcmp(str_1.data(), str_0.data(), 6), z);
test_value(memcmp(str_1.data(), str_0.data(), 14), lt);
test_value(memcmp("costa marbella", "costa rica", 14), lt);
test_value(str_0.compare(str_1), gt); test_value(str_1.compare(str_0), lt); str_2 = str_0;
test_value(str_2.compare(str_0), z);
str_2 = "cost";
test_value(str_2.compare(str_0), lt);
str_2 = "costa ricans";
test_value(str_2.compare(str_0), gt);
test_value(str_1.compare(0, 6, str_0), lt);
str_2 = "cost";
test_value(str_1.compare(0, 4, str_2), z);
test_value(str_1.compare(0, 5, str_2), gt);
test_value(str_1.compare(0, 6, str_0, 0, 6), z);
test_value(str_1.compare(0, 7, str_0, 0, 7), lt);
test_value(str_0.compare(0, 7, str_1, 0, 7), gt);
test_value(str_0.compare("costa marbella"), gt);
test_value(str_1.compare("costa rica"), lt);
str_2 = str_0;
test_value(str_2.compare("costa rica"), z);
test_value(str_2.compare("cost"), gt);
test_value(str_2.compare("costa ricans"), lt);
test_value(str_1.compare(0, 6, "costa rica", 0, 6), z);
test_value(str_1.compare(0, 7, "costa rica", 0, 7), lt);
test_value(str_0.compare(0, 7, "costa marbella", 0, 7), gt);
return 0;
}
int
main()
{
test01();
return 0;
}