~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to unittests/libdrizzle_test.cc

  • Committer: Olaf van der Spek
  • Date: 2011-07-04 19:11:47 UTC
  • mto: This revision was merged to the branch mainline in revision 2367.
  • Revision ID: olafvdspek@gmail.com-20110704191147-s99ojek811zi1fzj
RemoveĀ unusedĀ Name_resolution_context::error_reporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include "config.h"
 
21
#include <config.h>
22
22
 
23
23
#define BOOST_TEST_DYN_LINK
24
24
#include <boost/test/unit_test.hpp>
39
39
  BOOST_REQUIRE_EQUAL("hello \\\"world\\\"\\n", out);
40
40
}
41
41
 
 
42
BOOST_AUTO_TEST_CASE(drizzleEscapeStringBinary)
 
43
{
 
44
  const char orig[6]= {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
 
45
  char out[255];
 
46
  size_t out_len;
 
47
 
 
48
  out_len= drizzle_escape_string(out, orig, 6);
 
49
 
 
50
  BOOST_REQUIRE_EQUAL(7, out_len);
 
51
  BOOST_REQUIRE_EQUAL("\\0\1\2\3\4\5", out);
 
52
}
 
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
}
 
76
 
42
77
BOOST_AUTO_TEST_CASE(drizzleHexString)
43
78
{
44
79
  const unsigned char orig[5]= {0x34, 0x26, 0x80, 0x99, 0xFF};