~roger-booth/mysql-proxy/laminator

« back to all changes in this revision

Viewing changes to tests/unit/check_mysqld_proto.c

  • Committer: jan at mysql
  • Date: 2009-11-11 11:42:45 UTC
  • Revision ID: jan@mysql.com-20091111114245-ml6dgbjjkrkmcmpj
replaced assert() on missing trailing space by a "return -1"

Show diffs side-by-side

added added

removed removed

Lines of Context:
379
379
        g_string_free(packet.data, TRUE);
380
380
}
381
381
 
 
382
void test_mysqld_proto_gstring(void) {
 
383
        network_packet packet;
 
384
        GString *value = g_string_new(NULL);
 
385
 
 
386
        packet.data = g_string_new(NULL);
 
387
 
 
388
        packet.offset = 0;
 
389
        g_string_truncate(packet.data, 0);
 
390
        g_assert_cmpint(0, !=, network_mysqld_proto_get_gstring(&packet, value));
 
391
        g_assert_cmpint(0, ==, value->len);
 
392
 
 
393
        packet.offset = 0;
 
394
        g_string_assign_len(packet.data, C("012345")); /* no trailing \0 */
 
395
        g_assert_cmpint(0, !=, network_mysqld_proto_get_gstring(&packet, value));
 
396
 
 
397
        packet.offset = 0;
 
398
        g_string_assign_len(packet.data, C("012345\0"));
 
399
        g_assert_cmpint(0, ==, network_mysqld_proto_get_gstring(&packet, value));
 
400
        g_assert_cmpint(6, ==, value->len);
 
401
        g_assert_cmpstr("012345", ==, value->str);
 
402
 
 
403
        g_string_free(value, TRUE);
 
404
        g_string_free(packet.data, TRUE);
 
405
}
 
406
 
 
407
 
382
408
void test_mysqld_password(void) {
383
409
        GString *cleartext = g_string_new("123");
384
410
        GString *hashed_password = g_string_new(NULL);
420
446
        g_test_add_func("/core/mysqld-proto-lenenc-int", test_mysqld_proto_lenenc_int);
421
447
        g_test_add_func("/core/mysqld-proto-int", test_mysqld_proto_int);
422
448
        g_test_add_func("/core/mysqld-proto-gstring-len", test_mysqld_proto_gstring_len);
 
449
        g_test_add_func("/core/mysqld-proto-gstring", test_mysqld_proto_gstring);
423
450
 
424
451
        g_test_add_func("/core/mysqld-proto-binlog-event", test_mysqld_binlog_events);
425
452
        g_test_add_func("/core/mysqld-proto-password", test_mysqld_password);