Esempio n. 1
0
 // Static function
 // Split name-value pair around '=' char of the form "name=value"
 AclReader::nvPair AclReader::splitNameValuePair(const std::string& nvpString) {
     std::size_t pos = nvpString.find("=");
     if (pos == std::string::npos || pos == nvpString.size() - 1) {
         return nvPair(nvpString, "");
     }
     return nvPair(nvpString.substr(0, pos), nvpString.substr(pos+1));
 }
Esempio n. 2
0
void testSimple(int& iRet)
{
  ANameValuePair nvPair("name", "alex");
  AString str;
  nvPair.emit(str);
  ASSERT_UNIT_TEST(str.equals("name=alex"), "Simple emit to AString failed", "", iRet);
  ASSERT_UNIT_TEST(nvPair.isName("name"), "Checking name", "", iRet);
  ASSERT_UNIT_TEST(nvPair.isValue("alex"), "Checking value", "", iRet);
  ASSERT_UNIT_TEST(!nvPair.isName("Name"), "Checking against wrong case", "", iRet);
  ASSERT_UNIT_TEST(nvPair.isNameNoCase("Name"), "Compare without case", "", iRet);
}
Esempio n. 3
0
void testJson(int& iRet)
{
  ANameValuePair nvPair(ANameValuePair::JSON);
  size_t pos = 0;
  nvPair.parse(" \r\n \t coLoR :    \t \t  \" green's  yellow \" \r\n} \t ", pos);

  ASSERT_UNIT_TEST(nvPair.isName("coLoR"), "Json name test", "", iRet);
  ASSERT_UNIT_TEST(nvPair.isValue(" green's  yellow "), "Json value test", "", iRet);

  AString str('{');
  nvPair.emit(str);
  str.append('}');
  ASSERT_UNIT_TEST(str.equals("{coLoR:\" green's  yellow \"}"), "Json emit test", "", iRet);
}
Esempio n. 4
0
void testXml(int& iRet)
{
  //a_XML value parsing
  AString str;
  ANameValuePair nvPair(ANameValuePair::XML);
  size_t pos = 0;

  nvPair.parse("  \t \t   \n \r \r\n  iam   \r = \n \t  \"a'b'c'\" \r\n ", pos);
  nvPair.emit(str);
  ASSERT_UNIT_TEST(str == "iam=\"a'b'c'\"", "Handling of single quote in double quote error", "0", iRet);

  pos = 0;
  str.clear();
  nvPair.parse("  \t \t   \n \r \r\n  iam   \r = \t  \"Myvalue's value\"  ", pos);
  nvPair.emit(str);
  ASSERT_UNIT_TEST(str == "iam=\"Myvalue's value\"", "Handling of single quote in double quote error", "1", iRet);

  pos = 0;
  str.clear();
  nvPair.parse("iam = 'is \"quoted\" often'", pos);
  nvPair.emit(str);
  ASSERT_UNIT_TEST(str == "iam='is \"quoted\" often'", "Handling of double quote in single quote error", "", iRet);
}