2009-01-12 22:06:54 +00:00
|
|
|
#include "UnitTestPCH.h"
|
2008-07-22 22:52:16 +00:00
|
|
|
|
2014-09-07 23:52:03 +00:00
|
|
|
#include <RemoveComments.h>
|
2008-07-22 22:52:16 +00:00
|
|
|
|
|
|
|
|
2014-09-07 23:52:03 +00:00
|
|
|
using namespace std;
|
|
|
|
using namespace Assimp;
|
2008-07-22 22:52:16 +00:00
|
|
|
|
|
|
|
|
2009-01-12 22:06:54 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2014-09-07 23:52:03 +00:00
|
|
|
TEST(RemoveCommentsTest, testSingleLineComments)
|
2008-07-22 22:52:16 +00:00
|
|
|
{
|
|
|
|
const char* szTest = "int i = 0; \n"
|
|
|
|
"if (4 == //)\n"
|
|
|
|
"\ttrue) { // do something here \n"
|
|
|
|
"\t// hello ... and bye //\n";
|
|
|
|
|
2014-09-07 23:52:03 +00:00
|
|
|
|
2008-07-22 22:52:16 +00:00
|
|
|
char* szTest2 = new char[::strlen(szTest)+1];
|
|
|
|
::strcpy(szTest2,szTest);
|
|
|
|
|
|
|
|
const char* szTestResult = "int i = 0; \n"
|
|
|
|
"if (4 == \n"
|
|
|
|
"\ttrue) { \n"
|
|
|
|
"\t \n";
|
|
|
|
|
|
|
|
CommentRemover::RemoveLineComments("//",szTest2,' ');
|
2014-09-07 23:52:03 +00:00
|
|
|
EXPECT_STREQ(szTestResult, szTest2);
|
2008-07-22 22:52:16 +00:00
|
|
|
|
|
|
|
delete[] szTest2;
|
|
|
|
}
|
|
|
|
|
2009-01-12 22:06:54 +00:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2014-09-07 23:52:03 +00:00
|
|
|
TEST(RemoveCommentsTest, testMultiLineComments)
|
2008-07-22 22:52:16 +00:00
|
|
|
{
|
2014-09-07 23:52:03 +00:00
|
|
|
const char* szTest =
|
2008-07-22 22:52:16 +00:00
|
|
|
"/* comment to be removed */\n"
|
|
|
|
"valid text /* \n "
|
|
|
|
" comment across multiple lines */"
|
|
|
|
" / * Incomplete comment */ /* /* multiple comments */ */";
|
|
|
|
|
2014-09-07 23:52:03 +00:00
|
|
|
const char* szTestResult =
|
2008-07-22 22:52:16 +00:00
|
|
|
" \n"
|
|
|
|
"valid text "
|
|
|
|
" "
|
|
|
|
" / * Incomplete comment */ */";
|
|
|
|
|
|
|
|
char* szTest2 = new char[::strlen(szTest)+1];
|
|
|
|
::strcpy(szTest2,szTest);
|
|
|
|
|
|
|
|
CommentRemover::RemoveMultiLineComments("/*","*/",szTest2,' ');
|
2014-09-07 23:52:03 +00:00
|
|
|
EXPECT_STREQ(szTestResult, szTest2);
|
2008-07-22 22:52:16 +00:00
|
|
|
|
|
|
|
delete[] szTest2;
|
2014-08-17 22:46:21 +00:00
|
|
|
}
|