Class: TC_Mysql
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- TC_Mysql
- Defined in:
- ext/test.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #teardown ⇒ Object
- #test_client_info ⇒ Object
- #test_connect ⇒ Object
- #test_connect2 ⇒ Object
- #test_escape_string ⇒ Object
- #test_get_client_info ⇒ Object
- #test_init ⇒ Object
- #test_new ⇒ Object
- #test_options ⇒ Object
- #test_quote ⇒ Object
- #test_real_connect ⇒ Object
- #test_real_connect2 ⇒ Object
- #test_version ⇒ Object
Instance Method Details
#setup ⇒ Object
8 9 10 11 12 13 14 |
# File 'ext/test.rb', line 8 def setup() @host, @user, @pass, db, port, sock, flag = ARGV @db = db || "test" @port = port.to_i @sock = sock.nil? || sock.empty? ? nil : sock @flag = flag.to_i end |
#teardown ⇒ Object
15 16 |
# File 'ext/test.rb', line 15 def teardown() end |
#test_client_info ⇒ Object
54 55 56 |
# File 'ext/test.rb', line 54 def test_client_info() assert_match(/^\d.\d+.\d+(-.*)?$/, Mysql.client_info()) end |
#test_connect ⇒ Object
32 33 34 35 |
# File 'ext/test.rb', line 32 def test_connect() assert_nothing_raised{@m = Mysql.connect(@host, @user, @pass, @db, @port, @sock, @flag)} assert_nothing_raised{@m.close} end |
#test_connect2 ⇒ Object
88 89 90 91 92 |
# File 'ext/test.rb', line 88 def test_connect2() @m = Mysql.init assert_equal(@m, @m.connect(@host, @user, @pass, @db, @port, @sock, @flag)) @m.close end |
#test_escape_string ⇒ Object
42 43 44 |
# File 'ext/test.rb', line 42 def test_escape_string() assert_equal("abc\\'def\\\"ghi\\0jkl%mno", Mysql.escape_string("abc'def\"ghi\0jkl%mno")) end |
#test_get_client_info ⇒ Object
50 51 52 |
# File 'ext/test.rb', line 50 def test_get_client_info() assert_match(/^\d.\d+.\d+(-.*)?$/, Mysql.get_client_info()) end |
#test_init ⇒ Object
22 23 24 25 |
# File 'ext/test.rb', line 22 def test_init() assert_nothing_raised{@m = Mysql.init} assert_nothing_raised{@m.close} end |
#test_new ⇒ Object
37 38 39 40 |
# File 'ext/test.rb', line 37 def test_new() assert_nothing_raised{@m = Mysql.new(@host, @user, @pass, @db, @port, @sock, @flag)} assert_nothing_raised{@m.close} end |
#test_options ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'ext/test.rb', line 58 def () @m = Mysql.init assert_equal(@m, @m.(Mysql::INIT_COMMAND, "SET AUTOCOMMIT=0")) assert_equal(@m, @m.(Mysql::OPT_COMPRESS)) assert_equal(@m, @m.(Mysql::OPT_CONNECT_TIMEOUT, 10)) assert_equal(@m, @m.(Mysql::GUESS_CONNECTION)) if defined? Mysql::GUESS_CONNECTION assert_equal(@m, @m.(Mysql::OPT_LOCAL_INFILE, true)) # assert_equal(@m, @m.options(Mysql::OPT_NAMED_PIPE)) # assert_equal(@m, @m.options(Mysql::OPT_PROTOCOL, 1)) assert_equal(@m, @m.(Mysql::OPT_READ_TIMEOUT, 10)) if defined? Mysql::OPT_READ_TIMEOUT assert_equal(@m, @m.(Mysql::OPT_USE_EMBEDDED_CONNECTION)) if defined? Mysql::OPT_USE_EMBEDDED_CONNECTION assert_equal(@m, @m.(Mysql::OPT_USE_REMOTE_CONNECTION)) if defined? Mysql::OPT_USE_REMOTE_CONNECTION assert_equal(@m, @m.(Mysql::OPT_WRITE_TIMEOUT, 10)) if defined? Mysql::OPT_WRITE_TIMEOUT # assert_equal(@m, @m.options(Mysql::READ_DEFAULT_FILE, "/tmp/hoge")) assert_equal(@m, @m.(Mysql::READ_DEFAULT_GROUP, "test")) assert_equal(@m, @m.(Mysql::SECURE_AUTH, true)) if defined? Mysql::SECURE_AUTH # assert_equal(@m, @m.options(Mysql::SET_CHARSET_DIR, "??")) assert_equal(@m, @m.(Mysql::SET_CHARSET_NAME, "latin1")) assert_equal(@m, @m.(Mysql::SET_CLIENT_IP, "127.0.0.1")) if defined? Mysql::SET_CLIENT_IP # assert_equal(@m, @m.options(Mysql::SHARED_MEMORY_BASE_NAME, "xxx")) assert_equal(@m, @m.connect(@host, @user, @pass, @db, @port, @sock, @flag)) @m.close end |
#test_quote ⇒ Object
46 47 48 |
# File 'ext/test.rb', line 46 def test_quote() assert_equal("abc\\'def\\\"ghi\\0jkl%mno", Mysql.quote("abc'def\"ghi\0jkl%mno")) end |
#test_real_connect ⇒ Object
27 28 29 30 |
# File 'ext/test.rb', line 27 def test_real_connect() assert_nothing_raised{@m = Mysql.real_connect(@host, @user, @pass, @db, @port, @sock, @flag)} assert_nothing_raised{@m.close} end |
#test_real_connect2 ⇒ Object
82 83 84 85 86 |
# File 'ext/test.rb', line 82 def test_real_connect2() @m = Mysql.init assert_equal(@m, @m.real_connect(@host, @user, @pass, @db, @port, @sock, @flag)) @m.close end |
#test_version ⇒ Object
18 19 20 |
# File 'ext/test.rb', line 18 def test_version() assert_equal(20701, Mysql::VERSION) end |