本文整理汇总了C++中Path::Pop方法的典型用法代码示例。如果您正苦于以下问题:C++ Path::Pop方法的具体用法?C++ Path::Pop怎么用?C++ Path::Pop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path::Pop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestEnsureAndRemove
bool TestEnsureAndRemove() {
BEGIN_TEST;
PathFixture fixture;
ASSERT_TRUE(fixture.Create());
Path path;
ASSERT_EQ(ZX_OK, path.Push(fixture.path()));
ASSERT_EQ(ZX_OK, path.Push("foo/ba/z/qu"));
EXPECT_EQ(ZX_OK, path.Ensure(""));
EXPECT_NE(ZX_OK, path.Ensure("x"));
EXPECT_EQ(ZX_OK, path.Ensure("ux"));
EXPECT_EQ(ZX_OK, path.Ensure("corge"));
EXPECT_EQ(ZX_OK, path.Ensure("g/rault"));
EXPECT_EQ(ZX_OK, path.Ensure("g/arply"));
EXPECT_NE(ZX_OK, path.Remove(""));
EXPECT_EQ(ZX_OK, path.Remove("a"));
EXPECT_EQ(ZX_OK, path.Remove("x"));
EXPECT_NE(ZX_OK, path.Push("x"));
EXPECT_EQ(ZX_OK, path.Remove("corge"));
EXPECT_NE(ZX_OK, path.Push("corge"));
EXPECT_EQ(ZX_OK, path.Remove("g"));
EXPECT_NE(ZX_OK, path.Push("g"));
path.Pop();
EXPECT_EQ(ZX_OK, path.Remove("foo"));
EXPECT_NE(ZX_OK, path.Push("foo"));
END_TEST;
}
示例2: TestRename
bool TestRename() {
BEGIN_TEST;
BEGIN_TEST;
PathFixture fixture;
ASSERT_TRUE(fixture.Create());
Path path;
ASSERT_EQ(ZX_OK, path.Push(fixture.path("foo/ba")));
EXPECT_NE(ZX_OK, path.Rename("", "empty"));
EXPECT_NE(ZX_OK, path.Rename("empty", ""));
EXPECT_NE(ZX_OK, path.Rename("missing", "found"));
fbl::unique_fd fd(open(fixture.path("foo/ba/r").c_str(), O_RDWR));
EXPECT_TRUE(!!fd);
fd.reset(open(fixture.path("foo/ba/s").c_str(), O_RDWR));
EXPECT_FALSE(!!fd);
EXPECT_EQ(ZX_OK, path.Rename("r", "s"));
fd.reset(open(fixture.path("foo/ba/r").c_str(), O_RDWR));
EXPECT_FALSE(!!fd);
fd.reset(open(fixture.path("foo/ba/s").c_str(), O_RDWR));
EXPECT_TRUE(!!fd);
EXPECT_EQ(ZX_OK, path.Rename("s", "r"));
fd.reset(open(fixture.path("foo/ba/r").c_str(), O_RDWR));
EXPECT_TRUE(!!fd);
fd.reset(open(fixture.path("foo/ba/s").c_str(), O_RDWR));
EXPECT_FALSE(!!fd);
EXPECT_EQ(ZX_OK, path.Rename("z", "y"));
EXPECT_NE(ZX_OK, path.Push("z/qu/ux"));
EXPECT_EQ(ZX_OK, path.Push("y/qu/ux"));
path.Pop();
EXPECT_EQ(ZX_OK, path.Rename("y", "z"));
EXPECT_NE(ZX_OK, path.Push("y/qu/ux"));
EXPECT_EQ(ZX_OK, path.Push("z/qu/ux"));
END_TEST;
}