Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
fix string_view
Browse files Browse the repository at this point in the history
  • Loading branch information
neverchanje committed Jul 12, 2018
1 parent b450828 commit c5058f8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 44 deletions.
2 changes: 2 additions & 0 deletions src/core/core/memutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <cstddef>

namespace dsn {
namespace strings_internal {

Expand Down
44 changes: 0 additions & 44 deletions src/core/tests/string_view_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,6 @@

namespace {

TEST(StringViewTest, STLComparator)
{
std::string s1("foo");
std::string s2("bar");
std::string s3("baz");

dsn::string_view p1(s1);
dsn::string_view p2(s2);
dsn::string_view p3(s3);

typedef std::map<dsn::string_view, int> TestMap;
TestMap map;

map.insert(std::make_pair(p1, 0));
map.insert(std::make_pair(p2, 1));
map.insert(std::make_pair(p3, 2));
EXPECT_EQ(map.size(), 3);

TestMap::const_iterator iter = map.begin();
EXPECT_EQ(iter->second, 1);
++iter;
EXPECT_EQ(iter->second, 2);
++iter;
EXPECT_EQ(iter->second, 0);
++iter;
EXPECT_TRUE(iter == map.end());

TestMap::iterator new_iter = map.find("zot");
EXPECT_TRUE(new_iter == map.end());

new_iter = map.find("bar");
EXPECT_TRUE(new_iter != map.end());

map.erase(new_iter);
EXPECT_EQ(map.size(), 2);

iter = map.begin();
EXPECT_EQ(iter->second, 2);
++iter;
EXPECT_EQ(iter->second, 0);
++iter;
EXPECT_TRUE(iter == map.end());
}

// Separated from STL1() because some compilers produce an overly
// large stack frame for the combined function.
TEST(StringViewTest, STL2)
Expand Down

0 comments on commit c5058f8

Please sign in to comment.