ruby-mysql 2.9.11 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,149 @@
1
+ # coding: binary
2
+ require 'test/unit'
3
+ require 'test/unit/rr'
4
+ begin
5
+ require 'test/unit/notify'
6
+ rescue LoadError
7
+ # ignore
8
+ end
9
+
10
+ require 'mysql'
11
+
12
+ class TestMysqlPacket < Test::Unit::TestCase
13
+ def self._(s)
14
+ s.unpack('H*').first
15
+ end
16
+
17
+ def subject
18
+ Mysql::Packet.new(data)
19
+ end
20
+
21
+ sub_test_case '#lcb' do
22
+ [
23
+ ["\xfb", nil],
24
+ ["\xfc\x01\x02", 0x0201],
25
+ ["\xfd\x01\x02\x03", 0x030201],
26
+ ["\xfe\x01\x02\x03\x04\x05\x06\x07\x08", 0x0807060504030201],
27
+ ["\x01", 0x01],
28
+ ].each do |data, result|
29
+ sub_test_case "for '#{_ data}'" do
30
+ define_method(:data){ data }
31
+ test '' do
32
+ assert{ subject.lcb == result }
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ sub_test_case '#lcs' do
39
+ [
40
+ ["\x03\x41\x42\x43", 'ABC'],
41
+ ["\x01", ''],
42
+ ["", nil],
43
+ ].each do |data, result|
44
+ sub_test_case "for '#{_ data}'" do
45
+ define_method(:data){ data }
46
+ test '' do
47
+ assert{ subject.lcs == result }
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ sub_test_case '#read' do
54
+ define_method(:data){'ABCDEFGHI'}
55
+ test '' do
56
+ assert{ subject.read(7) == 'ABCDEFG' }
57
+ end
58
+ end
59
+
60
+ sub_test_case '#string' do
61
+ define_method(:data){"ABC\0DEF"}
62
+ test 'should NUL terminated String' do
63
+ assert{ subject.string == 'ABC' }
64
+ end
65
+ end
66
+
67
+ sub_test_case '#utiny' do
68
+ [
69
+ ["\x01", 0x01],
70
+ ["\xFF", 0xff],
71
+ ].each do |data, result|
72
+ sub_test_case "for '#{_ data}'" do
73
+ define_method(:data){data}
74
+ test '' do
75
+ assert{ subject.utiny == result }
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ sub_test_case '#ushort' do
82
+ [
83
+ ["\x01\x02", 0x0201],
84
+ ["\xFF\xFE", 0xfeff],
85
+ ].each do |data, result|
86
+ sub_test_case "for '#{_ data}'" do
87
+ define_method(:data){data}
88
+ test '' do
89
+ assert{ subject.ushort == result }
90
+ end
91
+ end
92
+ end
93
+ end
94
+
95
+ sub_test_case '#ulong' do
96
+ [
97
+ ["\x01\x02\x03\x04", 0x04030201],
98
+ ["\xFF\xFE\xFD\xFC", 0xfcfdfeff],
99
+ ].each do |data, result|
100
+ sub_test_case "for '#{_ data}'" do
101
+ define_method(:data){data}
102
+ test '' do
103
+ assert{ subject.ulong == result }
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ sub_test_case '#eof?' do
110
+ [
111
+ ["\xfe\x00\x00\x00\x00", true],
112
+ ["ABCDE", false],
113
+ ].each do |data, result|
114
+ sub_test_case "for '#{_ data}'" do
115
+ define_method(:data){data}
116
+ test '' do
117
+ assert{ subject.eof? == result }
118
+ end
119
+ end
120
+ end
121
+ end
122
+
123
+ sub_test_case 'Mysql::Packet.lcb' do
124
+ [
125
+ [nil, "\xfb"],
126
+ [1, "\x01"],
127
+ [250, "\xfa"],
128
+ [251, "\xfc\xfb\x00"],
129
+ [65535, "\xfc\xff\xff"],
130
+ [65536, "\xfd\x00\x00\x01"],
131
+ [16777215, "\xfd\xff\xff\xff"],
132
+ [16777216, "\xfe\x00\x00\x00\x01\x00\x00\x00\x00"],
133
+ [0xffffffffffffffff, "\xfe\xff\xff\xff\xff\xff\xff\xff\xff"],
134
+ ].each do |val, result|
135
+ sub_test_case "with #{val}" do
136
+ test '' do
137
+ assert{ Mysql::Packet.lcb(val) == result }
138
+ end
139
+ end
140
+ end
141
+ end
142
+
143
+ sub_test_case 'Mysql::Packet.lcs' do
144
+ test '' do
145
+ assert{ Mysql::Packet.lcs("hoge") == "\x04hoge" }
146
+ assert{ Mysql::Packet.lcs("あいう".force_encoding("UTF-8")) == "\x09\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86" }
147
+ end
148
+ end
149
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-mysql
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.11
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomita Masahiro
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-09 00:00:00.000000000 Z
11
+ date: 2021-10-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is MySQL connector. pure Ruby version
14
14
  email: tommy@tmtm.org
@@ -19,38 +19,36 @@ extra_rdoc_files:
19
19
  files:
20
20
  - README.rdoc
21
21
  - lib/mysql.rb
22
- - lib/mysql/constants.rb
23
- - lib/mysql/protocol.rb
24
22
  - lib/mysql/charset.rb
