我现在正在编写测试用例,我创建了一些测试文件并尝试读取它们。绝对路径为:
/home/user/code/Project/source/Project/components/Project/test/file.dat
但是使用绝对路径进行测试是有明显缺陷的。因此,我试图将绝对路径转换为相对路径,但我不知道为什么它不起作用。我创建了一个具有相对路径的文件。
findme.dat
我在其中找到了它
->and I found it in
/home/user/code/Project/build/source/Project/components/Project/test/findme.dat
所以我创建了相对路径
/../../../../../../source/Project/components/Project/test/file.dat
但该文件未打开,且未与is
对象关联,
std::ifstream is (path);
,并且is.is_open()
函数返回false。
你能帮我吗?