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 93 94 95 96 97 98 99
|
# typed: false
# coding: utf-8
describe PDF::Reader::CidWidths, "#initilize" do
context "with an empty array" do
subject { PDF::Reader::CidWidths.new(500, [])}
it "returns the default width" do
expect(subject[1]).to eq(500)
end
end
context "with an array using the first form" do
subject { PDF::Reader::CidWidths.new(500, [1, [10, 20, 30]])}
it "returns correct width for index 1" do
expect(subject[1]).to eq(10)
end
it "returns correct width for index 2" do
expect(subject[2]).to eq(20)
end
it "returns correct width for index 3" do
expect(subject[3]).to eq(30)
end
it "returns correct width for index 4" do
expect(subject[4]).to eq(500)
end
end
context "with an array using the second form" do
subject { PDF::Reader::CidWidths.new(500, [1, 3, 10])}
it "returns correct width for index 1" do
expect(subject[1]).to eq(10)
end
it "returns correct width for index 2" do
expect(subject[2]).to eq(10)
end
it "returns correct width for index 3" do
expect(subject[3]).to eq(10)
end
it "returns correct width for index 4" do
expect(subject[4]).to eq(500)
end
context "and the range covers a single number" do
subject { PDF::Reader::CidWidths.new(500, [3, 3, 10])}
it "returns correct width for index 3" do
expect(subject[3]).to eq(10)
end
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 "returns correct width for index 1" do
expect(subject[1]).to eq(10)
end
it "returns correct width for index 2" do
expect(subject[2]).to eq(20)
end
it "returns correct width for index 3" do
expect(subject[3]).to eq(30)
end
it "returns correct width for index 4" do
expect(subject[4]).to eq(40)
end
it "returns correct width for index 5" do
expect(subject[5]).to eq(40)
end
it "returns correct width for index 6" do
expect(subject[6]).to eq(40)
end
it "returns correct width for index 7" do
expect(subject[7]).to eq(500)
end
end
end
|