~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to unittests/libdrizzle_test.cc

  • Committer: Monty Taylor
  • Author(s): Andrew Hutchings
  • Date: 2011-03-14 16:54:30 UTC
  • mto: (2235.2.1 build)
  • mto: This revision was merged to the branch mainline in revision 2237.
  • Revision ID: mordred@inaugust.com-20110314165430-sfnwk7ek1b9nytb2
Add drizzle_safe_escape_string() function

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
  BOOST_REQUIRE_EQUAL("\\0\1\2\3\4\5", out);
52
52
}
53
53
 
 
54
BOOST_AUTO_TEST_CASE(drizzleSafeEscapeString)
 
55
{
 
56
  const char* orig= "hello \"world\"\n";
 
57
  char out[255];
 
58
  ssize_t out_len;
 
59
 
 
60
  out_len= drizzle_safe_escape_string(out, 255, orig, strlen(orig));
 
61
 
 
62
  BOOST_REQUIRE_EQUAL(17, out_len);
 
63
  BOOST_REQUIRE_EQUAL("hello \\\"world\\\"\\n", out);
 
64
}
 
65
 
 
66
BOOST_AUTO_TEST_CASE(drizzleSafeEscapeStringFail)
 
67
{
 
68
  const char* orig= "hello \"world\"\n";
 
69
  char out[5];
 
70
  ssize_t out_len;
 
71
 
 
72
  out_len= drizzle_safe_escape_string(out, 5, orig, strlen(orig));
 
73
 
 
74
  BOOST_REQUIRE_EQUAL(-1, out_len);
 
75
}
54
76
 
55
77
BOOST_AUTO_TEST_CASE(drizzleHexString)
56
78
{