poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] pickles,testsuite: add test for search pickle


From: Jose E. Marchesi
Subject: Re: [PATCH] pickles,testsuite: add test for search pickle
Date: Mon, 06 Feb 2023 01:24:20 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Hi Mohammad.

Thanks for the fix.
OK for master and maint/poke-3.

> 2023-02-06  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
>
>       * pickles/search.pk (search_type): Fix `mapper' invocation.
>       * testsuite/poke.pickles/search-test.pk: New test.
>       * testsuite/Makefile.am (EXTRA_DIST): Add new test.
> ---
>  ChangeLog                             |  6 +++
>  pickles/search.pk                     |  2 +-
>  testsuite/Makefile.am                 |  1 +
>  testsuite/poke.pickles/search-test.pk | 54 +++++++++++++++++++++++++++
>  4 files changed, 62 insertions(+), 1 deletion(-)
>  create mode 100644 testsuite/poke.pickles/search-test.pk
>
> diff --git a/ChangeLog b/ChangeLog
> index e5842d1b..2098ccf3 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,9 @@
> +2023-02-06  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
> +
> +     * pickles/search.pk (search_type): Fix `mapper' invocation.
> +     * testsuite/poke.pickles/search-test.pk: New test.
> +     * testsuite/Makefile.am (EXTRA_DIST): Add new test.
> +
>  2023-02-03  Jose E. Marchesi  <jemarch@gnu.org>
>  
>       * libpoke/pkl-tab.y (declaration): improve error message.
> diff --git a/pickles/search.pk b/pickles/search.pk
> index 9e907372..cccc8807 100644
> --- a/pickles/search.pk
> +++ b/pickles/search.pk
> @@ -43,7 +43,7 @@ fun search_type = (Pk_Type typ, int<32> ios = get_ios,
>        try
>        {
>          var found = typ.mapper (1 /* strict */,
> -                                ios, from'magnitude*from'unit, 0, 0);
> +                                ios, from'magnitude*from'unit);
>          var end = found'offset + found'size;
>  
>          return Search_Match_Data { start = found'offset, end = end };
> diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
> index 2309dcc7..6e528424 100644
> --- a/testsuite/Makefile.am
> +++ b/testsuite/Makefile.am
> @@ -600,6 +600,7 @@ EXTRA_DIST = \
>    poke.pickles/pe-test.pk \
>    poke.pickles/riscv-test.pk \
>    poke.pickles/sframe-test.pk \
> +  poke.pickles/search-test.pk \
>    poke.pickles/ustar-test.pk \
>    poke.pickles/color-test.pk \
>    poke.pickles/mbr-test.pk \
> diff --git a/testsuite/poke.pickles/search-test.pk 
> b/testsuite/poke.pickles/search-test.pk
> new file mode 100644
> index 00000000..4f3e4856
> --- /dev/null
> +++ b/testsuite/poke.pickles/search-test.pk
> @@ -0,0 +1,54 @@
> +/* search-test.pk - Tests for the search pickle.  */
> +
> +/* Copyright (C) 2023 The poke authors.  */
> +
> +/* This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 3 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +load pktest;
> +load search;
> +
> +set_endian (ENDIAN_BIG);
> +
> +var data = [0x12UB, 0x34UB, 0x56UB, 0x78UB, 0x9aUB, 0xbcUB, 0xefUB];
> +
> +type T1 = struct uint<16>
> +  {
> +    uint<4> three == 3UN;
> +    uint<8> anything;
> +    uint<4> six == 6UN;
> +  };
> +
> +var tests = [
> +  PkTest {
> +    name = "load search pickle",
> +    func = lambda (string name) void:
> +      {
> +        with_temp_ios
> +          :do lambda void:
> +            {
> +              byte[] @ 0#B = data;
> +
> +              var typ = typeof (T1),
> +                  matches = (search_type :typ typ);
> +
> +              assert (matches'length == 1);
> +              assert (matches[0].start == 1#B);
> +              assert (matches[0].end == 1#B + typ.size#b);
> +            };
> +      },
> +  },];
> +
> +var ok = pktest_run (tests);
> +exit (ok ? 0 : 1);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]