软件测试
一般软件或程序写完后,需要进行测试,一般有两种,白盒子和黑盒子测试在网上找了很久,没有找到写测试数据程序,于是自己写了个,在linux下。
被测试程序:
class Test
{
public:
int x;
static int y;
Test(int data=0){x=data;}
~Test(){};
void function(){x++;y++}
};
int Test::y=0;
void main()
{
Test one;
Test two;
Test three;
one.function();
cout<<”x=”<<one.x<<”y=”
<<one.y<<endl;
two.function();
cout<<”x=”<<two.x<<”y=”
<<two.y<<endl;
three.function();
cout<<”x=”<<three.x<<”y=”
<<three.y<<endl;
}
被测试数据:
#include <fstream>
#include <iostream>
using namespace std;
ofstream out("1.txt");
int main(int argc, char * argv[])
{
for (int i = 1; i < 10000; i++) {
out << i << " "
<< i + 1 << " "
<< i + 2 << " "
<< endl;
}
}
测试程序(bash shell):
# !/bin/sh
# 8.sh
cat 1.txt | while read oneline
do
echo ------------------------------------------
./a.out <<EOF
$oneline
EOF
done
被测试程序:
class Test
{
public:
int x;
static int y;
Test(int data=0){x=data;}
~Test(){};
void function(){x++;y++}
};
int Test::y=0;
void main()
{
Test one;
Test two;
Test three;
one.function();
cout<<”x=”<<one.x<<”y=”
<<one.y<<endl;
two.function();
cout<<”x=”<<two.x<<”y=”
<<two.y<<endl;
three.function();
cout<<”x=”<<three.x<<”y=”
<<three.y<<endl;
}
被测试数据:
#include <fstream>
#include <iostream>
using namespace std;
ofstream out("1.txt");
int main(int argc, char * argv[])
{
for (int i = 1; i < 10000; i++) {
out << i << " "
<< i + 1 << " "
<< i + 2 << " "
<< endl;
}
}
测试程序(bash shell):
# !/bin/sh
# 8.sh
cat 1.txt | while read oneline
do
echo ------------------------------------------
./a.out <<EOF
$oneline
EOF
done
转载于:https://blog.51cto.com/cmdblock/126045