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: Even more constexpr and tests. Created March 19, 2018, 1:26 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
« no previous file with comments | « 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..9bc37b512bbd23f53c7223b1bf01a71ef5bbafcc 100644
--- a/test/compiled/String.cpp
+++ b/test/compiled/String.cpp
@@ -10,7 +10,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+
sergei 2018/03/19 13:33:04 Could you please revert the change.
René Jeschke 2018/03/19 13:39:55 Done.
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -21,6 +21,45 @@
ABP_NS_USING
+constexpr void checkConstexprTemplateCtor()
+{
+ constexpr DependentString s(u"Test string");
+}
+
+constexpr void checkConstexprInvalidCtor()
+{
+ constexpr DependentString s;
+ static_assert(s.is_invalid(), "String should be invalid");
+}
+
+constexpr void checkConstexprCtor()
+{
+ constexpr DependentString s(u"Test string", 11);
+}
+
+constexpr void checkConstexprFuncsAndOps()
+{
+ constexpr DependentString s = u"Test string"_str;
+ constexpr DependentString s2 = u"Test string"_str;
+ constexpr DependentString s3 = u"Another 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 != s3, "Strings should not 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'");
+
+ static_assert(s.find(u'e') == 1, "'e' should be at pos 1");
+ static_assert(s.find(s2) == 0, "String should be found at pos 0");
+ static_assert(s.rfind(u'e') == 1, "'e' should be at pos 1");
+}
+
TEST(TestString, constructInvalidDependentString)
{
DependentString s;
« no previous file with comments | « compiled/String.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld