{"id":2297,"date":"2019-04-01T09:50:56","date_gmt":"2019-04-01T09:50:56","guid":{"rendered":""},"modified":"2019-04-01T17:51:19","modified_gmt":"2019-04-01T09:51:19","slug":"%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e5%8d%95%e7%89%87%e6%9c%ba%e7%9a%84%e8%87%aa%e5%8a%a8%e5%8c%96%e6%b5%8b%e8%af%95","status":"publish","type":"post","link":"http:\/\/www.szryc.com\/?p=2297","title":{"rendered":"\u5982\u4f55\u5b9e\u73b0\u5355\u7247\u673a\u7684\u81ea\u52a8\u5316\u6d4b\u8bd5"},"content":{"rendered":"

\n\t\u6d4b\u8bd5\uff0c\u76f8\u4fe1\u5bf9\u6bcf\u4e00\u4e2a\u641e\u7a0b\u5e8f\u7684\u90fd\u4e0d\u4f1a\u751f\u758f\uff0c\u7136\u540e\u6211\u4eec\u4f1a\u8054\u60f3\u5230\u4ec0\u4e48\u5355\u5143\u6d4b\u8bd5\uff0c\u96c6\u6210\u6d4b\u8bd5\uff0c\u53d1\u5e03\u6d4b\u8bd5\uff0c\u9ed1\u76d2\u6d4b\u8bd5\uff0c\u767d\u76d2\u6d4b\u8bd5\u7b49\u7b49\u4e00\u7cfb\u5217\u7684\u540d\u8bcd\u3002\u4f46\u5728\u5355\u7247\u673a<\/u>\u9886\u57df\uff0c\u66f4\u591a\u7684\u529f\u80fd\u6d4b\u8bd5\u3002\u6d4b\u8bd5\u4eba\u5458\uff0c\u5728\u8bd5\u7528\u4ea7\u54c1\u540e\uff0c\u53d1\u73b0bug\u7136\u540e\u62a5\u544a\u7ed9\u7814\u53d1\u4eba\u5458\uff0c\u5f80\u5f80\u5ffd\u7565\u4e2d\u95f4\u7684\u5355\u5143\u6d4b\u8bd5\uff0c\u5728\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\u5c31\u4fdd\u8bc1\u5404\u6a21\u5757\u7684\u529f\u80fd\u3002<\/p>\n

\n\t\u5bf9\u4e8e\u4e00\u4e9bJAVA<\/u>\uff0c C++<\/u>\u5f00\u53d1\u4eba\u5458\uff0ccppunit\uff0c junit\u8fd9\u4e9b\u81ea\u52a8\u5316\u6d4b\u8bd5\u6846\u67b6\uff0c\u7136\u800c\uff0c\u5bf9\u4e8e\u5355\u7247\u673a\u5f00\u53d1\u4eba\u5458\uff0c\u53c8\u600e\u4e48\u5b9e\u73b0\u81ea\u52a8\u5316\u6d4b\u8bd5\u5462\uff1f<\/p>\n

\n\t <\/div>\n

\n\t\u4e0b\u9762\u5c31UART<\/u>\u9a71\u52a8\u7684\u6d4b\u8bd5\u8bf4\u8d77\u3002<\/p>\n

\n\t\u6d4b\u8bd5\u7684\u76ee\u7684<\/p>\n

\n\t\u9996\u5148\u786e\u8ba4 \u529f\u80fd\u8fd9\u6761\u4e3b\u7ebf\u53ef\u4ee5\u8d70\u901a\u3002\u6bd4\u5982UART\u53d1\u9001\u5b57\u7b26\u8fd9\u4e2a\u529f\u80fd\u4e3b\u7ebf\u662f\uff1aSysCtl \u914d\u7f6eMCU<\/u>\u65f6\u949f<\/u>\u6e90\uff0c\u914d\u7f6eUART\u65f6\u949f\u6e90\uff0c SysCtl\u4f7f\u80fdUART\u5916\u8bbe\uff0c GPI<\/u>O\u914d\u7f6eRX\uff0c TX\u7ba1\u811a\u7684\u590d\u7528\uff0c\u914d\u7f6eBAUD\u5de5\u4f5c\u6a21\u5f0f\u7b49\uff0c\u7136\u540e\u624d\u662f\u53d1\u9001\u3002 \u4e5f\u5c31\u662f\u8bf4\uff0c\u60f3\u8981\u6210\u529f\u53d1\u9001\u4e00\u4e2a\u5b57\u7b26\uff0c\u524d\u9762\u7684\u6bcf\u4e00\u4e2a\u90fd\u4e0d\u80fd\u7f3a\u5931\u3002<\/p>\n

\n\t\"\u5982\u4f55\u5b9e\u73b0\u5355\u7247\u673a\u7684\u81ea\u52a8\u5316\u6d4b\u8bd5\"<\/p>\n

\n\t\u5176\u6b21\u662f\u529f\u80fd\u7684\u6b63\u786e\u6027\u3002<\/p>\n

\n\t\u5728\u5176\u6b21\u662f\u6539\u5584\uff0c\u6539\u8fdb\uff0c\u4f18\u5316\u3002<\/p>\n

\n\t\u4ec0\u4e48\u662f\u4e00\u4e2a\u6d4b\u8bd5<\/p>\n

\n\t\u6d4b\u8bd5\uff0c\u7ed9\u5b9a\u4e00\u4e2a\u6761\u4ef6\uff0c\u7136\u540e\u4f1a\u5f97\u5230\u4e00\u4e2a\u7ed3\u679c\uff0c\u671f\u671b\u7684\u7ed3\u679c\u4e0e\u5b9e\u9645\u7684\u7ed3\u679c\u6bd4\u8f83\uff0c\u5982\u679c\u4e00\u81f4\uff0c\u5c31\u8bf4\u6d4b\u8bd5\u901a\u8fc7\uff0c\u5426\u5219\uff0c\u5931\u8d25\u3002\u5f85\u6d4b\u529f\u80fd\uff0c\u5c31\u50cf\u662f\u4e00\u4e2a\u65b9\u7a0b\u5f0f\uff0c\u6211\u4eec\u4e00\u4e2a\u4e00\u4e2a\u7684\u4ee3\u5165\uff0c\u770b\u6bcf\u4e00\u6b21\u7684\u7ed3\u679c\u662f\u5426\u6b63\u786e\u3002<\/p>\n

\n\t\u5bf9\u4e8e\u4eba\u6765\u8bf4\uff0c\u6700\u7ec8\u7684\u7ed3\u679c\uff0c\u9700\u8981\u901a\u8fc7\u4eba\u7684\u542c\u89c9\u6216\u89c6\u89c9\u611f\u77e5\u7684\u3002\u4ece\u7ec8\u7aef\u770b\u5230\u4e00\u4e2aPass\u8bf4\u660e\u6d4b\u8bd5\u901a\u8fc7\uff0cLCD\u6b63\u786e\u663e\u793a\u4e86\u5b57\u7b26\uff0c\u4e5f\u8bf4\u660e\u4e86\u901a\u8fc7\u3002\u6211\u628a\u6d4b\u8bd5\u5206\u4e86\u4e00\u4e0b\u7c7b\uff1a<\/p>\n

\n\t\u4e0d\u80fd\u901a\u8fc7\u7a0b\u5e8f\u8bfb\u5230\u7ed3\u679c\u7684\uff0c\u53ea\u80fd\u901a\u8fc7\u4eba\u770b\u5230\u6216\u542c\u5230\u7684\uff0c\u6bd4\u5982LCD\uff0c \u8fd9\u7c7b\u65e0\u6cd5\u5b9e\u73b0\u81ea\u52a8\u5316\u6d4b\u8bd5\u3002<\/p>\n

\n\t\u4e00\u7c7b\u53ef\u4ee5\u901a\u8fc7\u7a0b\u5e8f\u8bfb\u5230\u7ed3\u679c\u7684\uff0c\u4e00\u822c\u662f\u6267\u884c\u4e86\u4e00\u4e9b\u7a0b\u5f0f\uff0c\u4f1a\u5f97\u5230\u4e00\u4e2a\u72b6\u6001\/\u7ed3\u679c\uff0c\u7a0b\u5e8f\u6b63\u597d\u53ef\u4ee5\u8bfb\u5230\u3002\u6bd4\u5982 Write<\/u>\u540eRead.<\/p>\n

\n\t\u53ef\u4ee5\u628a\u5e95\u4e00\u7c7b\u8f6c\u6362\u6210\u7b2c\u4e8c\u7c7b\u7684\u3002\u6bd4\u5982UART\u7684\u53d1\u9001\uff0c\u53ef\u4ee5\u901a\u8fc7\u8d85\u7ea7\u7ec8\u7aef\u770b\u5230\u7ed3\u679c\u5224\u65ad\uff0c\u4e5f\u53ef\u4ee5\u501f\u52a9UART2\uff08\u529f\u80fd\u6b63\u786e\u7684\uff09\uff0c \u5b83\u4eec\u4e4b\u95f4\u901a\u4fe1\uff0c\u6765\u5b9e\u73b0\u81ea\u52a8\u5316\u3002<\/p>\n

\n\t\u90fd\u8bf4C\u8bed\u8a00 = \u51fd\u6570 + \u6570\u636e\uff0c\u6d4b\u8bd5\u540c\u6837\u3002\u597d\u70b9\u7684\u4ee3\u7801\uff0c\u662f\u4e0d\u4f1a\u628a\u6570\u636e\u4e0e\u51fd\u6570\u6df7\u5728\u4e00\u8d77\u7684\u3002\u90a3\u4e48\u4ec0\u4e48\u662f\u6d4b\u8bd5\u6570\u636e\u5462\uff1f<\/p>\n

\n\ttypedef struct<\/p>\n

\n\t{<\/p>\n

\n\ttTestConditi<\/u>on sCondiTIon;<\/p>\n

\n\ttTestResult sExpectResult;<\/p>\n

\n\t}tTestData;<\/p>\n

\n\ttTestData psTestDataTable\uff3b\uff3d = {<\/p>\n

\n\t{ \uff0c }\uff0c<\/p>\n

\n\t{ \uff0c }\uff0c<\/p>\n

\n\t};<\/p>\n

\n\t\u4e00\u4e2a\u4e00\u4e2a\u6d4b\u8bd5\uff0c\u5c06\u6784\u6210\u8fd9\u6837\u4e00\u4e2a\u7ed3\u6784\u4f53\u6570\u7ec4\u3002\u6d4b\u8bd5\u6570\u636e\u7684\u589e\u52a0\uff0c\u6216\u4fee\u6539\u4ec5\u4ec5\u9700\u8981\u4fee\u6539\u8fd9\u4e2a\u6570\u7ec4\u5c31\u53ef\u4ee5\uff0c\u800c\u65e0\u9700\u4fee\u6539\u4ee3\u7801\u3002\u6d4b\u8bd5\uff0c\u540c\u6837\u53d8\u7684\u5f88\u597d\u7ef4\u62a4\u3002<\/p>\n

\n\t\u4ec0\u4e48\u662f\u81ea\u52a8\u5316\u6d4b\u8bd5<\/p>\n

\n\t\u81ea\u52a8\u5316\u6d4b\u8bd5\uff0c\u5176\u5b9e\u5c31\u662f\u81ea\u52a8\u8c03\u7528\u6bcf\u4e00\u4e2a\u6d4b\u8bd5\uff0c\u4e00\u4e2a\u4e00\u4e2a\u8c03\u7528\uff0c\u7136\u540e\uff0c\u4ee5\u4eba\u53ef\u4ee5\u611f\u77e5\u7684\u65b9\u5f0f\uff0c\u62a5\u544a\u7ed3\u679c\u3002\u6bd4\u5982\uff0c\u5728\u8d85\u7ea7\u7ec8\u7aef\u4e2d\u6253\u5370PASS.<\/p>\n

\n\t\u6bcf\u4e00\u4e2a\u6d4b\u8bd5\uff0c\u90fd\u53ef\u80fd\u9700\u8981\u9996\u5148\u6784\u9020\u5b83\u4eec\u81ea\u5df1\u7684\u521d\u59cb\u73af\u5883\u3002\u6bcf\u4e00\u4e2a\u6d4b\u8bd5\u4e4b\u95f4\uff0c\u5b83\u4eec\u4e0d\u80fd\u4e92\u76f8\u5f71\u54cd\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u6d4b\u8bd5\u6267\u884c\u5b8c\u540e\uff0c\u5b83\u9700\u8981\u8fd8\u539f\u73af\u5883\u5230\u590d\u4f4d\u72b6\u6001\u3002<\/p>\n

\n\t\u4e0b\u9762\u63cf\u8ff0\u4e0b\uff0c\u6211\u7ecf\u5e38\u7528\u5230\u7684\u6d4b\u8bd5\u6846\u67b6\uff0c\u8fd9\u662f\u6211\u4ece\u4e00\u4e2a\u5f00\u6e90\u9879\u76ee\u4e2d\u6539\u53d8\u8fc7\u6765\u7684\uff1a<\/p>\n

\n\t\u4e00\u4e2a\u6d4b\u8bd5\u5de5\u7a0b\uff0c\u6709\u591a\u7ec4\u6d4b\u8bd5\uff08Suite\uff09\uff0c \u4e00\u4e2a\u7ec4\uff08Suite\uff09\u4e0b\u53ef\u80fd\u6709\u591a\u4e2a\u6d4b\u8bd5\u3002\u7ec4\u7684\u6982\u5ff5\uff0c\u5176\u5b9e\u5c31\u662f\u7ec4\u4ef6\uff0c\u628a\u76f8\u4f3c\u7684\u653e\u5728\u4e00\u7ec4\uff0c\u5c31\u50cf\u6587\u4ef6\u5939\u7ec4\u7ec7\u3002<\/p>\n

\n\t\/\/*****************************************************************************<\/p>\n

\n\t\/\/<\/p>\n

\n\t\/\/\uff01 brief Structure represenTIng a test case.<\/p>\n

\n\t\/\/<\/p>\n

\n\t\/\/*****************************************************************************<\/p>\n

\n\ttypedef struct<\/p>\n

\n\t{<\/p>\n

\n\t\/\/<\/p>\n

\n\t\/\/\uff01 brief Test case name get funcTIon.<\/p>\n

\n\t\/\/<\/p>\n

\n\tchar* \uff08*GetTest\uff09\uff08void\uff09;<\/p>\n

\n\t\/\/<\/p>\n

\n\t\/\/\uff01 brief Test case preparaTIon function.<\/p>\n

\n\t\/\/<\/p>\n

\n\tvoid \uff08*Setup\uff09\uff08void\uff09;<\/p>\n

\n\t\/\/<\/p>\n

\n\t\/\/\uff01 brief Test case clean up function.<\/p>\n

\n\t\/\/<\/p>\n

\n\tvoid \uff08*TearDown\uff09\uff08void\uff09;<\/p>\n

\n\t\/\/<\/p>\n

\n\t\/\/\uff01 brief Test case execution function.<\/p>\n

\n\t\/\/<\/p>\n

\n\tvoid \uff08*Execute\uff09\uff08void\uff09;<\/p>\n

\n\t}<\/p>\n

\n\ttTestCase;<\/p>\n

\n\tSetup\u662f\u4e3a\u4e86\u6784\u9020\u6d4b\u8bd5\u9700\u8981\u7684\u73af\u5883\u3002TearDown\u662f\u5728\u6d4b\u8bd5\u6267\u884c\u540e\uff0c\u8fd8\u539f\u6d4b\u8bd5\u73af\u5883\u3002Execute\u624d\u662f\u6d4b\u8bd5\u4e3b\u4f53\u3002Execute\u4e2d\u53ef\u4ee5\u8fdb\u884c\u4e00\u4e9bTestAssert\uff0c \u6765\u6267\u884c\u4e00\u4e2a\u4e00\u4e2a\u7684\u5224\u65ad\u3002<\/p>\n

\n\tGetTest\u4ec5\u4ec5\u662f\u4e3a\u4e86\u5728\u7ec8\u7aef\u6253\u5370\u4e00\u4e0b\u8fd9\u4e2a\u6d4b\u8bd5\u7684\u5185\u5bb9\u3002<\/p>\n

\n\t\u4e0b\u9762\u662f\u6846\u67b6mai<\/u>n\uff1a<\/p>\n

\n\txtBoolean<\/p>\n

\n\tTestMain\uff08void\uff09<\/p>\n

\n\t{<\/p>\n

\n\tint i\uff0c j;<\/p>\n

\n\tTestIOInit\uff08\uff09;<\/p>\n

\n\tPrintLine\uff08“”\uff09;<\/p>\n

\n\tPrintLine\uff08“*** CooCox CoIDE components test suites”\uff09;<\/p>\n

\n\tPrintLine\uff08“***”\uff09;<\/p>\n

\n\t#ifdef TEST_COMPONENTS_NAME<\/p>\n

\n\tPrint\uff08“*** Components\uff1a ”\uff09;<\/p>\n

\n\tPrintLine\uff08TEST_COMPONENTS_NAME\uff09;<\/p>\n

\n\t#endif<\/p>\n

\n\t#ifdef TEST_COMPONENTS_VERS<\/u>ION<\/p>\n

\n\tPrint\uff08“*** Version\uff1a ”\uff09;<\/p>\n

\n\tPrintLine\uff08TEST_COMPONENTS_VERSION\uff09;<\/p>\n

\n\t#endif<\/p>\n

\n\t#ifdef TEST_BOARD_NAME<\/p>\n

\n\tPrint\uff08“*** Test Board\uff1a ”\uff09;<\/p>\n

\n\tPrintLine\uff08TEST_BOARD_NAME\uff09;<\/p>\n

\n\t#endif<\/p>\n

\n\tPrintLine\uff08“”\uff09;<\/p>\n

\n\tg_bGlobalFail = xfalse;<\/p>\n

\n\ti = 0;<\/p>\n

\n\twhile \uff08g_psPatterns\uff3bi\uff3d\uff09<\/p>\n

\n\t{<\/p>\n

\n\tj = 0;<\/p>\n

\n\twhile \uff08g_psPatterns\uff3bi\uff3d\uff3bj\uff3d\uff09<\/p>\n

\n\t{<\/p>\n

\n\tPrintNewLine\uff08\uff09;<\/p>\n

\n\tPrint\uff08“--- Test Case ”\uff09;<\/p>\n

\n\tPrintN\uff08i + 1\uff09;<\/p>\n

\n\tPrint\uff08“\u3002”\uff09;<\/p>\n

\n\tPrintN\uff08j + 1\uff09;<\/p>\n

\n\tPrint\uff08“ \uff08”\uff09;<\/p>\n

\n\tPrint\uff08g_psPatterns\uff3bi\uff3d\uff3bj\uff3d-\u300bGetTest\uff08\uff09\uff09;<\/p>\n

\n\tPrintLine\uff08“\uff09”\uff09;<\/p>\n

\n\tExecuteTest\uff08g_psPatterns\uff3bi\uff3d\uff3bj\uff3d\uff09;<\/p>\n

\n\tif \uff08g_bLocalFail == xtrue\uff09<\/p>\n

\n\t{<\/p>\n

\n\tPrint\uff08“--- Result\uff1a FAILURE ”\uff09;<\/p>\n

\n\tPrintLine\uff08“”\uff09;<\/p>\n

\n\t\/\/<\/p>\n

\n\t\/\/printf error information<\/p>\n

\n\t\/\/<\/p>\n

\n\tPrint\uff08g_pcErrorInfoBuffer\uff09;<\/p>\n

\n\tPrintLine\uff08“”\uff09;<\/p>\n

\n\tif \uff08g_pcTokensBuffer \u300a g_pcTok\uff09<\/p>\n

\n\t{<\/p>\n

\n\tPrint\uff08“ The tokens in buffer is\uff1a ”\uff09;<\/p>\n

\n\tPrintTokens\uff08\uff09;<\/p>\n

\n\tPrintLine\uff08“”\uff09;<\/p>\n

\n\t}<\/p>\n

\n\t}<\/p>\n

\n\telse<\/p>\n

\n\t{<\/p>\n

\n\tPrintLine\uff08“--- Result\uff1a SUCCESS ”\uff09;<\/p>\n

\n\t}<\/p>\n

\n\tj++;<\/p>\n

\n\t}<\/p>\n

\n\ti++;<\/p>\n

\n\t}<\/p>\n

\n\tPrintNewLine\uff08\uff09;<\/p>\n

\n\tPrintLine\uff08“”\uff09;<\/p>\n

\n\tPrint\uff08“Final result\uff1a ”\uff09;<\/p>\n

\n\tif \uff08g_bGlobalFail == xtrue\uff09<\/p>\n

\n\tPrintLine\uff08“FAILURE”\uff09;<\/p>\n

\n\telse<\/p>\n

\n\tPrintLine\uff08“SUCCESS”\uff09;<\/p>\n

\n\treturn g_bGlobalFail;<\/p>\n

\n\t}<\/p>\n

\n\t\u5982\u9700\u5b8c\u6574\u7684\u6d4b\u8bd5\u6846\u67b6\u4ee3\u7801\uff0c\u8bf7\u8054\u7cfb\u6211\uff0c\u6216\u524d\u5f80\u6211\u4eec\u7684\u5f00\u6e90\u9879\u76ee\uff1ahttps:\/\/github.com\/coocox\/cox.<\/p>\n

\n\t\u8fd9\u662f\u4e00\u4e2a\u7edf\u4e00API\u6807\u51c6\u7684\u5916\u8bbe\u5e93\u3002\u57fa\u4e8eCoX\u7684\u9a71\u52a8\uff0c\u65e0\u9700\u79fb\u690d\uff0c\u5c31\u53ef\u4ee5\u7528\u5230\u5176\u4ed6MCU\u5e73\u53f0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6d4b\u8bd5\uff0c\u76f8\u4fe1\u5bf9\u6bcf\u4e00\u4e2a\u641e\u7a0b\u5e8f\u7684\u90fd\u4e0d\u4f1a\u751f\u758f\uff0c\u7136\u540e\u6211\u4eec\u4f1a\u8054\u60f3\u5230\u4ec0\u4e48\u5355\u5143\u6d4b\u8bd5\uff0c\u96c6\u6210\u6d4b\u8bd5\uff0c\u53d1\u5e03\u6d4b\u8bd5\uff0c\u9ed1\u76d2\u6d4b\u8bd5\uff0c\u767d\u76d2\u6d4b\u8bd5\u7b49\u7b49\u4e00\u7cfb\u5217\u7684\u540d\u8bcd\u3002\u4f46\u5728 \u5355\u7247\u673a \u9886\u57df\uff0c\u66f4\u591a\u7684\u529f\u80fd\u6d4b\u8bd5\u3002\u6d4b\u8bd5<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"_links":{"self":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2297"}],"collection":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2297"}],"version-history":[{"count":0,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2297\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2297"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}