lib/core: Fixed bug in `BytesIterator::init with_buffer`
authorLucas Bajolet <r4pass@hotmail.com>
Tue, 15 Sep 2015 14:19:00 +0000 (10:19 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Tue, 15 Sep 2015 14:51:17 +0000 (10:51 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/core/bytes.nit
tests/sav/test_bytes_hexdigit.res [new file with mode: 0644]
tests/test_bytes_hexdigit.nit [new file with mode: 0644]

index deddbd8..75d7ccd 100644 (file)
@@ -278,7 +278,7 @@ private class BytesIterator
 
        var max: Int
 
-       init with_buffer(b: Bytes) do init(b.items, 0, b.length - 1)
+       init with_buffer(b: Bytes) do init(b.items, 0, b.length)
 
        redef fun is_ok do return index < max
 
diff --git a/tests/sav/test_bytes_hexdigit.res b/tests/sav/test_bytes_hexdigit.res
new file mode 100644 (file)
index 0000000..f00af0c
--- /dev/null
@@ -0,0 +1,3 @@
+0x0b
+0x1f
+0x4d
diff --git a/tests/test_bytes_hexdigit.nit b/tests/test_bytes_hexdigit.nit
new file mode 100644 (file)
index 0000000..28f51e3
--- /dev/null
@@ -0,0 +1,17 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+var s = "0B1F4D".hexdigest_to_bytes
+
+for i in s do print i