asciipack 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 164e298f484a42236cb887376ab27a88d6ea3bbc
4
- data.tar.gz: 71363702a9be3a3e840f1abe6e802884eeda00c0
3
+ metadata.gz: 1691b37fbd3296bc64c616a4e4df2b4cd6889a07
4
+ data.tar.gz: a5e015148d90c132932e3fbed05c6379ce6f28ce
5
5
  SHA512:
6
- metadata.gz: 31b12c722b94d276baf5061e782b041c26225564e0d14fd79e2182ffec089013c62663b20f681e9023ed9e51dd658a95be0065f68f3085730c948296a11ff36e
7
- data.tar.gz: 0e16623d5a791f61f1b5cd2a2115759f44ec144d802107b20491c876dfc2e14c7c34cc65a7a6ea03b64581f9b3af9532c57fac6059e4d3b5da34482cb35a2ed1
6
+ metadata.gz: 06ce558462f2af4a6c07422a912bb78bcb65220e3ea49570ec317e997f98375258ec288fc099ca3531271432d901eb4cc7a429c6f6d58244386809997f2f8709
7
+ data.tar.gz: ecb62c4e1f7e0e79db03569de77649a67c35338de4db391f091455cf93cdd8c7c8fe7a65669e6b06d489a53de3d85bc41d2f9c175910a2f98473d4b219a740b2
@@ -56,8 +56,7 @@ to_i16all (unpacker_t* ptr, int len)
56
56
  {
57
57
  uint64_t ret = 0;
58
58
  while (len--) {
59
- ret += to_i16(*ptr->ch);
60
- ptr->ch++;
59
+ ret += to_i16(*ptr->ch++);
61
60
  if (len != 0) ret = ret << 4;
62
61
  }
63
62
  return ret;
@@ -102,6 +101,7 @@ Unpacker_str (unpacker_t* ptr, size_t len)
102
101
 
103
102
  VALUE str = rb_str_new(head, len);
104
103
  rb_funcall(str, rb_intern("force_encoding"), 1, rb_str_new2("utf-8"));
104
+ ptr->ch += len;
105
105
  return str;
106
106
  }
107
107
 
@@ -133,9 +133,7 @@ Unpacker_read (unpacker_t* ptr)
133
133
  {
134
134
  uint64_t num;
135
135
 
136
- ptr->ch++;
137
-
138
- switch (*(ptr->ch - 1)) {
136
+ switch (*ptr->ch++) {
139
137
  case 'a': // int 4
140
138
  num = Unpacker_int(ptr, 1);
141
139
  return INT2FIX(num);
@@ -267,7 +265,7 @@ Unpacker_read (unpacker_t* ptr)
267
265
  case 'Y': return Qtrue;
268
266
  }
269
267
 
270
- rb_raise(rb_eArgError, "undefined type:%c", *(ptr->ch));
268
+ rb_raise(rb_eArgError, "undefined type:%c,data:%s,at:%ld", *(ptr->ch), ptr->buffer, ptr->ch - ptr->buffer);
271
269
  return Qnil;
272
270
  }
273
271
 
@@ -1,3 +1,3 @@
1
1
  module AsciiPack
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -48,7 +48,6 @@ puts("|object|" + reports(0).keys.join("|") + "|")
48
48
  puts("|---|" + reports(0).keys.map{"---"}.join("|") + "|")
49
49
 
50
50
  map16 = {}
51
- a = '@'
52
51
  0x100.times {|i| map16[i.to_s] = 0 }
53
52
 
54
53
  tt = Time.now
@@ -4,7 +4,9 @@ require 'spec_helper'
4
4
 
5
5
  describe AsciiPack do
6
6
  it "intro" do
7
- expect(AsciiPack.pack({"compact"=>true,"binary"=>0})).to eq('r2NcompactYMbinary0')
7
+ demo = {"compact"=>true,"binary"=>0}
8
+ expect(AsciiPack.pack(demo)).to eq('r2NcompactYMbinary0')
9
+ expect(AsciiPack.unpack('r2NcompactYMbinary0')).to eq(demo)
8
10
  end
9
11
 
10
12
  it "int 4" do
@@ -70,6 +72,7 @@ describe AsciiPack do
70
72
  check_each_other(1.0000000000000004, T.float64 + '3ff0000000000002')
71
73
  check_each_other(1/3.0, T.float64 + '3fd5555555555555')
72
74
  expect(AsciiPack.pack(Float::NAN)).to eq(T.float64 + '7ff8000000000000')
75
+ expect(AsciiPack.unpack(T.float64 + '7ff8000000000000').nan?).to be true
73
76
  check_each_other(1 / 0.0, T.float64 + '7ff0000000000000')
74
77
  check_each_other(-1 / 0.0, T.float64 + 'fff0000000000000')
75
78
  end
@@ -89,10 +92,8 @@ describe AsciiPack do
89
92
  end
90
93
 
91
94
  it "str 16" do
92
- 100.times {
93
95
  format "a" * 0x100, T.str16, 5 + 0x100
94
96
  format "a" * 0xffff, T.str16, 5 + 0xffff
95
- }
96
97
  end
97
98
 
98
99
  it "str 32" do
@@ -148,8 +149,7 @@ describe AsciiPack do
148
149
  1000.times {
149
150
  array = [array]
150
151
  }
151
- ap = AsciiPack.pack(array)
152
- expect(AsciiPack.unpack(ap)).to eq(array)
152
+ check_each_other(array, AsciiPack.pack(array))
153
153
  end
154
154
 
155
155
  it "nil" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciipack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss