spec/format_spec.rb in asciipack-0.1.0 vs spec/format_spec.rb in asciipack-0.1.1
- old
+ new
@@ -1,13 +1,14 @@
-# encoding: ascii-8bit
+# encoding: utf-8
require 'spec_helper'
describe AsciiPack do
it "intro" do
expect(AsciiPack.pack({"compact"=>true,"binary"=>0})).to eq('r2NcompactYMbinary0')
end
+
it "int 4" do
format -1, T.int4, 2
format -8, T.int4, 2
end
@@ -71,30 +72,32 @@
expect(AsciiPack.pack(Float::NAN)).to eq(T.float64 + '7fffffffffffffff')
expect(AsciiPack.pack(1 / 0.0)).to eq(T.float64 + '7ff0000000000000')
expect(AsciiPack.pack(-1 / 0.0)).to eq(T.float64 + 'fff0000000000000')
end
- it "fixbin" do
- format "", T.fixbin_0, 1
- format " ", T.fixbin_1, 2
- format " " * 0xe, T.fixbin_E, 15
- format " " * 0xf, T.fixbin_F, 16
+ it "fixstr" do
+ format "", T.fixstr_0, 1
+ format " ", T.fixstr_1, 2
+ format "あ", T.fixstr_1, 2
+ format "漢字", T.fixstr_2, 3
+ format " " * 0xe, T.fixstr_E, 15
+ format " " * 0xf, T.fixstr_F, 16
end
- it "bin 8" do
- format "a" * 0x10, T.bin8, 3 + 0x10
- format "a" * 0xff, T.bin8, 3 + 0xff
+ it "str 8" do
+ format "a" * 0x10, T.str8, 3 + 0x10
+ format "a" * 0xff, T.str8, 3 + 0xff
end
- it "bin 16" do
- format "a" * 0x100, T.bin16, 5 + 0x100
- format "a" * 0xffff, T.bin16, 5 + 0xffff
+ it "str 16" do
+ format "a" * 0x100, T.str16, 5 + 0x100
+ format "a" * 0xffff, T.str16, 5 + 0xffff
end
- it "bin 32" do
- format "a" * 0x10000, T.bin32, 9 + 0x10000
+ it "str 32" do
+ format "a" * 0x10000, T.str32, 9 + 0x10000
# FIXME too late
- # format "a" * 0xffffffff, T.bin32, 9 + 0xffffffff
+ # format "a" * 0xffffffff, T.str32, 9 + 0xffffffff
end
it "map 4" do
format_map 0, T.map4
format_map 0xf, T.map4