File: cid_widths_spec.rb

package info (click to toggle)
ruby-pdf-reader 1.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 12,908 kB
  • ctags: 569
  • sloc: ruby: 8,330; makefile: 10
file content (92 lines) | stat: -rw-r--r-- 2,119 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# coding: utf-8

require File.dirname(__FILE__) + "/spec_helper"

describe PDF::Reader::CidWidths, "#initilize" do
  context "with an empty array" do
    subject { PDF::Reader::CidWidths.new(500, [])}

    it "should return the default width" do
      subject[1].should == 500
    end
  end

  context "with an array using the first form" do
    subject { PDF::Reader::CidWidths.new(500, [1, [10, 20, 30]])}

    it "should return correct width for index 1" do
      subject[1].should == 10
    end

    it "should return correct width for index 2" do
      subject[2].should == 20
    end

    it "should return correct width for index 3" do
      subject[3].should == 30
    end

    it "should return correct width for index 4" do
      subject[4].should == 500
    end
  end

  context "with an array using the second form" do
    subject { PDF::Reader::CidWidths.new(500, [1, 3, 10])}

    it "should return correct width for index 1" do
      subject[1].should == 10
    end

    it "should return correct width for index 2" do
      subject[2].should == 10
    end

    it "should return correct width for index 3" do
      subject[3].should == 10
    end

    it "should return correct width for index 4" do
      subject[4].should == 500
    end
  end

  context "with an array mixing the first and second form" do
    let!(:widths) {
      [
        1, [10, 20, 30],
        4, 6, 40,
      ]
    }
    subject       { PDF::Reader::CidWidths.new(500, widths)}

    it "should return correct width for index 1" do
      subject[1].should == 10
    end

    it "should return correct width for index 2" do
      subject[2].should == 20
    end

    it "should return correct width for index 3" do
      subject[3].should == 30
    end

    it "should return correct width for index 4" do
      subject[4].should == 40
    end

    it "should return correct width for index 5" do
      subject[5].should == 40
    end

    it "should return correct width for index 6" do
      subject[6].should == 40
    end

    it "should return correct width for index 7" do
      subject[7].should == 500
    end
  end

end