File: interp_test.rb

package info (click to toggle)
ruby-gsl 2.1.0.3%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,604 kB
  • sloc: ansic: 62,050; ruby: 15,845; sh: 19; makefile: 10
file content (27 lines) | stat: -rw-r--r-- 706 bytes parent folder | download | duplicates (5)
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
require 'test_helper'

class InterpTest < GSL::TestCase

  def test_bsearch
    x_array = GSL::Vector.alloc(0.0, 1.0, 2.0, 3.0, 4.0)

    res = GSL::Interp.bsearch(x_array, 1.5, 0, 4)
    refute res != 1, 'simple bsearch'

    res = x_array.bsearch(4.0, 0, 4)
    refute res != 3, 'upper endpoint bsearch'

    res = GSL::Interp.bsearch(x_array, 0.0, 0, 4)
    refute res != 0, 'lower endpoint bsearch'

    res = GSL::Interp.bsearch(x_array, 2.0, 0, 4)
    refute res != 2, 'degenerate bsearch'

    res = GSL::Interp.bsearch(x_array, 10.0, 0, 4)
    refute res != 3, 'out of bounds bsearch +'

    res = GSL::Interp.bsearch(x_array, -10.0, 0, 4)
    refute res != 0, 'out of bounds bsearch -'
  end

end