zoukankan      html  css  js  c++  java
  • 词频统计器(测试)

    在网上学习了vs测试,发现都是以类为单位来测试类中的方法、属性。

    然而我的四则运算代码,没有类,是照着C的风格写的。

    于是我将代码中需要测试的方法 在测试类中进行重写。

    测试有点牵强。

    测试目标:是否从文章中能够提取出单词

    测试代码:

    #include "stdafx.h"
    using namespace System;
    using namespace System::Text;
    using namespace System::Collections::Generic;
    using namespace Microsoft::VisualStudio::TestTools::UnitTesting;
    
    namespace TestProject2
    {
    	[TestClass]
    	public ref class UnitTest
    	{
    	private:
    		TestContext^ testContextInstance;
    
    	public: 
    		property Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^ TestContext
    		{
    			Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^ get()
    			{
    				return testContextInstance;
    			}
    			System::Void set(Microsoft::VisualStudio::TestTools::UnitTesting::TestContext^ value)
    			{
    				testContextInstance = value;
    			}
    		};
    
    		#pragma region Additional test attributes
    		#pragma endregion 	
    		[TestMethod]
    		void TestMethod1()
    		{
    			char text[1000] = { "How are you? I am fun thank you ,and you" };
    			int i = 0;
    			while (text[i] != '')
    			{
    				char s[30];
    				int j = 0;
    				while ((text[i] >= 'a'&&text[i] <= 'z') || (text[i] >= 'A'&&text[i] <= 'Z') || text[i] == '-')
    				{
    					if (text[i] >= 'A'&&text[i] <= 'Z')
    						text[i] += 'a' - 'A';
    					s[j++] = text[i++];
    				}
    				Assert::IsNotNull(s[j]);
    				s[j] = '';
    				if (text[i] == '')
    					break;
    				else
    					i++;
    			}
    		};
    	};
    }
    

     测试结果:

  • 相关阅读:
    flash 观察帧频率的工具 fps counter
    flash builder 找不到所需要的AdobeFlashPlayer调试器版本
    好文好文
    win7下flash builder 4.5无法设置Courier New字体
    AS3日期工具
    png图片 透明区域如何 让其不响应鼠标事件?
    Access插入数据
    异步正则
    log4net异步刷新 TextBox (试运行版)
    Python对Xpath的支持
  • 原文地址:https://www.cnblogs.com/wangsen123/p/5909886.html
Copyright © 2011-2022 走看看