📄 firstdlg.cpp
字号:
// FirstDlg.cpp : implementation file
//
#include "stdafx.h"
#include "RWXML8.h"
#include "FirstDlg.h"
#include "Markup.h"
#include "vector"
#include "stdio.h"
using namespace std;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFirstDlg dialog
//vector<int> List;
// int TCCount=10;
struct TestCaseNode{
int TC_ID;
int TC_Node_Count;
int TC_Seg_Count;
vector<int> NodeList;
vector<int> SegmentList;
int Time;
}TestCase;
struct Node_TC{
int Node_id;
vector<int> TC;
int TC_count;
int reverse;
};
vector<Node_TC> Node_TestCase(51);
//vector<Node_TC> Node_TestCase
vector<TestCaseNode> TestSuite(25);
//vector<TestCaseNode> TestSuiteMin(TestSuite);
//int TC_Node[22][50];
//int TC_Seg[22][100];
//struct array1{vector<int> data;};
struct TC_Node_Node{
int tcid;
int Node;
int time;
int reverse;
};
struct TC_Seg_Node{
int tcid;
int segment;
int time;
bool reverse;
};
// int MAX=0;
int NODECOUNT=0;
int SEGCOUNT=0;
/*
vector<TC_Node_Node> vec_TC_Node(NODECOUNT);
vector<TC_Node_Node> squen_TC_Node(NODECOUNT);
vector<TC_Seg_Node> vec_TC_Seg(SEGCOUNT);
vector<TC_Seg_Node> squen_TC_Seg(SEGCOUNT);
*/
//vector<TC_Node_Node>::iterator inter_Node;
//vector<TC_Seg_Node>::iterator inter_segment;
//vector<int> p_flag(50);
//vector<int> s_flag(100);
//memset(TC_Node,0,sizeof(TC_Node));
//vector<int> TS_TCID;
//vector<int> TS_TCTime;
//vector<int>
CFirstDlg::CFirstDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFirstDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFirstDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CFirstDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFirstDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFirstDlg, CDialog)
//{{AFX_MSG_MAP(CFirstDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFirstDlg message handlers
BOOL CFirstDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString csTCID;
int TCCount;
CString csTCCount;
CString csNodeCount;
CString csSegmentCount;
CMarkup xml;
CMarkup xmlTemp;
xmlTemp.SetDoc("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
CMarkup xml_Node_TestCase;
xml_Node_TestCase.SetDoc("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
xml.Load("TestSuite01.xml");
xml.FindElem("TS");
csTCCount = xml.GetAttrib("TestCaseCount");
TCCount=atoi(xml.GetAttrib("TestCaseCount"));
// vector<TestCaseNode> TestSuite(TCCount);
// xml.FindChildElem("TC");
//依次取出每个测试用例的每个域值放在链表TestSuite
for(int i=0;i<TCCount;i++)
{
xml.FindChildElem("TC");
xml.IntoElem();
xmlTemp.AddElem("测试用例");
//测试用例编号
// CString cst=xml.GetAttrib("ID");
// int tcid=atoi(xml.GetAttrib("ID"));
// TS_TCID.push_back(tcid);
TestSuite[i].TC_ID=atoi(xml.GetAttrib("ID"));
xmlTemp.AddAttrib("编号",TestSuite[i].TC_ID);
//测试用例执行完所用时间
// TS_TCTime.push_back(atoi(xml.GetAttrib("Time")));
TestSuite[i].Time=atoi(xml.GetAttrib("Time"));
xmlTemp.AddAttrib("时间",TestSuite[i].Time);
//测试用例对应的各个点
xml.FindChildElem("Node");
xml.IntoElem();
TestSuite[i].TC_Node_Count=atoi(xml.GetAttrib("NodeCount"));
NODECOUNT+=TestSuite[i].TC_Node_Count;
xmlTemp.AddChildElem("节点");
xmlTemp.AddAttrib("节点总数",TestSuite[i].TC_Node_Count);
// xml.FindChildElem("PElement");
for(int j=0;j<TestSuite[i].TC_Node_Count;j++)
{
xml.FindChildElem("NElement");
TestSuite[i].NodeList.push_back(atoi(xml.GetChildData()));
xmlTemp.AddChildElem("NElement",TestSuite[i].NodeList[j]);
// xml.FindChildElem("PElement");
}//每个测试用例中的点循环
xml.OutOfElem();
//测试用例对应的各个段
xml.FindChildElem("Segment");
xml.IntoElem();
TestSuite[i].TC_Seg_Count=atoi(xml.GetAttrib("SegCount"));
SEGCOUNT+=TestSuite[i].TC_Seg_Count;
xmlTemp.AddChildElem("段");
xmlTemp.AddAttrib("段总数",TestSuite[i].TC_Seg_Count);
xml.FindChildElem("SElement");
for(int k=0;k<TestSuite[i].TC_Seg_Count;k++)
{
TestSuite[i].SegmentList.push_back(atoi(xml.GetChildData()));
xmlTemp.AddChildElem("SElement",TestSuite[i].SegmentList[k]);
xml.FindChildElem("SElement");
}//每个测试用例中的段循环
xml.OutOfElem();
xmlTemp.Save("xmlTemp.xml");
xml.OutOfElem();
xml.FindElem("TC");
}//整个测试用例集的循环
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
//将testsuite中的数据整理为一个node对应多个tc的表
for(int t=0;t<Node_TestCase.size();t++)
{
Node_TestCase[t].Node_id=t;
Node_TestCase[t].reverse=2;
Node_TestCase[t].TC_count=0;
}
for(int ii=1;ii<TestSuite.size();ii++)
{
for(int iii=0;iii<TestSuite[ii].TC_Node_Count;iii++)
{
int n=TestSuite[ii].NodeList[iii];
// Node_TestCase[n].Node_id=n;
Node_TestCase[n].TC_count++;
Node_TestCase[n].TC.push_back(TestSuite[ii].TC_ID);
}
}
//输出表Node_TestCase
xml_Node_TestCase.AddElem("TS");
xml_Node_TestCase.IntoElem();
for(int jj=1;jj<Node_TestCase.size();jj++)
{
xml_Node_TestCase.AddElem("Node");
xml_Node_TestCase.AddAttrib("Node_id",Node_TestCase[jj].Node_id);
xml_Node_TestCase.AddAttrib("reverse",Node_TestCase[jj].reverse);
xml_Node_TestCase.AddAttrib("TC_count",Node_TestCase[jj].TC_count);
//xml_Node_TestCase.IntoElem();
for(int jjj=0;jjj<Node_TestCase[jj].TC.size();jjj++)
xml_Node_TestCase.AddChildElem("TC",Node_TestCase[jj].TC[jjj]);
// xml_Node_TestCase.OutOfElem();
}
xml_Node_TestCase.OutOfElem();
xml_Node_TestCase.Save("xml_Node_TestCase.xml");
/*
CString str;
str.Format("%d",TestSuite[1].TC_ID);
CStatic* pWnd=(CStatic*)GetDlgItem(IDC_STATIC1);
pWnd->SetWindowText("OK");
// xml.OutOfElem();
// }
//将用例存入二维数组
for(int ii=0;ii!=TestSuite.size();ii++)
{
for(int jj=0;jj<TestSuite[ii].TC_Node_Count;jj++)
{
int m=TestSuite[ii].TC_ID;
int n=TestSuite[ii].NodeList[jj];
array2[m][n]=1;
}
}
*/
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
void CFirstDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CMarkup xmlNode;
xmlNode.SetDoc("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
CMarkup xmlSeg;
xmlSeg.SetDoc("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
CMarkup xmlNodeSequen;
xmlNodeSequen.SetDoc("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
CMarkup xmlSegSequen;
xmlSegSequen.SetDoc("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
CMarkup xmlMinGreedy;
xmlMinGreedy.SetDoc("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
CMarkup xmlMinHeur;
xmlMinHeur.SetDoc("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
vector<TC_Node_Node> vec_TC_Node(NODECOUNT);
vector<TC_Node_Node> squen_TC_Node(NODECOUNT);
vector<TC_Node_Node> greedy_TC_Node(NODECOUNT);
vector<TC_Seg_Node> vec_TC_Seg(SEGCOUNT);
vector<TC_Seg_Node> squen_TC_Seg(SEGCOUNT);
vector<int> vect1;
vector<int> vect2;
vector<int> vect3;
int testedNode=NODECOUNT;
int testedseg=SEGCOUNT;
// TC_Node.resize(22);
// int **a;
// int array2[30][50];
// memset(array2,0,sizeof(array2));
// vector<int> array1;
// int row[30];
// int column[50];
// vector<int> array2(row,column);
// a=0;
// vector<TestCaseNode>::iterator iterTS=TestSuite.begin();
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
//从Node方面进行最小化
/* for(vector<TestCaseNode>::iterator iterTS=TestSuite.begin();iterTS!=TestSuite.end();++iterTS)
{
if(TestSuite[i].TC_Node_Count==1)
{
TestSuiteMin[i]=TestSuite[i];
TestSuite[i]=TestSuite.end();
// TestSuite.resize(TestSuite.size()) ;
}
}
*/
/*
for(int i=0;i!=TestSuite.size();i++)
{
if(TestSuite[i].TC_Node_Count==1)
{
TestSuiteMin=TestSuite;
TestSuite[i]=TestSuite.end();
// TestSuite.resize(TestSuite.size()) ;
}
}
*/
int cur_p=0;
int cur_s=0;
/*
xmlNode.AddElem("TC-Node");
xmlNode.IntoElem();
xmlSeg.AddElem("TC-Segment");
xmlSeg.IntoElem();
*/
for(int i=0;i!=TestSuite.size();i++)
{
//把TC与Node对应信息存入二维vector数组TC_Node
for(int j=0;j<TestSuite[i].TC_Node_Count;j++)
{
// xmlNode.AddElem("TC");
vec_TC_Node[cur_p].tcid=TestSuite[i].TC_ID;
vec_TC_Node[cur_p].Node=TestSuite[i].NodeList[j];
vec_TC_Node[cur_p].reverse=2;
vec_TC_Node[cur_p++].time=TestSuite[i].Time;
/*
xmlNode.AddAttrib("TC_ID",vec_TC_Node[cur_p].tcid);
xmlNode.AddAttrib("Node",vec_TC_Node[cur_p].Node);
xmlNode.AddAttrib("time",vec_TC_Node[cur_p].time);
*/
/* int m=TestSuite[i].TC_ID;
int n=TestSuite[i].NodeList[j];
TC_Node[m][n]=1;
*/
}
//把TC与Segment对应信息存入二维vector类型数组TC_Seg
for(int t=0;t<TestSuite[i].TC_Seg_Count;t++)
{
// xmlSeg.AddElem("TC");
vec_TC_Seg[cur_s].tcid=TestSuite[i].TC_ID;
vec_TC_Seg[cur_s].segment=TestSuite[i].SegmentList[t];
vec_TC_Seg[cur_s++].time=TestSuite[i].Time;
/*
xmlSeg.AddAttrib("TC_ID",vec_TC_Seg[cur_s].tcid);
xmlSeg.AddAttrib("segment",vec_TC_Seg[cur_s].segment);
xmlSeg.AddAttrib("time",vec_TC_Seg[cur_s].time);
*/
/*
int m=TestSuite[i].TC_ID;
int n=TestSuite[i].SegmentList[t];
TC_Seg[m][n]=1;
*/
}
}
/* xmlNode.OutOfElem();
xmlNode.Save("xmlNode.xml");
xmlSeg.OutOfElem();
xmlSeg.Save("xmlSeg.xml");
*/
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
//统计被测到的Node的数目,vect1中存放不重复的Node
vect1.push_back(vec_TC_Node[0].Node);
for(int kk=0;kk<vec_TC_Node.size();kk++)
{
for(int kkk=0;kkk<vect1.size();kkk++)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -