OSDN Git Service

PATCH: [ 1585418 ] CppUnit tests for StringDiff
authorKimmo Varis <kimmov@gmail.com>
Fri, 27 Oct 2006 15:18:59 +0000 (15:18 +0000)
committerKimmo Varis <kimmov@gmail.com>
Fri, 27 Oct 2006 15:18:59 +0000 (15:18 +0000)
Testing/CppUnit/Changes.txt [new file with mode: 0644]
Testing/CppUnit/StringDifferencing/ReadMe.txt [new file with mode: 0644]
Testing/CppUnit/StringDifferencing/Resource.h [new file with mode: 0644]
Testing/CppUnit/StringDifferencing/StdAfx.cpp [new file with mode: 0644]
Testing/CppUnit/StringDifferencing/StdAfx.h [new file with mode: 0644]
Testing/CppUnit/StringDifferencing/StringDifferencing.cpp [new file with mode: 0644]
Testing/CppUnit/StringDifferencing/StringDifferencing.dsp [new file with mode: 0644]
Testing/CppUnit/StringDifferencing/StringDifferencing.h [new file with mode: 0644]
Testing/CppUnit/StringDifferencing/StringDifferencing.rc [new file with mode: 0644]
Testing/CppUnit/StringDifferencing/TestCase1.cpp [new file with mode: 0644]
Testing/CppUnit/StringDifferencing/TestCase1.h [new file with mode: 0644]

