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: Seperated test cases. Created March 15, 2018, 7:02 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..ffd54c91ecb0d8d86dc124e7cbfe91122cc2410d 100644
--- a/test/compiled/String.cpp
+++ b/test/compiled/String.cpp
@@ -21,6 +21,41 @@
ABP_NS_USING
+void checkConstexprTemplateCtor()
+{
+ static constexpr DependentString s(u"Test string");
+}
+
+void checkConstexprInvalidCtor()
+{
+ static constexpr DependentString s;
sergei 2018/03/16 13:43:27 What is the reason to have `static` variables?
René Jeschke 2018/03/16 17:00:47 It's an old habit. As I am using 'const' a lot, I
hub 2018/03/16 17:11:32 Yes, please.
+ static_assert(s.is_invalid(), "String should be invalid");
+}
+
+void checkConstexprCtor()
+{
+ static const String::value_type chars[] = u"Test string";
+ static const String::size_type length = sizeof(chars) / sizeof(chars[0]) - 1;
+ static constexpr DependentString s(chars, length);
+}
+
+void checkConstexprFuncsAndOps()
+{
+ static constexpr DependentString s = u"Test string"_str;
+ static constexpr DependentString s2 = u"Test string"_str;
+
+ static_assert(s.length() == s2.length(), "Length should be equal");
+ static_assert(s.equals(s2), "Strings should be equal");
+ static_assert(s == s2, "Strings should be equal");
+
+ 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] == 'T', "First character should be 'T'");
+ static_assert(s[1] == 'e', "Second character should be 'e'");
+}
+
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