From c66ba16639c2f025a47b76971610728741ff8e59 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Tue, 15 Sep 2015 10:19:00 -0400 Subject: [PATCH] lib/core: Fixed bug in `BytesIterator::init with_buffer` Signed-off-by: Lucas Bajolet --- lib/core/bytes.nit | 2 +- tests/sav/test_bytes_hexdigit.res | 3 +++ tests/test_bytes_hexdigit.nit | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/sav/test_bytes_hexdigit.res create mode 100644 tests/test_bytes_hexdigit.nit diff --git a/lib/core/bytes.nit b/lib/core/bytes.nit index deddbd8..75d7ccd 100644 --- a/lib/core/bytes.nit +++ b/lib/core/bytes.nit @@ -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 index 0000000..f00af0c --- /dev/null +++ b/tests/sav/test_bytes_hexdigit.res @@ -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 index 0000000..28f51e3 --- /dev/null +++ b/tests/test_bytes_hexdigit.nit @@ -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 -- 1.7.9.5