File: cases_spec.rb

package info (click to toggle)
ruby-msgpack 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 972 kB
  • sloc: ruby: 4,789; ansic: 4,309; java: 1,809; makefile: 4
file content (39 lines) | stat: -rw-r--r-- 723 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'spec/spec_helper'
require 'json'

describe MessagePack do
  here = File.dirname(__FILE__)
  CASES         = File.read("#{here}/cases.msg")
  CASES_JSON    = File.read("#{here}/cases.json")
  CASES_COMPACT = File.read("#{here}/cases_compact.msg")

  it 'compare with json' do
    ms = []
    MessagePack::Unpacker.new.feed_each(CASES) {|m|
      ms << m
    }

    js = JSON.load(CASES_JSON)

    ms.zip(js) {|m,j|
      m.should == j
    }
  end

  it 'compare with compat' do
    ms = []
    MessagePack::Unpacker.new.feed_each(CASES) {|m|
      ms << m
    }

    cs = []
    MessagePack::Unpacker.new.feed_each(CASES_COMPACT) {|c|
      cs << c
    }

    ms.zip(cs) {|m,c|
      m.should == c
    }
  end
end