⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dataverify.cxx

📁 RTP协议
💻 CXX
📖 第 1 页 / 共 2 页
字号:
	DataClass test4 = "19238471832758715289725371";	DataClass test5 = "4000@";	test_verify(test0.convertInt() == 1024);	test_verify(test1.convertInt() == 1000);	test_verify (test2.convertInt() == 1000);	test_verify(test3.convertInt() == 1000);	test_verify (test5.convertInt() == 4000);    }    {	DataClass j = "asnf abcd";	string s = j.convertString();	test_verify (DataClass(s) == j);    }    {	const int MAX_TESTS = 25;		DataClass data[MAX_TESTS];	data[0] = "Testing Data";	test_verify (strcmp(data[0].logData(), "Testing Data") == 0);	data[1] = data[0];	test_verify (strcmp(data[1].logData(), "Testing Data") == 0);	data[2] = "Testing Data";	data[2] += "added data";	test_verify (strcmp(data[2].logData(), "Testing Dataadded data") == 0);	data[3] = data[1] + data[2];	test_verify (data[3] == "Testing DataTesting Dataadded data");	string str("This is a string");	DataClass data4(str);	test_verify (data4 == "This is a string");	//	mstring mstr("This is a mstring");	//	DataClass data5(mstr);	//	test_verify (data5 == "This is a mstring");	int value = 5;	DataClass data6(value);	test_verify (data6 == "5");	DataClass testData;	testData = "alphb";		data[7] = "alpha";		test_verify ((data[7] < testData) &&		     !(data[7] == testData) &&		     !(data[7] > testData) &&		     (data[7] != testData));	data[8] = "alphc";	test_verify ((data[8] > testData) &&		     !(data[8] == testData) &&		     !(data[8] < testData) &&		     (data[8] != testData));	data[9] = "alphb";	test_verify ((data[9] == testData) &&		     !(data[9] < testData) &&		     !(data[9] > testData) &&		     !(data[9] != testData));	data[10] = "alphbx";		test_verify ((data[10] > testData) &&		     !(data[10] < testData) &&		     !(data[10] == testData) &&		     (data[10] != testData));	data[11] = "hello, world!";		char newstr[256];	strcpy(newstr, data[11].logData());		test_verify (	    (strcmp(newstr, "hello, world!") == 0) && (data[11].length() == 13));    }    {	DataClass test = "Hello, world!";	DataClass test2 = "Hello";	test_verify ( test > DataClass("Hello"));	test_verify ( test > test2);	test_verify ( DataClass("Hello") < test);	test_verify ( test2 < test );    }    {	// test lowercase() and uppercase()	DataClass test = "Hello, World!";	test.lowercase();	test_verify(test == "hello, world!");	test_verify(test != "Hello, World!");	DataClass test2 = "Hello, World!";	test2.uppercase();	test_verify(test2 == "HELLO, WORLD!");	test_verify(test2 != "Hello, World!");    }    /// test matchChar    {	char fail;	DataClass test = "this is a simple test";	{	    DataClass a = test.matchChar("sal", &fail);	    test_verify(fail == 's');	    test_verify(a == "thi");	}	{	    DataClass a = test.matchChar("sal", &fail);	    test_verify(fail == 's');	    test_verify(a == " i");	}	{	    DataClass a = test.matchChar("sal", &fail);	    test_verify(fail == 'a');	    test_verify(a == " ");	}	{	    DataClass a = test.matchChar("sal", &fail);	    test_verify(fail == 's');	    test_verify(a == " ");	}	{	    DataClass a = test.matchChar("sal", &fail);	    test_verify(fail == 'l');	    test_verify(a == "imp");	}	{	    DataClass a = test.matchChar("sal", &fail);	    test_verify(fail == 's');	    test_verify(a == "e te");	}	{	    DataClass a = test.matchChar("sal", &fail);	    test_verify(fail == '\0');	    test_verify(test == "t");	}    }    {	DataClass test = "From:    testItem";	char fail;	DataClass a = test.matchChar(": ", &fail);	test_verify(fail == ':');	test_verify(a == "From");	test_verify(test == "    testItem");    }    // test getLine    {	DataClass test = "test\ntest\r\ntest\r\n";	{	    bool fail;	    DataClass a = test.getLine(&fail);	    test_verify(fail == false);	    test_verify(a == "test");	}	{	    bool fail;	    DataClass a = test.getLine(&fail);	    test_verify(fail == false);	    test_verify(a == "test");	}	{	    bool fail;	    DataClass a = test.getLine(&fail);	    test_verify(fail == false);	    test_verify(a == "test");	}	{	    bool fail;	    DataClass a = test.getLine(&fail);	    test_verify(fail == true);	}	DataClass test2 = "test\r\n\r\ntest\r\n";	{	    bool fail;	    DataClass a = test2.getLine(&fail);	    test_verify(fail == false);	    test_verify(a == "test");	}	{	    bool fail;	    DataClass a = test2.getLine(&fail);	    test_verify(fail == false);	    test_verify(a == "");	}	{	    bool fail;	    DataClass a = test2.getLine(&fail);	    test_verify(fail == false);	    test_verify(a == "test");	}    }    // test removeLWS    {	DataClass test = "From: test\r\n   continuation\r\n test2\r\n";	test.removeLWS();	test_verify(test == "From: test     continuation   test2\r\n");	cout << test << endl;    }    // test substring    {	DataClass test = "abcdefg";	test_verify(test == test.substring(0,-1));	test_verify(test.substring(0,3) == "abc");	test_verify(test.substring(0,0) == "");	test_verify(test.substring(1,-1) == "bcdefg");	test_verify(test.substring(1,2) == "b");	test_verify(test.substring(1,1) == "");	test_verify(test.substring(1,4) == "bcd");	cout << test.substring(0,test.length() - 1) << endl;	test_verify(test.substring(0,test.length()) == test);	test_verify(test.substring(1,test.length() - 1) == "bcdef");    }#if 0    {      Data buf = "1000,1001,\n";      std::vector <Data> retList;      bool matchFail = false;      Data tok = buf.parse(",\n ", &matchFail);            while (!matchFail)	{	  retList.push_back(tok);	  tok = buf.parse(",\n ", &matchFail);	}            if(matchFail)	{	  retList.push_back(buf);	  buf.erase();	}      test_verify(retList[0] == "1000");      test_verify(retList[1] == "1001");    }#endif    {      DataClass buf = "1000,1001";      bool matchFail;      DataClass tok = buf.parse(",\n ", &matchFail);      test_verify(tok == "1000");      test_verify(buf == "1001");    }    {      DataClass buf = "1000  ";      bool matchFail;      Data tok = buf.parse(",\n ", &matchFail);      test_verify(tok == "1000");      test_verify(buf == "");    }    {      Data buf = "1000,1001,\n";      bool matchFail;      Data tok = buf.parse(",\n ", &matchFail);            test_verify(tok == "1000");      test_verify(buf == "1001,\n");      tok = buf.parse(",\n ", &matchFail);      test_verify(tok == "1001");      test_verify(buf == "");      tok = buf.parse(",\n ", &matchFail);      test_verify(matchFail == true);      test_verify(buf == "");    }}int main(){    cerr << "Data!" << endl;    test<Data>();#if 0    cerr << "CopyOnWriteData!" << endl;    test<CopyOnWriteData>();    cerr << "StringData!" << endl;    test<StringData>();#endif    return test_return_code(141);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -