/* ****************************************************************************
*
* c_str -
*/
TEST(RestrictionString, c_str)
{
  RestrictionString   restrictionString;

  utInit();

  restrictionString.set("STR");
  EXPECT_STREQ("STR", restrictionString.c_str());

  utExit();
}
/* ****************************************************************************
*
* present - no output expected, just exercising the code
*/
TEST(RestrictionString, present)
{
  RestrictionString   restrictionString;

  utInit();

  restrictionString.set("");
  restrictionString.present("");

  restrictionString.set("STR");
  restrictionString.present("");

  utExit();
}
/* ****************************************************************************
*
* isEmptSetAndGet -
*/
TEST(RestrictionString, isEmptySetAndGet)
{
  RestrictionString   restrictionString;

  utInit();

  restrictionString.string = "";
  EXPECT_TRUE(restrictionString.isEmpty());

  restrictionString.set("STR");
  EXPECT_FALSE(restrictionString.isEmpty());

  EXPECT_STREQ("STR", restrictionString.get().c_str());

  utExit();
}
/* ****************************************************************************
*
* check - should RestrictionString::check always return "OK"?
*/
TEST(RestrictionString, check)
{
  RestrictionString   restrictionString;
  std::string         checked;

  utInit();

  checked = restrictionString.check();
  EXPECT_STREQ("OK", checked.c_str());

  restrictionString.string = "String";

  checked = restrictionString.check();
  EXPECT_STREQ("OK", checked.c_str());

  utExit();
}
/* ****************************************************************************
*
* render -
*/
TEST(RestrictionString, render)
{
  RestrictionString   restrictionString;
  std::string         out;
  const char*         outfile1 = "ngsi.restrictionString.render.middle.json";

  utInit();

  out = restrictionString.toJsonV1(false);
  EXPECT_STREQ("", out.c_str());

  restrictionString.string = "String";

  out = restrictionString.toJsonV1(false);
  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), outfile1)) << "Error getting test data from '" << outfile1 << "'";
  EXPECT_STREQ(expectedBuf, out.c_str());

  utExit();
}
/* ****************************************************************************
*
* check - should RestrictionString::check always return "OK"?
*/
TEST(RestrictionString, check)
{
  RestrictionString   restrictionString;
  std::string         checked;

  utInit();

  checked = restrictionString.check(RegisterContext, XML, "", "", 0);
  EXPECT_STREQ("OK", checked.c_str());

  restrictionString.string = "String";

  checked = restrictionString.check(RegisterContext, XML, "", "", 0);
  EXPECT_STREQ("OK", checked.c_str());

  checked = restrictionString.check(RegisterContext, JSON, "", "", 0);
  EXPECT_STREQ("OK", checked.c_str());

  utExit();
}