~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to unittests/libdrizzle_test.cc

  • Committer: Mark Atwood
  • Date: 2011-11-20 08:50:16 UTC
  • mfrom: (2461.1.2 drizzle-build)
  • Revision ID: me@mark.atwood.name-20111120085016-2o4no5btx18x2gws
mergeĀ lp:~brianaker/drizzle/libdrizzle-refactor

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