File: function_channel_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 (38 lines) | stat: -rw-r--r-- 2,549 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
RSpec.describe Magick::Image, '#function_channel' do
  it 'works' do
    image = described_class.read('gradient:') { |options| options.size = '20x600' }
    image = image.first
    image.rotate!(90)
    expect { image.function_channel Magick::PolynomialFunction, 0.33 }.not_to raise_error
    expect { image.function_channel Magick::PolynomialFunction, 4, -1.5 }.not_to raise_error
    expect { image.function_channel Magick::PolynomialFunction, 4, -4, 1 }.not_to raise_error
    expect { image.function_channel Magick::PolynomialFunction, -25, 53, -36, 8.3, 0.2 }.not_to raise_error

    expect { image.function_channel Magick::SinusoidFunction, 1 }.not_to raise_error
    expect { image.function_channel Magick::SinusoidFunction, 1, 90 }.not_to raise_error
    expect { image.function_channel Magick::SinusoidFunction, 5, 90, 0.25, 0.75 }.not_to raise_error

    expect { image.function_channel Magick::ArcsinFunction, 1 }.not_to raise_error
    expect { image.function_channel Magick::ArcsinFunction, 0.5 }.not_to raise_error
    expect { image.function_channel Magick::ArcsinFunction, 0.4, 0.7 }.not_to raise_error
    expect { image.function_channel Magick::ArcsinFunction, 0.5, 0.5, 0.5, 0.5 }.not_to raise_error

    expect { image.function_channel Magick::ArctanFunction, 1 }.not_to raise_error
    expect { image.function_channel Magick::ArctanFunction, 10, 0.7 }.not_to raise_error
    expect { image.function_channel Magick::ArctanFunction, 5, 0.7, 1.2 }.not_to raise_error
    expect { image.function_channel Magick::ArctanFunction, 15, 0.7, 0.5, 0.75 }.not_to raise_error

    # with channel args
    expect { image.function_channel Magick::PolynomialFunction, 0.33, Magick::RedChannel }.not_to raise_error
    expect { image.function_channel Magick::SinusoidFunction, 1, Magick::RedChannel, Magick::BlueChannel }.not_to raise_error

    # invalid args
    expect { image.function_channel }.to raise_error(ArgumentError)
    expect { image.function_channel 1 }.to raise_error(TypeError)
    expect { image.function_channel Magick::PolynomialFunction }.to raise_error(ArgumentError)
    expect { image.function_channel Magick::PolynomialFunction, [] }.to raise_error(TypeError)
    expect { image.function_channel Magick::SinusoidFunction, 5, 90, 0.25, 0.75, 0.1 }.to raise_error(ArgumentError)
    expect { image.function_channel Magick::ArcsinFunction, 0.5, 0.5, 0.5, 0.5, 0.1 }.to raise_error(ArgumentError)
    expect { image.function_channel Magick::ArctanFunction, 15, 0.7, 0.5, 0.75, 0.1 }.to raise_error(ArgumentError)
  end
end