File: hash_spec.rb

package info (click to toggle)
ruby-rmagick 6.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,232 kB
  • sloc: cpp: 19,563; ruby: 17,147; sh: 88; javascript: 36; makefile: 13
file content (22 lines) | stat: -rw-r--r-- 645 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
RSpec.describe Magick::Pixel, '#hash' do
  it 'works' do
    pixel = described_class.from_color('brown')

    hash = nil
    expect { hash = pixel.hash }.not_to raise_error
    expect(hash).not_to be(nil)
    expect(hash).to eq(1_385_502_079)

    pixel = described_class.new
    expect(pixel.hash).to eq(127)

    pixel = described_class.from_color('red')
    expect(pixel.hash).to eq(2_139_095_167)

    # Pixel.hash sacrifices the last bit of the opacity channel
    pixel = described_class.new(0, 0, 0, 72)
    pixel2 = described_class.new(0, 0, 0, 73)
    expect(pixel2).not_to eq(pixel)
    expect(pixel2.hash).to eq(pixel.hash)
  end
end