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

Delta Between Two Patch Sets: test/compiled/String.cpp

Issue 29714586: Noissue - implement a couple of common lexical_cast cases. (Closed) Base URL: github.com:adblockplus/adblockpluscore
Left Patch Set: Created March 5, 2018, 3:38 p.m.
Right Patch Set: address comment Created March 6, 2018, 10:35 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« compiled/String.h ('K') | « compiled/String.h ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 EXPECT_EQ(123u, lexical_cast<uint32_t>(u"0123"_str)); 145 EXPECT_EQ(123u, lexical_cast<uint32_t>(u"0123"_str));
146 EXPECT_EQ(123u, lexical_cast<uint32_t>(u"0000123"_str)); 146 EXPECT_EQ(123u, lexical_cast<uint32_t>(u"0000123"_str));
147 EXPECT_EQ(4294967294u, lexical_cast<uint32_t>(u"4294967294"_str)); 147 EXPECT_EQ(4294967294u, lexical_cast<uint32_t>(u"4294967294"_str));
148 EXPECT_EQ(4294967295u, lexical_cast<uint32_t>(u"4294967295"_str)); 148 EXPECT_EQ(4294967295u, lexical_cast<uint32_t>(u"4294967295"_str));
149 EXPECT_EQ( 0u, lexical_cast<uint32_t>(u"4294967296"_str)); 149 EXPECT_EQ( 0u, lexical_cast<uint32_t>(u"4294967296"_str));
150 EXPECT_EQ( 0u, lexical_cast<uint32_t>(u"4594967295"_str)); 150 EXPECT_EQ( 0u, lexical_cast<uint32_t>(u"4594967295"_str));
151 EXPECT_EQ( 0u, lexical_cast<uint32_t>(u"5294967295"_str)); 151 EXPECT_EQ( 0u, lexical_cast<uint32_t>(u"5294967295"_str));
152 EXPECT_EQ( 0u, lexical_cast<uint32_t>(u"42949672950"_str)); 152 EXPECT_EQ( 0u, lexical_cast<uint32_t>(u"42949672950"_str));
153 EXPECT_EQ(4294967295u, lexical_cast<uint32_t>(u"04294967295"_str)); 153 EXPECT_EQ(4294967295u, lexical_cast<uint32_t>(u"04294967295"_str));
154 154
155 EXPECT_EQ(123u, lexical_cast<uint32_t>(u"123abc"_str)); 155 EXPECT_EQ(0, lexical_cast<int32_t>(u" 123"_str));
156 EXPECT_EQ(0u, lexical_cast<uint32_t>(u" 123"_str));
157 EXPECT_EQ(0, lexical_cast<int32_t>(u"123abc"_str));
158 EXPECT_EQ(0u, lexical_cast<uint32_t>(u"123abc"_str));
159 EXPECT_EQ(0, lexical_cast<int32_t>(u"1 23"_str));
160 EXPECT_EQ(0u, lexical_cast<uint32_t>(u"1 23"_str));
156 } 161 }
157 162
158 TEST(TestStringLexicalCast, toBoolean) 163 TEST(TestStringLexicalCast, toBoolean)
159 { 164 {
160 EXPECT_TRUE(lexical_cast<bool>(u"true"_str)); 165 EXPECT_TRUE(lexical_cast<bool>(u"true"_str));
161 EXPECT_FALSE(lexical_cast<bool>(u"true123"_str)); 166 EXPECT_FALSE(lexical_cast<bool>(u"true123"_str));
162 EXPECT_FALSE(lexical_cast<bool>(u"false"_str)); 167 EXPECT_FALSE(lexical_cast<bool>(u"false"_str));
163 EXPECT_FALSE(lexical_cast<bool>(u"some-string"_str)); 168 EXPECT_FALSE(lexical_cast<bool>(u"some-string"_str));
164 EXPECT_FALSE(lexical_cast<bool>(u""_str)); 169 EXPECT_FALSE(lexical_cast<bool>(u""_str));
165 EXPECT_FALSE(lexical_cast<bool>(DependentString())); 170 EXPECT_FALSE(lexical_cast<bool>(DependentString()));
166 } 171 }
167 172
168 TEST(TestStringLexicalCast, toOwnedString) 173 TEST(TestStringLexicalCast, toOwnedString)
169 { 174 {
170 EXPECT_EQ(u"some-string"_str, lexical_cast<OwnedString>(u"some-string"_str)); 175 EXPECT_EQ(u"some-string"_str, lexical_cast<OwnedString>(u"some-string"_str));
171 EXPECT_EQ(u""_str, lexical_cast<OwnedString>(u""_str)); 176 EXPECT_EQ(u""_str, lexical_cast<OwnedString>(u""_str));
172 } 177 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld