Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/compiled/String.cpp

Issue 29722755: Issue 6378 - [emscripten] Make DependentString constexpr
Patch Set: Made _str constexpr. Created March 15, 2018, 4:09 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« compiled/String.h ('K') | « compiled/String.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/compiled/String.cpp
diff --git a/test/compiled/String.cpp b/test/compiled/String.cpp
index e969ccde556eb61d9b3b67a6303fca1eddec8b9b..54f18ad668e89c1dd2cc075b78d0b2aa409e9837 100644
--- a/test/compiled/String.cpp
+++ b/test/compiled/String.cpp
@@ -21,6 +21,25 @@
ABP_NS_USING
+TEST(TestString, checkConstexprCorrectness)
Eric 2018/03/15 17:05:01 Since all the static_assert statements don't gener
René Jeschke 2018/03/15 17:41:23 Is it really worth it to clutter the test code wit
Eric 2018/03/15 18:33:54 I should preface these comments by saying that I a
René Jeschke 2018/03/15 19:02:34 Okay, fine with me. I separated the tests. The onl
+{
+ static constexpr DependentString s(u"Hello world!");
+ static constexpr DependentString s2;
+ static constexpr DependentString s3 = u"Hello again!"_str;
+
+ static_assert(s.length() == 12, "Length should be 12");
+ static_assert(s3.length() == 12, "Length should be 12");
+
+ static_assert(!s.empty(), "String should not be empty");
+ static_assert(!s.is_writable(), "String should not be writable");
+ static_assert(!s.is_deleted(), "String should not be deleted");
+
+ static_assert(s.data()[0] == 'H', "First character should be 'H'");
+ static_assert(s[1] == 'e', "Second character should be 'e'");
+
+ static_assert(s2.is_invalid(), "String should be invalid");
+}
+
TEST(TestString, constructInvalidDependentString)
{
DependentString s;
« compiled/String.h ('K') | « compiled/String.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld