This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Add tests for std::string default constructor and destructor
ClosedPublic

Authored by philnik on Apr 5 2022, 6:58 AM.

Diff Detail

Event Timeline

philnik created this revision.Apr 5 2022, 6:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 6:58 AM
philnik requested review of this revision.Apr 5 2022, 6:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 6:58 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
nilayvaish accepted this revision.Apr 5 2022, 10:41 AM
nilayvaish added a subscriber: nilayvaish.

Minor comments, otherwise looks good to me.

libcxx/test/std/strings/basic.string/string.cons/default.pass.cpp
41

Why is this commented out? Same question for the other file as well.

libcxx/test/std/strings/basic.string/string.cons/dtor.pass.cpp
33–35

Seems unused.

philnik marked 2 inline comments as done.Apr 5 2022, 10:44 AM
philnik added inline comments.
libcxx/test/std/strings/basic.string/string.cons/default.pass.cpp
41

std::string isn't constexpr yet. This will be uncommented when std::string is made constexpr (D110598 if you want to review it :P).

libcxx/test/std/strings/basic.string/string.cons/dtor.pass.cpp
33–35

AFAICT this is supposed to be that way. The comment above says that it checks that the address of the destructors constructor can be taken.

var-const requested changes to this revision.Apr 5 2022, 4:46 PM
var-const added inline comments.
libcxx/test/std/strings/basic.string/string.cons/default.pass.cpp
14

This comment is no longer entirely true, because now this file also tests that the default constructor works and creates an empty string. I'd suggest moving it closer to the static assertions and rephrasing to something like Test the noexcept specification, which is a conforming extension..

14

If this is an extension, it seems like the test should use LIBCPP_STATIC_ASSERT (unless the other implementations just happen to do the same extension). If this test passes with GCC and MSVC, I wonder if the extension in question is fully tested?

41

Can you please add a TODO to uncomment this line once that patch lands? In general, I think we should always add a TODO or at least a comment when committing commented out code.

libcxx/test/std/strings/basic.string/string.cons/dtor.pass.cpp
56–57

Nit: can you use LIBCPP_STATIC_ASSERT?

This revision now requires changes to proceed.Apr 5 2022, 4:46 PM
philnik updated this revision to Diff 420721.Apr 5 2022, 11:50 PM
philnik marked 5 inline comments as done.
  • Address comments
libcxx/test/std/strings/basic.string/string.cons/default.pass.cpp
41

I think a TODO doesn't make a lot of sense here. This commented out line exists in almost every single file in strings/basic.string. It just makes it harder to remove all the residue mechanically.

ldionne accepted this revision.Apr 6 2022, 9:28 AM

LGTM, I think all comments have been addressed but please confirm with Costa before shipping, just to be sure.

libcxx/test/std/strings/basic.string/string.cons/default.pass.cpp
41

I agree with Costa in the general case, however in this specific instance the string tests have this commented out bit consistently, so I think this is fine as-is. Also we know we're going to uncomment it in the very short term.

var-const accepted this revision.Apr 7 2022, 4:41 PM
var-const added inline comments.
libcxx/test/std/strings/basic.string/string.cons/default.pass.cpp
13

Very optional nit: two blank lines in a row, I'd remove one.

This revision is now accepted and ready to land.Apr 7 2022, 4:41 PM
This revision was automatically updated to reflect the committed changes.
philnik marked 3 inline comments as done.
libcxx/test/std/strings/basic.string/string.cons/default.pass.cpp