23
+ - lib/mysql/constants.rb
25
24
  - lib/mysql/error.rb
26
25
  - lib/mysql/packet.rb
27
- - spec/mysql_spec.rb
28
- - spec/mysql/packet_spec.rb
26
+ - lib/mysql/protocol.rb
27
+ - test/test_mysql.rb
28
+ - test/test_mysql_packet.rb
29
29
  homepage: http://github.com/tmtm/ruby-mysql
30
30
  licenses:
31
- - Ruby's
31
+ - Ruby
32
32
  metadata: {}
33
- post_install_message:
33
+ post_install_message:
34
34
  rdoc_options: []
35
35
  require_paths:
36
36
  - lib
37
37
  required_ruby_version: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  required_rubygems_version: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - '>='
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  requirements: []
48
- rubyforge_project:
49
- rubygems_version: 2.0.0
50
- signing_key:
48
+ rubygems_version: 3.2.22
49
+ signing_key:
51
50
  specification_version: 4
52
51
  summary: MySQL connector
53
52
  test_files:
54
- - spec/mysql_spec.rb
55
- - spec/mysql/packet_spec.rb
56
- has_rdoc: true
53
+ - test/test_mysql.rb
54
+ - test/test_mysql_packet.rb
@@ -1,118 +0,0 @@
1
- # coding: binary
2
- describe Mysql::Packet do
3
- def self._(s)
4
- s.unpack('H*').first
5
- end
6
- subject{Mysql::Packet.new(data)}
7
- describe '#lcb' do
8
- [
9
- ["\xfb", nil],
10
- ["\xfc\x01\x02", 0x0201],
11
- ["\xfd\x01\x02\x03", 0x030201],
12
- ["\xfe\x01\x02\x03\x04\x05\x06\x07\x08", 0x0807060504030201],
13
- ["\x01", 0x01],
14
- ].each do |data, result|
15
- context "for '#{_ data}'" do
16
- let(:data){data}
17
- it{subject.lcb.should == result}
18
- end
19
- end
20
- end
21
-
22
- describe '#lcs' do
23
- [
24
- ["\x03\x41\x42\x43", 'ABC'],
25
- ["\x01", ''],
26
- ["", nil],
27
- ].each do |data, result|
28
- context "for '#{_ data}'" do
29
- let(:data){data}
30
- it{subject.lcs.should == result}
31
- end
32
- end
33
- end
34
-
35
- describe '#read' do
36
- let(:data){'ABCDEFGHI'}
37
- it{subject.read(7).should == 'ABCDEFG'}
38
- end
39
-
40
- describe '#string' do
41
- let(:data){"ABC\0DEF"}
42
- it 'should NUL terminated String' do
43
- subject.string.should == 'ABC'
44
- end
45
- end
46
-
47
- describe '#utiny' do
48
- [
49
- ["\x01", 0x01],
50
- ["\xFF", 0xff],
51
- ].each do |data, result|
52
- context "for '#{_ data}'" do
53
- let(:data){data}
54
- it{subject.utiny.should == result}
55
- end
56
- end
57
- end
58
-
59
- describe '#ushort' do
60
- [
61
- ["\x01\x02", 0x0201],
62
- ["\xFF\xFE", 0xfeff],
63
- ].each do |data, result|
64
- context "for '#{_ data}'" do
65
- let(:data){data}
66
- it{subject.ushort.should == result}
67
- end
68
- end
69
- end
70
-
71
- describe '#ulong' do
72
- [
73
- ["\x01\x02\x03\x04", 0x04030201],
74
- ["\xFF\xFE\xFD\xFC", 0xfcfdfeff],
75
- ].each do |data, result|
76
- context "for '#{_ data}'" do
77
- let(:data){data}
78
- it{subject.ulong.should == result}
79
- end
80
- end
81
- end
82
-
83
- describe '#eof?' do
84
- [
85
- ["\xfe\x00\x00\x00\x00", true],
86
- ["ABCDE", false],
87
- ].each do |data, result|
88
- context "for '#{_ data}'" do
89
- let(:data){data}
90
- it{subject.eof?.should == result}
91
- end
92
- end
93
- end
94
-
95
- end
96
-
97
- describe 'Mysql::Packet.lcb' do
98
- [
99
- [nil, "\xfb"],
100
- [1, "\x01"],
101
- [250, "\xfa"],
102
- [251, "\xfc\xfb\x00"],
103
- [65535, "\xfc\xff\xff"],
104
- [65536, "\xfd\x00\x00\x01"],
105
- [16777215, "\xfd\xff\xff\xff"],
106
- [16777216, "\xfe\x00\x00\x00\x01\x00\x00\x00\x00"],
107
- [0xffffffffffffffff, "\xfe\xff\xff\xff\xff\xff\xff\xff\xff"],
108
- ].each do |val, result|
109
- context "with #{val}" do
110
- it{Mysql::Packet.lcb(val).should == result}
111
- end
112
- end
113
- end
114
-
115
- describe 'Mysql::Packet.lcs' do
116
- it{Mysql::Packet.lcs("hoge").should == "\x04hoge"}
117
- it{Mysql::Packet.lcs("あいう".force_encoding("UTF-8")).should == "\x09\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86"}
118
- end