File: rest_test.rb

package info (click to toggle)
ruby-bindata 2.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 568 kB
  • ctags: 932
  • sloc: ruby: 8,146; makefile: 3
file content (29 lines) | stat: -rwxr-xr-x 643 bytes parent folder | download
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
#!/usr/bin/env ruby

require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))

describe BinData::Rest do
  let(:obj) { BinData::Rest.new }

  it "initial state" do
    obj.must_equal ""
  end

  it "reads till end of stream" do
    data = "abcdefghij"
    obj.read(data).must_equal data
  end

  it "allows setting value for completeness" do
    obj.assign("123")
    obj.must_equal "123"
    obj.to_binary_s.must_equal_binary "123"
  end

  it "accepts BinData::BasePrimitive parameters" do
    rest = BinData::Rest.new(:assert => "abc")
    lambda {
      rest.read("xyz")
    }.must_raise BinData::ValidityError
  end
end