public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Dimitrij Mijoski <dmjpp@hotmail.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: Re: [PATCH] libstdc++: testsuite: Enhance codecvt_unicode with tests for length()
Date: Wed, 18 Oct 2023 12:35:15 +0200	[thread overview]
Message-ID: <AS1P192MB1620766FB6A4D71DD5C8F406ACD5A@AS1P192MB1620.EURP192.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <CACb0b4nNDa5Un8MNEFJW0NBchG+OT67nOi4gQ42zoO+V1-nrYQ@mail.gmail.com>

On Wed, 2023-10-18 at 10:52 +0100, Jonathan Wakely wrote:
> On Tue, 17 Oct 2023 at 23:51, Dimitrij Mijoski <dmjpp@hotmail.com> wrote:
> > 
> > We can test codecvt::length() with the same data that we test
> > codecvt::in(). For each call of in() we add another call to length().
> > Some additional small cosmentic changes are applied.
> 
> Thanks! I'll get this applied.

I think I have an improvement to this patch, see bellow.

> > @@ -79,6 +78,10 @@ utf8_to_utf32_in_ok (const std::codecvt<InternT, ExternT, mbstate_t> &cvt)
> >        VERIFY (char_traits<InternT>::compare (out, exp, t.out_size) == 0);
> >        if (t.out_size < array_size (out))
> >         VERIFY (out[t.out_size] == 0);
> > +
> > +      state = {};
> > +      auto len = cvt.length (state, in, in + t.in_size, t.out_size);
> > +      VERIFY (len == t.in_size);
> >      }
> > 
> >    for (auto t : offsets)

Notice that codecvt::length() return type is (signed) int that should
never be negative. Still because t.in_size is size_t the assertion may
generate some warnings. In theory that assrtion can be done like this:

VERIFY(len >= 0);
VERIFY(static_cast<size_t>(len) == t.in_size);

  reply	other threads:[~2023-10-18 10:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-17 22:50 Dimitrij Mijoski
2023-10-18  9:52 ` Jonathan Wakely
2023-10-18 10:35   ` Dimitrij Mijoski [this message]
2023-10-18 10:52 ` [PATCH v2] " Dimitrij Mijoski
2023-10-21 11:14   ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS1P192MB1620766FB6A4D71DD5C8F406ACD5A@AS1P192MB1620.EURP192.PROD.OUTLOOK.COM \
    --to=dmjpp@hotmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).