diff --git a/Testing/CppUnit/Changes.txt b/Testing/CppUnit/Changes.txt
new file mode 100644 (file)
index 0000000..8764a88
--- /dev/null
@@ -0,0 +1,8 @@
+Testing\selftest\Changes.txt\r
+\r
+2006-10-27 Kimmo\r
+ PATCH: [ 1585418 ] CppUnit tests for StringDiff\r
+  Add folder Testing/CppUnit for unit tests\r
+  Add folder CppUnit/StringDifferencing and its contents\r
+\r
+\r
diff --git a/Testing/CppUnit/StringDifferencing/ReadMe.txt b/Testing/CppUnit/StringDifferencing/ReadMe.txt
new file mode 100644 (file)
index 0000000..6166d93
--- /dev/null
@@ -0,0 +1,42 @@
+========================================================================\r
+       CONSOLE APPLICATION : StringDifferencing\r
+========================================================================\r
+\r
+\r
+AppWizard has created this StringDifferencing application for you.  \r
+\r
+This file contains a summary of what you will find in each of the files that\r
+make up your StringDifferencing application.\r
+\r
+StringDifferencing.dsp\r
+    This file (the project file) contains information at the project level and\r
+    is used to build a single project or subproject. Other users can share the\r
+    project (.dsp) file, but they should export the makefiles locally.\r
+\r
+StringDifferencing.cpp\r
+    This is the main application source file.\r
+\r
+StringDifferencing.rc\r
+    This is a listing of all of the Microsoft Windows resources that the\r
+    program uses.  It includes the icons, bitmaps, and cursors that are stored\r
+    in the RES subdirectory.  This file can be directly edited in Microsoft\r
+    Visual C++.\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+Other standard files:\r
+\r
+StdAfx.h, StdAfx.cpp\r
+    These files are used to build a precompiled header (PCH) file\r
+    named StringDifferencing.pch and a precompiled types file named StdAfx.obj.\r
+\r
+Resource.h\r
+    This is the standard header file, which defines new resource IDs.\r
+    Microsoft Visual C++ reads and updates this file.\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+Other notes:\r
+\r
+AppWizard uses "TODO:" to indicate parts of the source code you\r
+should add to or customize.\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
diff --git a/Testing/CppUnit/StringDifferencing/Resource.h b/Testing/CppUnit/StringDifferencing/Resource.h
new file mode 100644 (file)
index 0000000..db5e0f3
--- /dev/null
@@ -0,0 +1,16 @@
+//{{NO_DEPENDENCIES}}\r
+// Microsoft Visual C++ generated include file.\r
+// Used by StringDifferencing.rc\r
+//\r
+#define IDS_HELLO                       1\r
+\r
+// Next default values for new objects\r
+// \r
+#ifdef APSTUDIO_INVOKED\r
+#ifndef APSTUDIO_READONLY_SYMBOLS\r
+#define _APS_NEXT_RESOURCE_VALUE        101\r
+#define _APS_NEXT_COMMAND_VALUE         40001\r
+#define _APS_NEXT_CONTROL_VALUE         1000\r
+#define _APS_NEXT_SYMED_VALUE           101\r
+#endif\r
+#endif\r
diff --git a/Testing/CppUnit/StringDifferencing/StdAfx.cpp b/Testing/CppUnit/StringDifferencing/StdAfx.cpp
new file mode 100644 (file)
index 0000000..b547f16
--- /dev/null
@@ -0,0 +1,36 @@
+// stdafx.cpp : source file that includes just the standard includes\r
+//     StringDifferencing.pch will be the pre-compiled header\r
+//     stdafx.obj will contain the pre-compiled type information\r
+\r
+#include "stdafx.h"\r
+\r
+// TODO: reference any additional headers you need in STDAFX.H\r
+// and not in this file\r
+\r
+/**\r
+ * Code below is copied from /Src/StdAfx.h\r
+ */\r
+\r
+// Convert any negative inputs to negative char equivalents\r
+// This is aimed at correcting any chars mistakenly \r
+// sign-extended to negative ints.\r
+// This is ok for the UNICODE build because UCS-2LE code bytes\r
+// do not extend as high as 2Gig (actually even full Unicode\r
+// codepoints don't extend that high).\r
+static wint_t normch(wint_t c)\r
+{\r
+#ifdef _UNICODE\r
+       return (unsigned short)(short)c;\r
+#else\r
+       return (unsigned char)(char)c;\r
+#endif\r
+}\r
+\r
+/**\r
+ * @brief Return non-zero if input character is a space.\r
+ * Also converts any negative inputs to negative char equivalents (see normch).\r
+ */\r
+int xisspace (wint_t c)\r
+{\r
+  return _istspace (normch(c));\r
+}\r
diff --git a/Testing/CppUnit/StringDifferencing/StdAfx.h b/Testing/CppUnit/StringDifferencing/StdAfx.h
new file mode 100644 (file)
index 0000000..2349cd5
--- /dev/null
@@ -0,0 +1,35 @@
+// stdafx.h : include file for standard system include files,\r
+//  or project specific include files that are used frequently, but\r
+//      are changed infrequently\r
+//\r
+\r
+#if !defined(AFX_STDAFX_H__D64D3318_60FB_479C_81CB_4AC3DFDC2103__INCLUDED_)\r
+#define AFX_STDAFX_H__D64D3318_60FB_479C_81CB_4AC3DFDC2103__INCLUDED_\r
+\r
+#if _MSC_VER > 1000\r
+#pragma once\r
+#endif // _MSC_VER > 1000\r
+\r
+#define VC_EXTRALEAN           // Exclude rarely-used stuff from Windows headers\r
+\r
+#include <afx.h>\r
+#include <afxwin.h>         // MFC core and standard components\r
+#include <afxext.h>         // MFC extensions\r
+#include <afxdtctl.h>          // MFC support for Internet Explorer 4 Common Controls\r
+#include <afxtempl.h>\r
+\r
+#ifndef _AFX_NO_AFXCMN_SUPPORT\r
+#include <afxcmn.h>                    // MFC support for Windows Common Controls\r
+#endif // _AFX_NO_AFXCMN_SUPPORT\r
+\r
+#include <iostream>\r
+\r
+// TODO: reference additional headers your program requires here\r
+\r
+int xisspace (wint_t c);\r
+\r
+\r
+//{{AFX_INSERT_LOCATION}}\r
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.\r
+\r
+#endif // !defined(AFX_STDAFX_H__D64D3318_60FB_479C_81CB_4AC3DFDC2103__INCLUDED_)\r
diff --git a/Testing/CppUnit/StringDifferencing/StringDifferencing.cpp b/Testing/CppUnit/StringDifferencing/StringDifferencing.cpp
new file mode 100644 (file)
index 0000000..5b1da85
--- /dev/null
@@ -0,0 +1,73 @@
+// StringDifferencing.cpp : Defines the entry point for the console application.\r
+//\r
+\r
+#include "stdafx.h"\r
+#include "StringDifferencing.h"\r
+\r
+#include <cppunit/BriefTestProgressListener.h>\r
+#include <cppunit/CompilerOutputter.h>\r
+#include <cppunit/extensions/TestFactoryRegistry.h>\r
+#include <cppunit/TestResult.h>\r
+#include <cppunit/TestResultCollector.h>\r
+#include <cppunit/TestRunner.h>\r
+#include <cppunit/ui/text/TestRunner.h>\r
+\r
+// Includes for testcases\r
+#include "TestCase1.h"\r
+\r
+\r
+#ifdef _DEBUG\r
+#define new DEBUG_NEW\r
+#undef THIS_FILE\r
+static char THIS_FILE[] = __FILE__;\r
+#endif\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+// The one and only application object\r
+\r
+CWinApp theApp;\r
+\r
+using namespace std;\r
+\r
+int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])\r
+{\r
+       int nRetCode = 0;\r
+\r
+       // initialize MFC and print and error on failure\r
+       if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))\r
+       {\r
+               // TODO: change error code to suit your needs\r
+               cerr << _T("Fatal Error: MFC initialization failed") << endl;\r
+               nRetCode = 1;\r
+       }\r
+       else\r
+       {\r
+               /**\r
+                * This is the code running the tests.\r
+                * Tests are found automatically once they are created with\r
+                * CppUnit's macros, you don't need to run single tests here.\r
+                */\r
+               CPPUNIT_NS::TestResult controller;\r
+\r
+               // Add a listener that colllects test result\r
+               CPPUNIT_NS::TestResultCollector result;\r
+               controller.addListener( &result );\r
+\r
+               // Add a listener that print dots as test run.\r
+               CPPUNIT_NS::BriefTestProgressListener progress;\r
+               controller.addListener( &progress );\r
+\r
+               // Add the top suite to the test runner\r
+               CPPUNIT_NS::TestRunner runner;\r
+               runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );\r
+               runner.run( controller );\r
+\r
+               // Print test in a compiler compatible format.\r
+               CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );\r
+               outputter.write();\r
+       }\r
+\r
+       return nRetCode;\r
+}\r
+\r
+\r
diff --git a/Testing/CppUnit/StringDifferencing/StringDifferencing.dsp b/Testing/CppUnit/StringDifferencing/StringDifferencing.dsp
new file mode 100644 (file)
index 0000000..07f65ae
--- /dev/null
@@ -0,0 +1,148 @@
+# Microsoft Developer Studio Project File - Name="StringDifferencing" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Console Application" 0x0103\r
+\r
+CFG=StringDifferencing - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "StringDifferencing.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "StringDifferencing.mak" CFG="StringDifferencing - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "StringDifferencing - Win32 Release" (based on "Win32 (x86) Console Application")\r
+!MESSAGE "StringDifferencing - Win32 Debug" (based on "Win32 (x86) Console Application")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""\r
+# PROP Scc_LocalPath ""\r
+CPP=cl.exe\r
+RSC=rc.exe\r
+\r
+!IF  "$(CFG)" == "StringDifferencing - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 2\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 2\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Release"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c\r
+# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c\r
+# ADD BASE RSC /l 0x40b /d "NDEBUG" /d "_AFXDLL"\r
+# ADD RSC /l 0x40b /d "NDEBUG" /d "_AFXDLL"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
+\r
+!ELSEIF  "$(CFG)" == "StringDifferencing - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 2\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 2\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "Debug"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ    /c\r
+# ADD CPP /nologo /MDd /W3 /Gm- /GR /GX /ZI /Od /I "..\..\..\Externals\cppunit\include" /I "..\..\..\Src" /I "..\..\..\Src\Common" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_AFXDLL" /FD /GZ    /c\r
+# SUBTRACT CPP /YX /Yc /Yu\r
+# ADD BASE RSC /l 0x40b /d "_DEBUG" /d "_AFXDLL"\r
+# ADD RSC /l 0x40b /d "_DEBUG" /d "_AFXDLL"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunitd.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\Build\CppUnit"\r
+# SUBTRACT LINK32 /incremental:no\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "StringDifferencing - Win32 Release"\r
+# Name "StringDifferencing - Win32 Debug"\r
+# Begin Group "Source Files"\r
+\r
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+# Begin Source File\r
+\r
+SOURCE=.\StdAfx.cpp\r
+# ADD CPP /Yc"stdafx.h"\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\StringDifferencing.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\StringDifferencing.rc\r
+# End Source File\r
+# End Group\r
+# Begin Group "Header Files"\r
+\r
+# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
+# Begin Source File\r
+\r
+SOURCE=.\Resource.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\StdAfx.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\StringDifferencing.h\r
+# End Source File\r
+# End Group\r
+# Begin Group "Resource Files"\r
+\r
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+# End Group\r
+# Begin Group "Test Cases"\r
+\r
+# PROP Default_Filter ""\r
+# Begin Source File\r
+\r
+SOURCE=.\TestCase1.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\TestCase1.h\r
+# End Source File\r
+# End Group\r
+# Begin Group "Files to Test"\r
+\r
+# PROP Default_Filter ""\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\Src\stringdiffs.cpp\r
+# End Source File\r
+# End Group\r
+# Begin Source File\r
+\r
+SOURCE=.\ReadMe.txt\r
+# End Source File\r
+# End Target\r
+# End Project\r
diff --git a/Testing/CppUnit/StringDifferencing/StringDifferencing.h b/Testing/CppUnit/StringDifferencing/StringDifferencing.h
new file mode 100644 (file)
index 0000000..2357815
--- /dev/null
@@ -0,0 +1,12 @@
+\r
+#if !defined(AFX_STRINGDIFFERENCING_H__8A380B51_4087_460E_B2A5_55408D13BAA1__INCLUDED_)\r
+#define AFX_STRINGDIFFERENCING_H__8A380B51_4087_460E_B2A5_55408D13BAA1__INCLUDED_\r
+\r
+#if _MSC_VER > 1000\r
+#pragma once\r
+#endif // _MSC_VER > 1000\r
+\r
+#include "resource.h"\r
+\r
+\r
+#endif // !defined(AFX_STRINGDIFFERENCING_H__8A380B51_4087_460E_B2A5_55408D13BAA1__INCLUDED_)\r
diff --git a/Testing/CppUnit/StringDifferencing/StringDifferencing.rc b/Testing/CppUnit/StringDifferencing/StringDifferencing.rc
new file mode 100644 (file)
index 0000000..73120af
--- /dev/null
@@ -0,0 +1,70 @@
+//Microsoft Visual C++ generated resource script.\r
+//\r
+#include "resource.h"\r
+\r
+#define APSTUDIO_READONLY_SYMBOLS\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Generated from the TEXTINCLUDE 2 resource.\r
+//\r
+#include "afxres.h"\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+#undef APSTUDIO_READONLY_SYMBOLS\r
+\r
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r
+#ifdef _WIN32\r
+LANGUAGE 9, 1\r
+#pragma code_page(1252)\r
+#endif //_WIN32\r
+\r
+#ifdef APSTUDIO_INVOKED\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// TEXTINCLUDE\r
+//\r
+\r
+1 TEXTINCLUDE DISCARDABLE \r
+BEGIN\r
+    "resource.h\0"\r
+END\r
+\r
+2 TEXTINCLUDE DISCARDABLE \r
+BEGIN\r
+    "#include ""afxres.h""\r\n"\r
+    "\0"\r
+END\r
+\r
+3 TEXTINCLUDE DISCARDABLE \r
+BEGIN\r
+    "\r\n"\r
+    "\0"\r
+END\r
+\r
+#endif    // APSTUDIO_INVOKED\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// String Table\r
+//\r
+\r
+STRINGTABLE DISCARDABLE \r
+BEGIN\r
+    IDS_HELLO               "Hello from MFC!"\r
+END\r
+\r
+#endif\r
+/////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+\r
+#ifndef APSTUDIO_INVOKED\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Generated from the TEXTINCLUDE 3 resource.\r
+//\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+#endif    // not APSTUDIO_INVOKED\r
diff --git a/Testing/CppUnit/StringDifferencing/TestCase1.cpp b/Testing/CppUnit/StringDifferencing/TestCase1.cpp
new file mode 100644 (file)
index 0000000..8172aca
--- /dev/null
@@ -0,0 +1,177 @@
+\r
+#include <cppunit/config/SourcePrefix.h>\r
+#include "stdafx.h"\r
+\r
+#include "CompareOptions.h"\r
+#include "stringdiffs.h"\r
+\r
+#include "TestCase1.h"\r
+\r
+CPPUNIT_TEST_SUITE_REGISTRATION( TestCase1 );\r
+\r
+void TestCase1::setUp()\r
+{\r
+       // Add possible initializations here\r
+}\r
+\r
+void TestCase1::tearDown()\r
+{\r
+       // Add possible cleanups here\r
+}\r
+\r
+void TestCase1::Identical1()\r
+{\r
+       wdiffarray diffs;\r
+       CString string1(_T("Test"));\r
+       CString string2(_T("Test"));\r
+       int count = 0;\r
+\r
+       // Break type is whitespace or punctuation\r
+\r
+       // Check strings with different settings\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               true, WHITESPACE_COMPARE_ALL, 0, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 0);\r
+\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               false, WHITESPACE_COMPARE_ALL, 0, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 0);\r
+\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               true, WHITESPACE_IGNORE_CHANGE, 0, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 0);\r
+\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               true, WHITESPACE_IGNORE_ALL, 0, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 0);\r
+\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               true, WHITESPACE_COMPARE_ALL, 1, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 0);\r
+\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               true, WHITESPACE_COMPARE_ALL, 0, true,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 0);\r
+}\r
+\r
+void TestCase1::Identical2()\r
+{\r
+       wdiffarray diffs;\r
+       CString string1(_T("Test words"));\r
+       CString string2(_T("Test words"));\r
+       int count = 0;\r
+\r
+       // Break type is whitespace or punctuation\r
+\r
+       // Check strings with different settings\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               true, WHITESPACE_COMPARE_ALL, 0, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 0);\r
+\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               false, WHITESPACE_COMPARE_ALL, 0, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 0);\r
+\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               true, WHITESPACE_IGNORE_CHANGE, 0, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 0);\r
+\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               true, WHITESPACE_IGNORE_ALL, 0, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 0);\r
+\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               true, WHITESPACE_COMPARE_ALL, 1, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 0);\r
+\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               true, WHITESPACE_COMPARE_ALL, 0, true,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 0);\r
+}\r
+\r
+void TestCase1::Difference1()\r
+{\r
+       wdiffarray diffs;\r
+       CString string1(_T("Test"));\r
+       CString string2(_T("test"));\r
+       int count = 0;\r
+\r
+       // Break type is whitespace or punctuation\r
+\r
+       // Check strings with different settings\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               false, WHITESPACE_COMPARE_ALL, 0, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 0);\r
+       diffs.RemoveAll();\r
+\r
+       // Check strings with different settings\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               true, WHITESPACE_COMPARE_ALL, 0, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 1);\r
+       diffs.RemoveAll();\r
+\r
+       string1 = _T("tesT");\r
+       string2 = _T("test");\r
+       // Check strings with different settings\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               true, WHITESPACE_COMPARE_ALL, 0, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT_MESSAGE(_T("testT & test difference not found!"), count == 1);\r
+       diffs.RemoveAll();\r
+}\r
+\r
+void TestCase1::Difference2()\r
+{\r
+       wdiffarray diffs;\r
+       CString string1(_T("Test string"));\r
+       CString string2(_T("test strIng"));\r
+       int count = 0;\r
+\r
+       // Break type is whitespace or punctuation\r
+\r
+       // Check strings with different settings\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               false, WHITESPACE_COMPARE_ALL, 0, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 0);\r
+       diffs.RemoveAll();\r
+\r
+       // This fails? Why?\r
+       // Shouldn't it it find two differences? But it founds only one?\r
+       sd_ComputeWordDiffs(string1, string2,\r
+               true, WHITESPACE_COMPARE_ALL, 0, false,\r
+               &diffs);\r
+       count = diffs.GetSize();\r
+       CPPUNIT_ASSERT(count == 2);\r
+       diffs.RemoveAll();\r
+}\r
diff --git a/Testing/CppUnit/StringDifferencing/TestCase1.h b/Testing/CppUnit/StringDifferencing/TestCase1.h
new file mode 100644 (file)
index 0000000..921f933
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef _TESTCASE1_H_\r
+#define _TESTCASE1_H_\r
+\r
+#include <cppunit/extensions/HelperMacros.h>\r
+\r
+class TestCase1 : public CPPUNIT_NS::TestFixture\r
+{\r
+  CPPUNIT_TEST_SUITE( TestCase1 );\r
+  CPPUNIT_TEST( Identical1 );\r
+  CPPUNIT_TEST( Identical2 );\r
+  CPPUNIT_TEST( Difference1 );\r
+  CPPUNIT_TEST( Difference2 );\r
+  CPPUNIT_TEST_SUITE_END();\r
+\r
+protected:\r
+       \r
+\r
+public:\r
+  void setUp();\r
+  void tearDown();\r
+\r
+protected:\r
+       void Identical1();\r
+       void Identical2();\r
+\r
+       void Difference1();\r
+       void Difference2();\r
+};\r
+\r
+\r
+#endif\r