simple-mmap 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/simple_mmap/mapped_file.c +2 -3
- data/test/test_file_window.rb +4 -0
- metadata +1 -1
@@ -130,12 +130,11 @@ static VALUE sm_mapped_file_read_window_data(VALUE vself, VALUE voffset, VALUE v
|
|
130
130
|
return Qnil;
|
131
131
|
}
|
132
132
|
|
133
|
-
size_t curr;
|
134
|
-
curr = offset;
|
133
|
+
size_t curr = offset;
|
135
134
|
size_t i;
|
136
135
|
for(i = 0; i < length; ++i) {
|
137
136
|
//printf("i=%i offset=%i length=%i curr=%i map->len=%i\n", i, offset, length, curr, sm_map->len);
|
138
|
-
if ((
|
137
|
+
if ((offset + i) > sm_map->len)
|
139
138
|
break;
|
140
139
|
buff[i] = sm_map->map[curr++];
|
141
140
|
}
|
data/test/test_file_window.rb
CHANGED
@@ -43,6 +43,10 @@ class TestFileWindow < Test::Unit::TestCase
|
|
43
43
|
assert_equal "z", @fw[25, 10]
|
44
44
|
end
|
45
45
|
|
46
|
+
def test_get_all_bytes
|
47
|
+
assert_equal ('a'..'z').to_a.join, @fw[0, 26]
|
48
|
+
end
|
49
|
+
|
46
50
|
def test_nil_on_negative_index
|
47
51
|
assert_equal nil, @fw[-1]
|
48
52
|
assert_equal nil, @fw[-1, 2]
|