~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to unittests/libdrizzle_test.cc

  • Committer: Mark Atwood
  • Date: 2011-11-14 07:30:41 UTC
  • Revision ID: me@mark.atwood.name-20111114073041-mo2hgg8ouseo2kpu
releaseĀ 2011.11.29

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
{
32
32
  const char* orig= "hello \"world\"\n";
33
33
  char out[255];
 
34
  size_t out_len;
34
35
 
35
 
  ssize_t out_len= drizzle_escape_string(out, sizeof(out), orig, strlen(orig));
 
36
  out_len= drizzle_escape_string(out, orig, strlen(orig));
36
37
 
37
38
  BOOST_REQUIRE_EQUAL(17, out_len);
38
39
  BOOST_REQUIRE_EQUAL("hello \\\"world\\\"\\n", out);
42
43
{
43
44
  const char orig[6]= {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
44
45
  char out[255];
 
46
  size_t out_len;
45
47
 
46
 
  ssize_t out_len= drizzle_escape_string(out, sizeof(out), orig, 6);
 
48
  out_len= drizzle_escape_string(out, orig, 6);
47
49
 
48
50
  BOOST_REQUIRE_EQUAL(7, out_len);
49
51
  BOOST_REQUIRE_EQUAL("\\0\1\2\3\4\5", out);
53
55
{
54
56
  const char* orig= "hello \"world\"\n";
55
57
  char out[255];
 
58
  ssize_t out_len;
56
59
 
57
 
  ssize_t out_len= drizzle_escape_string(out, sizeof(out), orig, strlen(orig));
 
60
  out_len= drizzle_safe_escape_string(out, 255, orig, strlen(orig));
58
61
 
59
62
  BOOST_REQUIRE_EQUAL(17, out_len);
60
63
  BOOST_REQUIRE_EQUAL("hello \\\"world\\\"\\n", out);
64
67
{
65
68
  const char* orig= "hello \"world\"\n";
66
69
  char out[5];
 
70
  ssize_t out_len;
67
71
 
68
 
  ssize_t out_len= drizzle_escape_string(out, sizeof(out), orig, strlen(orig));
 
72
  out_len= drizzle_safe_escape_string(out, 5, orig, strlen(orig));
69
73
 
70
74
  BOOST_REQUIRE_EQUAL(-1, out_len);
71
75
}
74
78
{
75
79
  const unsigned char orig[5]= {0x34, 0x26, 0x80, 0x99, 0xFF};
76
80
  char out[255];
 
81
  size_t out_len;
77
82
 
78
 
  size_t out_len= drizzle_hex_string(out, (char*) orig, 5);
 
83
  out_len= drizzle_hex_string(out, (char*) orig, 5);
79
84
 
80
85
  BOOST_REQUIRE_EQUAL(10, out_len);
81
86
  BOOST_REQUIRE_EQUAL("34268099FF", out);