On Wed, 2023-10-18 at 10:52 +0100, Jonathan Wakely wrote:
> On Tue, 17 Oct 2023 at 23:51, Dimitrij Mijoski <dm...@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 via email to