我的 Visual c++ 托管单元测试项目未读取输入文件
My Visual c++ managed Unit test Project not Reading a input file
我正在使用VisualStudio 2015,正在处理c ++托管的单元测试项目,我通过文本文件给出输入值,但它不谈论文件中的值
我的代码在这里
struct employee
{
char name[20];
char department[25];
double salary;
}
[TestMethod]
void Employee_Test()
{
VEMPLOYEE Expectedemployee; //This is class
employee emp_Test;
infile.open("Output_Expected.txt",ios::in);
if (!infile)
exit(1);
for(int i=0;i<3;i++)
{
infile >> emp_Test.name >> emp_Test.department >> emp_Test.salary;
Expectedemployee.push_back(emp_Test);
}
infile.close();
}
但是在我的测试代码中没有读取文件值,预期员工容器显示为空,
我的输入文件是
Robin IT 25000
Nikson IT 20000
Bob IT 20000
通过对上面的代码进行一些小的修复,我在我的机器上成功地运行了代码(win10/gcc(。 所以,我想问题很可能与您的类VEMPLOYEE
有关,并且可能特定于push_back()
成员函数。
我使用VEMPLOYEE
作为测试目的的vector
,我希望您将class
实现为像容器一样工作,但我在"VEMPLOYEE Expectemployee"行中看不到任何大小/类型相关信息;
所以,至少你的文件例程是好的。 检查您的class
.
相关文章:
- 为什么从 std::cin 读取输入后右括号字符的值有时不是")"?
- 函数 freopen 不读取输入
- 我遇到使用 c++ 逐行读取输入文件的问题
- 控制台未正确读取输入字符串
- 在C++中使用istringstream读取输入时出错
- 不读取C++输入
- C++ 仅读取输入文件中的部分(不是全部)数据以添加到记录中
- 读取输入后,输出丢失了一个字符
- 如何在 c++ 中读取输入字符串,忽略空格
- 使用 docker 读取输入文件
- 如何在窗口上的命令行中读取输入 .in 文件
- 在 c++ 服务器上实时读取输入
- 使用不同类型的分隔符从.txt文件中读取输入
- 如何在读取 c++ 输入时脱离循环
- 尝试重复读取输入会出错
- 我的 Visual c++ 托管单元测试项目未读取输入文件
- C 读取输入,直到线char数组的结束
- C (Visual Studio):尝试从.txt文件读取输入时什么都没有收到
- 读取C++输入文件
- 如何从具有交替数据的文件中读取输入并存储到两个数组