Details
- Reviewers
ldionne - Group Reviewers
Restricted Project - Commits
- rG1406f099de94: [libc++][tests] Fix a test exercising incorrect overload
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I noticed a test I added in https://reviews.llvm.org/D153709 wasn't testing the constructor overload it was supposed to test. Instead, it tested the same overload as string-alloc.mode.pass.cpp.
I don't think that's true. The test was exercising this constructor: explicit basic_stringbuf(basic_string<charT, traits, Allocator>&& s, ios_base::openmode which = ios_base::in | ios_base::out) unless I missed something subtle. We're specifying a test allocator in the type of basic_stringbuf, but we're not passing any allocator to the constructor itself. Did I miss something?
@ldionne std::basic_string<CharT, std::traits<CharT>, test_allocator<CharT>> is a different type than std::basic_string<CharT>.
I double-checked with printfs which constructor was called.
@ldionne Can we please continue this review before the 17.0 branch is created?
The constructor to be tested is not a template and the allocator of the moved string must be the same type as stringbuf's allocator.
It was not: the string had a default std::allocator while stringbuf had test_allocator.
A different overload was selected that allows a different allocator and we have a different test for it.
libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/string.move.mode.pass.cpp | ||
---|---|---|
29–36 | OH!! I see it now. Okay, thanks for the fix. What would you think about testing this thought? std::basic_string<CharT, std::char_traits<CharT>, test_allocator<CharT>> s(STR("testing")); const std::basic_stringbuf<CharT, std::char_traits<CharT>, test_allocator<CharT>> buf(std::move(s)); assert(buf.str() == STR("testing")); It's nice to use the test_allocator and not just the default one. |
OH!! I see it now. Okay, thanks for the fix.
What would you think about testing this thought?
It's nice to use the test_allocator and not just the default one.