blackwinter / rb-gsl

Ruby interface to the GNU Scientific Library [Ruby 2.x and GSL 1.16 compatible fork of the gsl gem]
https://blackwinter.github.io/rb-gsl
Other
27 stars 7 forks source link

Fix missing range tests in permutation.c #10

Closed gbence closed 9 years ago

gbence commented 9 years ago

Originally, alarming crashes were recognized when GSL::Index#get was given over-its-size indices. These lead to the tests and then the fix in its basis (GSL::Permutation in permutation.c).

blackwinter commented 9 years ago

Thanks, merged! Although I took the liberty to refactor your changes a bit. Could you make sure that it still does what you intended? In particular, why did you want i.get(0..5) and i.get(-5..0) to fail? I leveraged Ruby's rb_range_beg_len instead of GSL's get_range_int_beg_en_n to get Array#[]-like behaviour.