string_view: implement access API and port libcxx tests#938
string_view: implement access API and port libcxx tests#938igchor merged 3 commits intopmem:masterfrom KFilipek:tests-access_api
Conversation
igchor
left a comment
There was a problem hiding this comment.
Reviewed 7 of 7 files at r1.
Reviewable status:complete! all files reviewed, all discussions resolved
Codecov Report
@@ Coverage Diff @@
## master #938 +/- ##
==========================================
- Coverage 96.07% 95.98% -0.10%
==========================================
Files 48 48
Lines 6122 6134 +12
==========================================
+ Hits 5882 5888 +6
- Misses 240 246 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
lukaszstolarczuk
left a comment
There was a problem hiding this comment.
Reviewed 6 of 7 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @KFilipek)
include/libpmemobj++/string_view.hpp, line 166 at r2 (raw file):
* Returns count of characters stored in this pmem::obj::string_view data. * * @return pointer to C-like string (char *), it may not end with null
returns pointer to c-like string? (here and above)
include/libpmemobj++/string_view.hpp, line 206 at r2 (raw file):
/** * Returns reference to a last character in the view.
to the last char
include/libpmemobj++/string_view.hpp, line 219 at r2 (raw file):
/** * Returns reference to a first character in the view.
.
include/libpmemobj++/string_view.hpp, line 220 at r2 (raw file):
/** * Returns reference to a first character in the view. *
perhaps also worth mention what if empty() == true
tests/external/libcxx/string.view/string.view.access/at.pass.cpp, line 37 at r2 (raw file):
} #ifndef TEST_HAS_NO_EXCEPTIONS
I know it's ported from libcxx, but I'd remove this if. We throw exceptions in at and if we ever change it, this test will just fail... which is good, I guess
tests/external/libcxx/string.view/string.view.access/back.pass.cpp, line 55 at r2 (raw file):
{ constexpr pmem::obj::basic_string_view<char> sv("ABC", 2); static_assert(sv.length() == 2, "");
why not UT_ASSERT?
tests/external/libcxx/string.view/string.view.access/data.pass.cpp, line 49 at r2 (raw file):
constexpr const char *s = "ABC"; constexpr pmem::obj::basic_string_view<char> sv(s, 2); static_assert(sv.length() == 2, "");
.
tests/external/libcxx/string.view/string.view.access/front.pass.cpp, line 54 at r2 (raw file):
{ constexpr pmem::obj::basic_string_view<char> sv("ABC", 2); static_assert(sv.length() == 2, "");
.
tests/external/libcxx/string.view/string.view.access/index.pass.cpp, line 59 at r2 (raw file):
constexpr pmem::obj::basic_string_view<char> sv("ABC", 2); static_assert(sv.length() == 2, ""); static_assert(sv[0] == 'A', "");
.
KFilipek
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @lukaszstolarczuk)
include/libpmemobj++/string_view.hpp, line 166 at r2 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
returns pointer to c-like string? (here and above)
No, I don't see any reason to duplicate "return" word:
https://pmem.io/libpmemobj-cpp/master/doxygen/classpmem_1_1obj_1_1basic__string.html#afec7256ef676461b095a0e2f662893e0
The same here in return section:
https://en.cppreference.com/w/cpp/string/basic_string_view/front
include/libpmemobj++/string_view.hpp, line 206 at r2 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
to the last char
Done.
include/libpmemobj++/string_view.hpp, line 219 at r2 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
.
Done.
include/libpmemobj++/string_view.hpp, line 220 at r2 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
perhaps also worth mention what if empty() == true
Done.
tests/external/libcxx/string.view/string.view.access/at.pass.cpp, line 37 at r2 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
I know it's ported from libcxx, but I'd remove this
if. We throw exceptions inatand if we ever change it, this test will just fail... which is good, I guess
Done.
tests/external/libcxx/string.view/string.view.access/back.pass.cpp, line 55 at r2 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
why not UT_ASSERT?
because static_assert is evaluated in compile-time in opposite to assert which is underlying.
tests/external/libcxx/string.view/string.view.access/data.pass.cpp, line 49 at r2 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
.
The same here, above is the constexpr
tests/external/libcxx/string.view/string.view.access/front.pass.cpp, line 54 at r2 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
.
.
tests/external/libcxx/string.view/string.view.access/index.pass.cpp, line 59 at r2 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
.
.
igchor
left a comment
There was a problem hiding this comment.
Reviewed 1 of 2 files at r3.
Reviewable status: 6 of 7 files reviewed, 10 unresolved discussions (waiting on @KFilipek and @lukaszstolarczuk)
include/libpmemobj++/string_view.hpp, line 13 at r1 (raw file):
#include <algorithm> #include <stdexcept>
You should leave stdexcept here - for out_of_range
lukaszstolarczuk
left a comment
There was a problem hiding this comment.
Reviewed 2 of 2 files at r3.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @KFilipek)
include/libpmemobj++/string_view.hpp, line 166 at r2 (raw file):
Previously, KFilipek (Krzysztof Filipek) wrote…
No, I don't see any reason to duplicate "return" word:
https://pmem.io/libpmemobj-cpp/master/doxygen/classpmem_1_1obj_1_1basic__string.html#afec7256ef676461b095a0e2f662893e0
The same here in return section:
https://en.cppreference.com/w/cpp/string/basic_string_view/front
no, no. You didn't understand me ;) this are length and size - do they return a pointer to a string? I don't thinks so... ;)
- add missing functions: front, back - extend declarations by constexpr keyword
- change implementation to use pmem::obj::string_view
KFilipek
left a comment
There was a problem hiding this comment.
Reviewable status: 6 of 7 files reviewed, 2 unresolved discussions (waiting on @igchor and @lukaszstolarczuk)
include/libpmemobj++/string_view.hpp, line 13 at r1 (raw file):
Previously, igchor (Igor Chorążewicz) wrote…
You should leave stdexcept here - for out_of_range
Done.
include/libpmemobj++/string_view.hpp, line 166 at r2 (raw file):
Previously, lukaszstolarczuk (Łukasz Stolarczuk) wrote…
no, no. You didn't understand me ;) this are
lengthandsize- do they return a pointer to a string? I don't thinks so... ;)
Done. Sorry xD
lukaszstolarczuk
left a comment
There was a problem hiding this comment.
Reviewed 1 of 1 files at r4.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @igchor)
include/libpmemobj++/string_view.hpp, line 166 at r2 (raw file):
Previously, KFilipek (Krzysztof Filipek) wrote…
Done. Sorry xD
no problem, thx
igchor
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! all files reviewed, all discussions resolved
This change is