[Winmerge-svn] SF.net SVN: winmerge:[7538] trunk/Testing/GoogleTest
Windows visual diff and merge for files and directories
Brought to you by:
christianlist,
grimmdp
From: <sdo...@us...> - 2011-06-05 11:25:14
|
Revision: 7538 http://winmerge.svn.sourceforge.net/winmerge/?rev=7538&view=rev Author: sdottaka Date: 2011-06-05 11:25:07 +0000 (Sun, 05 Jun 2011) Log Message: ----------- Add Google Test unit test project for ProjectFile Added Paths: ----------- trunk/Testing/GoogleTest/ProjectFile/ trunk/Testing/GoogleTest/ProjectFile/ProjectFile.vcproj trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_LeftAndRight.cpp trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_LeftAndRightNonRecursive.cpp trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_LeftAndRightRecursive.cpp trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_PathsAndFilter.cpp trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_SimpleLeft.cpp trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_SimpleRight.cpp trunk/Testing/GoogleTest/ProjectFile/TestData/ trunk/Testing/GoogleTest/ProjectFile/TestData/LeftAndRight.WinMerge trunk/Testing/GoogleTest/ProjectFile/TestData/LeftAndRightNonRecursive.WinMerge trunk/Testing/GoogleTest/ProjectFile/TestData/LeftAndRightRecursive.WinMerge trunk/Testing/GoogleTest/ProjectFile/TestData/PathsAndFilter.WinMerge trunk/Testing/GoogleTest/ProjectFile/TestData/SimpleLeft.WinMerge trunk/Testing/GoogleTest/ProjectFile/TestData/SimpleRight.WinMerge trunk/Testing/GoogleTest/ProjectFile/misc.cpp trunk/Testing/GoogleTest/ProjectFile/test_main.cpp Property changes on: trunk/Testing/GoogleTest/ProjectFile ___________________________________________________________________ Added: bugtraq:url + http://sourceforge.net/support/tracker.php?aid=%BUGID% Added: bugtraq:logregex + (\d{6,}) Added: trunk/Testing/GoogleTest/ProjectFile/ProjectFile.vcproj =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/ProjectFile.vcproj (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/ProjectFile.vcproj 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,275 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="ProjectFile" + ProjectGUID="{A1C78585-1654-40DB-A425-91B3DE535972}" + RootNamespace="ProjectFile" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="Debug" + IntermediateDirectory="Debug" + ConfigurationType="1" + UseOfMFC="2" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories=".;..\..\..\Src;..\..\..\Src\Common;..\..\..\Externals\scew;..\..\..\Externals\expat\lib" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="gtestd.lib scew_d.lib libexpat.lib" + OutputFile="$(OutDir)/ProjectFile.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="..;..\..\..\Build\scew;..\..\..\Build\expat" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/ProjectFile.pdb" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="Release" + IntermediateDirectory="Release" + ConfigurationType="1" + UseOfMFC="2" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories=".;..\..\..\Src;..\..\..\Src\Common;..\..\..\Externals\scew;..\..\..\Externals\expat\lib" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="gtest.lib" + OutputFile="$(OutDir)/ProjectFile.exe" + LinkIncremental="1" + AdditionalLibraryDirectories="..;..\..\..\Build\scew;..\..\..\Build\expat" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\misc.cpp" + > + </File> + <File + RelativePath="..\..\..\Src\ProjectFile.cpp" + > + </File> + <File + RelativePath=".\ProjectFile_test_LeftAndRight.cpp" + > + </File> + <File + RelativePath=".\ProjectFile_test_LeftAndRightNonRecursive.cpp" + > + </File> + <File + RelativePath=".\ProjectFile_test_LeftAndRightRecursive.cpp" + > + </File> + <File + RelativePath=".\ProjectFile_test_PathsAndFilter.cpp" + > + </File> + <File + RelativePath=".\ProjectFile_test_SimpleLeft.cpp" + > + </File> + <File + RelativePath=".\ProjectFile_test_SimpleRight.cpp" + > + </File> + <File + RelativePath=".\test_main.cpp" + > + </File> + <File + RelativePath="..\..\..\Src\Common\Ucs2Utf8.cpp" + > + </File> + <File + RelativePath="..\..\..\Src\Common\unicoder.cpp" + > + </File> + <File + RelativePath="..\..\..\Src\Common\UnicodeString.cpp" + > + </File> + <File + RelativePath="..\..\..\Src\Common\Utf8FileDetect.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath="..\..\..\Src\ProjectFile.h" + > + </File> + <File + RelativePath="..\..\..\Src\Common\Ucs2Utf8.h" + > + </File> + <File + RelativePath="..\..\..\Src\Common\unicoder.h" + > + </File> + <File + RelativePath="..\..\..\Src\Common\UnicodeString.h" + > + </File> + <File + RelativePath="..\..\..\Src\Common\Utf8FileDetect.h" + > + </File> + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> Added: trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_LeftAndRight.cpp =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_LeftAndRight.cpp (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_LeftAndRight.cpp 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,153 @@ +/** + * @file ProjectFile_test_PathsAndFilter.cpp + * + * @brief Implementation for PathsAndFilter testcase. + */ + +#include <gtest/gtest.h> +#include <windows.h> +#include <tchar.h> + +#include "UnicodeString.h" +#include "ProjectFile.h" + +namespace +{ + /** @brief Projectfile to load. */ + static const TCHAR FileName[] = _T("TestData\\PathsAndFilter.WinMerge"); + /** @brief Left path we should get from file. */ + static const TCHAR LeftPath[] = _T("C:\\Temp\\Left"); + /** @brief Right path we should get from file. */ + static const TCHAR RightPath[] = _T("C:\\Temp\\Right"); + /** @brief Filter we should get from file. */ + static const TCHAR Filter[] = _T("Filter Name"); + + // The fixture for testing paths functions. + class ProjectFilePathsAndFilterTest : public testing::Test + { + protected: + // You can remove any or all of the following functions if its body + // is empty. + + ProjectFilePathsAndFilterTest() + { + // You can do set-up work for each test here. + } + + virtual ~ProjectFilePathsAndFilterTest() + { + // You can do clean-up work that doesn't throw exceptions here. + } + + // If the constructor and destructor are not enough for setting up + // and cleaning up each test, you can define the following methods: + + virtual void SetUp() + { + // Code here will be called immediately after the constructor (right + // before each test). + m_pProjectFile = new ProjectFile; + + String sError; + BOOL success = m_pProjectFile->Read(FileName, &sError); + } + + virtual void TearDown() + { + // Code here will be called immediately after each test (right + // before the destructor). + delete m_pProjectFile; + } + + // Objects declared here can be used by all tests in the test case for ProjectFile. + ProjectFile *m_pProjectFile; + }; + + /** + * @brief Load the projectfile. + */ + TEST_F(ProjectFilePathsAndFilterTest, Load) + { + String sError; + + // setUp already created the project file for us, but this + // test is for testing creation and loading.. + if (m_pProjectFile) + delete m_pProjectFile; + m_pProjectFile = new ProjectFile; + EXPECT_TRUE(m_pProjectFile != NULL); + + BOOL success = m_pProjectFile->Read(FileName, &sError); + + // Must succeed + EXPECT_EQ(TRUE, success); + EXPECT_TRUE(sError.empty()); + } + + /** + * @brief Read left path different ways. + */ + TEST_F(ProjectFilePathsAndFilterTest, GetLeftPath) + { + // Has left path + BOOL bIsLeft = m_pProjectFile->HasLeft(); + EXPECT_EQ(TRUE, bIsLeft); + + // Get left path without read-only info + String left = m_pProjectFile->GetLeft(); + EXPECT_TRUE(left.compare(LeftPath) == 0); + + // Get left path with read-only info + BOOL bReadOnly; + left = m_pProjectFile->GetLeft(&bReadOnly); + EXPECT_TRUE(left.compare(LeftPath) == 0); + EXPECT_EQ(FALSE, bReadOnly); + } + + /** + * @brief Make sure right path is not get. + */ + TEST_F(ProjectFilePathsAndFilterTest, GetRightPath) + { + // Has have right path + BOOL bIsRight = m_pProjectFile->HasRight(); + EXPECT_EQ(TRUE, bIsRight); + + // Get right path without read-only info + String right = m_pProjectFile->GetRight(); + EXPECT_TRUE(right.compare(RightPath) == 0); + + // Get right path with read-only info + BOOL bReadOnly; + right = m_pProjectFile->GetRight(&bReadOnly); + EXPECT_TRUE(right.compare(RightPath) == 0); + EXPECT_EQ(FALSE, bReadOnly); + } + + /** + * @brief Make sure subfolder inclusion is not get. + */ + TEST_F(ProjectFilePathsAndFilterTest, GetSubfolders) + { + // We don't have a subfolders + BOOL bHasSubfolders = m_pProjectFile->HasSubfolders(); + EXPECT_EQ(FALSE, bHasSubfolders); + + // Returns -1 if not set + int subfolders = m_pProjectFile->GetSubfolders(); + EXPECT_EQ(-1, subfolders); + } + + /** + * @brief Read filter. + */ + TEST_F(ProjectFilePathsAndFilterTest, GetFilter) + { + // Now we have a filter + BOOL bHasFilter = m_pProjectFile->HasFilter(); + EXPECT_EQ(TRUE, bHasFilter); + + String filter = m_pProjectFile->GetFilter(); + EXPECT_TRUE(filter.compare(Filter) == 0); + } +} Added: trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_LeftAndRightNonRecursive.cpp =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_LeftAndRightNonRecursive.cpp (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_LeftAndRightNonRecursive.cpp 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,151 @@ +/** + * @file ProjectFile_test_LeftAndRightNonRecursive.cpp + * + * @brief Implementation for LeftAndRightNonRecursive testcase. + */ + +#include <gtest/gtest.h> +#include <windows.h> +#include <tchar.h> + +#include "UnicodeString.h" +#include "ProjectFile.h" + +namespace +{ + /** @brief Projectfile to load. */ + static const TCHAR FileName[] = _T("TestData\\LeftAndRightNonRecursive.WinMerge"); + /** @brief Left path we should get from file. */ + static const TCHAR LeftPath[] = _T("C:\\Temp\\Left"); + /** @brief Right path we should get from file. */ + static const TCHAR RightPath[] = _T("C:\\Temp\\Right"); + + // The fixture for testing paths functions. + class ProjectFileLeftAndRightNonRecursiveTest : public testing::Test + { + protected: + // You can remove any or all of the following functions if its body + // is empty. + + ProjectFileLeftAndRightNonRecursiveTest() + { + // You can do set-up work for each test here. + } + + virtual ~ProjectFileLeftAndRightNonRecursiveTest() + { + // You can do clean-up work that doesn't throw exceptions here. + } + + // If the constructor and destructor are not enough for setting up + // and cleaning up each test, you can define the following methods: + + virtual void SetUp() + { + // Code here will be called immediately after the constructor (right + // before each test). + m_pProjectFile = new ProjectFile; + + String sError; + BOOL success = m_pProjectFile->Read(FileName, &sError); + } + + virtual void TearDown() + { + // Code here will be called immediately after each test (right + // before the destructor). + delete m_pProjectFile; + } + + // Objects declared here can be used by all tests in the test case for ProjectFile. + ProjectFile *m_pProjectFile; + }; + + /** + * @brief Load the projectfile. + */ + TEST_F(ProjectFileLeftAndRightNonRecursiveTest, Load) + { + String sError; + + // setUp already created the project file for us, but this + // test is for testing creation and loading.. + if (m_pProjectFile) + delete m_pProjectFile; + m_pProjectFile = new ProjectFile; + EXPECT_TRUE(m_pProjectFile != NULL); + + BOOL success = m_pProjectFile->Read(FileName, &sError); + + // Must succeed + EXPECT_EQ(TRUE, success); + EXPECT_TRUE(sError.empty()); + } + + /** + * @brief Read left path different ways. + */ + TEST_F(ProjectFileLeftAndRightNonRecursiveTest, GetLeftPath) + { + // Has left path + BOOL bIsLeft = m_pProjectFile->HasLeft(); + EXPECT_EQ(TRUE, bIsLeft); + + // Get left path without read-only info + String left = m_pProjectFile->GetLeft(); + EXPECT_TRUE(left.compare(LeftPath) == 0); + + // Get left path with read-only info + BOOL bReadOnly; + left = m_pProjectFile->GetLeft(&bReadOnly); + EXPECT_TRUE(left.compare(LeftPath) == 0); + EXPECT_EQ(FALSE, bReadOnly); + } + + /** + * @brief Make sure right path is not get. + */ + TEST_F(ProjectFileLeftAndRightNonRecursiveTest, GetRightPath) + { + // Has have right path + BOOL bIsRight = m_pProjectFile->HasRight(); + EXPECT_EQ(TRUE, bIsRight); + + // Get right path without read-only info + String right = m_pProjectFile->GetRight(); + EXPECT_TRUE(right.compare(RightPath) == 0); + + // Get right path with read-only info + BOOL bReadOnly; + right = m_pProjectFile->GetRight(&bReadOnly); + EXPECT_TRUE(right.compare(RightPath) == 0); + EXPECT_EQ(FALSE, bReadOnly); + } + + /** + * @brief Make sure subfolder inclusion is get and disabled. + */ + TEST_F(ProjectFileLeftAndRightNonRecursiveTest, GetSubfolders) + { + // Now we have a subfolders + BOOL bHasSubfolders = m_pProjectFile->HasSubfolders(); + EXPECT_EQ(TRUE, bHasSubfolders); + + // But the setting says we don't want recursive compare + int subfolders = m_pProjectFile->GetSubfolders(); + EXPECT_EQ(0, subfolders); + } + + /** + * @brief Make sure filter is not get. + */ + TEST_F(ProjectFileLeftAndRightNonRecursiveTest, GetFilter) + { + // We don't have a filter + BOOL bHasFilter = m_pProjectFile->HasFilter(); + EXPECT_EQ(FALSE, bHasFilter); + + String filter = m_pProjectFile->GetFilter(); + EXPECT_TRUE(filter.empty()); + } +} Added: trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_LeftAndRightRecursive.cpp =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_LeftAndRightRecursive.cpp (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_LeftAndRightRecursive.cpp 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,150 @@ +/** + * @file ProjectFile_test_LeftAndRightRecursive.cpp + * + * @brief Implementation for LeftAndRightRecursive testcase. + */ + +#include <gtest/gtest.h> +#include <windows.h> +#include <tchar.h> + +#include "UnicodeString.h" +#include "ProjectFile.h" + +namespace +{ + /** @brief Projectfile to load. */ + static const TCHAR FileName[] = _T("TestData\\LeftAndRightRecursive.WinMerge"); + /** @brief Left path we should get from file. */ + static const TCHAR LeftPath[] = _T("C:\\Temp\\Left"); + /** @brief Right path we should get from file. */ + static const TCHAR RightPath[] = _T("C:\\Temp\\Right"); + + // The fixture for testing paths functions. + class ProjectFileLeftAndRightRecursiveTest : public testing::Test + { + protected: + // You can remove any or all of the following functions if its body + // is empty. + + ProjectFileLeftAndRightRecursiveTest() + { + // You can do set-up work for each test here. + } + + virtual ~ProjectFileLeftAndRightRecursiveTest() + { + // You can do clean-up work that doesn't throw exceptions here. + } + + // If the constructor and destructor are not enough for setting up + // and cleaning up each test, you can define the following methods: + + virtual void SetUp() + { + // Code here will be called immediately after the constructor (right + // before each test). + m_pProjectFile = new ProjectFile; + + String sError; + BOOL success = m_pProjectFile->Read(FileName, &sError); + } + + virtual void TearDown() + { + // Code here will be called immediately after each test (right + // before the destructor). + delete m_pProjectFile; + } + + // Objects declared here can be used by all tests in the test case for ProjectFile. + ProjectFile *m_pProjectFile; + }; + + /** + * @brief Load the projectfile. + */ + TEST_F(ProjectFileLeftAndRightRecursiveTest, Load) + { + String sError; + + // setUp already created the project file for us, but this + // test is for testing creation and loading.. + if (m_pProjectFile) + delete m_pProjectFile; + m_pProjectFile = new ProjectFile; + EXPECT_TRUE(m_pProjectFile != NULL); + + BOOL success = m_pProjectFile->Read(FileName, &sError); + + // Must succeed + EXPECT_EQ(TRUE, success); + EXPECT_TRUE(sError.empty()); + } + + /** + * @brief Read left path different ways. + */ + TEST_F(ProjectFileLeftAndRightRecursiveTest, GetLeftPath) + { + // Has left path + BOOL bIsLeft = m_pProjectFile->HasLeft(); + EXPECT_EQ(TRUE, bIsLeft); + + // Get left path without read-only info + String left = m_pProjectFile->GetLeft(); + EXPECT_TRUE(left.compare(LeftPath) == 0); + + // Get left path with read-only info + BOOL bReadOnly; + left = m_pProjectFile->GetLeft(&bReadOnly); + EXPECT_TRUE(left.compare(LeftPath) == 0); + EXPECT_EQ(FALSE, bReadOnly); + } + + /** + * @brief Make sure right path is not get. + */ + TEST_F(ProjectFileLeftAndRightRecursiveTest, GetRightPath) + { + // Has have right path + BOOL bIsRight = m_pProjectFile->HasRight(); + EXPECT_EQ(TRUE, bIsRight); + + // Get right path without read-only info + String right = m_pProjectFile->GetRight(); + EXPECT_TRUE(right.compare(RightPath) == 0); + + // Get right path with read-only info + BOOL bReadOnly; + right = m_pProjectFile->GetRight(&bReadOnly); + EXPECT_TRUE(right.compare(RightPath) == 0); + EXPECT_EQ(FALSE, bReadOnly); + } + + /** + * @brief Make sure subfolder inclusion is get and enabled. + */ + TEST_F(ProjectFileLeftAndRightRecursiveTest, GetSubfolders) + { + // Now we have a subfolders + BOOL bHasSubfolders = m_pProjectFile->HasSubfolders(); + EXPECT_EQ(TRUE, bHasSubfolders); + + int subfolders = m_pProjectFile->GetSubfolders(); + EXPECT_EQ(1, subfolders); + } + + /** + * @brief Make sure filter is not get. + */ + TEST_F(ProjectFileLeftAndRightRecursiveTest, GetFilter) + { + // We don't have a filter + BOOL bHasFilter = m_pProjectFile->HasFilter(); + EXPECT_EQ(FALSE, bHasFilter); + + String filter = m_pProjectFile->GetFilter(); + EXPECT_TRUE(filter.empty()); + } +} Added: trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_PathsAndFilter.cpp =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_PathsAndFilter.cpp (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_PathsAndFilter.cpp 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,151 @@ +/** + * @file ProjectFile_test_LeftAndRight.cpp + * + * @brief Implementation for LeftAndRight testcase. + */ + +#include <gtest/gtest.h> +#include <windows.h> +#include <tchar.h> + +#include "UnicodeString.h" +#include "ProjectFile.h" + +namespace +{ + /** @brief Projectfile to load. */ + static const TCHAR FileName[] = _T("TestData\\LeftAndRight.WinMerge"); + /** @brief Left path we should get from file. */ + static const TCHAR LeftPath[] = _T("C:\\Temp\\Left"); + /** @brief Right path we should get from file. */ + static const TCHAR RightPath[] = _T("C:\\Temp\\Right"); + + // The fixture for testing paths functions. + class ProjectFileLeftAndRightTest : public testing::Test + { + protected: + // You can remove any or all of the following functions if its body + // is empty. + + ProjectFileLeftAndRightTest() + { + // You can do set-up work for each test here. + } + + virtual ~ProjectFileLeftAndRightTest() + { + // You can do clean-up work that doesn't throw exceptions here. + } + + // If the constructor and destructor are not enough for setting up + // and cleaning up each test, you can define the following methods: + + virtual void SetUp() + { + // Code here will be called immediately after the constructor (right + // before each test). + m_pProjectFile = new ProjectFile; + + String sError; + BOOL success = m_pProjectFile->Read(FileName, &sError); + } + + virtual void TearDown() + { + // Code here will be called immediately after each test (right + // before the destructor). + delete m_pProjectFile; + } + + // Objects declared here can be used by all tests in the test case for ProjectFile. + ProjectFile *m_pProjectFile; + }; + + /** + * @brief Load the projectfile. + */ + TEST_F(ProjectFileLeftAndRightTest, Load) + { + String sError; + + // setUp already created the project file for us, but this + // test is for testing creation and loading.. + if (m_pProjectFile) + delete m_pProjectFile; + m_pProjectFile = new ProjectFile; + EXPECT_TRUE(m_pProjectFile != NULL); + + BOOL success = m_pProjectFile->Read(FileName, &sError); + + // Must succeed + EXPECT_EQ(TRUE, success); + EXPECT_TRUE(sError.empty()); + } + + /** + * @brief Read left path different ways. + */ + TEST_F(ProjectFileLeftAndRightTest, GetLeftPath) + { + // Has left path + BOOL bIsLeft = m_pProjectFile->HasLeft(); + EXPECT_EQ(TRUE, bIsLeft); + + // Get left path without read-only info + String left = m_pProjectFile->GetLeft(); + EXPECT_TRUE(left.compare(LeftPath) == 0); + + // Get left path with read-only info + BOOL bReadOnly; + left = m_pProjectFile->GetLeft(&bReadOnly); + EXPECT_TRUE(left.compare(LeftPath) == 0); + EXPECT_EQ(FALSE, bReadOnly); + } + + /** + * @brief Make sure right path is not get. + */ + TEST_F(ProjectFileLeftAndRightTest, GetRightPath) + { + // Has have right path + BOOL bIsRight = m_pProjectFile->HasRight(); + EXPECT_EQ(TRUE, bIsRight); + + // Get right path without read-only info + String right = m_pProjectFile->GetRight(); + EXPECT_TRUE(right.compare(RightPath) == 0); + + // Get right path with read-only info + BOOL bReadOnly; + right = m_pProjectFile->GetRight(&bReadOnly); + EXPECT_TRUE(right.compare(RightPath) == 0); + EXPECT_EQ(FALSE, bReadOnly); + } + + /** + * @brief Make sure subfolder inclusion is not get. + */ + TEST_F(ProjectFileLeftAndRightTest, GetSubfolders) + { + // We don't have a subfolders + BOOL bHasSubfolders = m_pProjectFile->HasSubfolders(); + EXPECT_EQ(FALSE, bHasSubfolders); + + // Returns -1 if not set + int subfolders = m_pProjectFile->GetSubfolders(); + EXPECT_EQ(-1, subfolders); + } + + /** + * @brief Make sure filter is not get. + */ + TEST_F(ProjectFileLeftAndRightTest, GetFilter) + { + // We don't have a filter + BOOL bHasFilter = m_pProjectFile->HasFilter(); + EXPECT_EQ(FALSE, bHasFilter); + + String filter = m_pProjectFile->GetFilter(); + EXPECT_TRUE(filter.empty()); + } +} Added: trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_SimpleLeft.cpp =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_SimpleLeft.cpp (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_SimpleLeft.cpp 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,149 @@ +/** + * @file ProjectFile_test_SimpleLeft.cpp + * + * @brief Implementation for SimpleLeft testcase. + */ + +#include <gtest/gtest.h> +#include <windows.h> +#include <tchar.h> + +#include "UnicodeString.h" +#include "ProjectFile.h" + +namespace +{ + /** @brief Projectfile to load. */ + static const TCHAR FileName[] = _T("TestData\\SimpleLeft.WinMerge"); + /** @brief Left path we should get from file. */ + static const TCHAR LeftPath[] = _T("C:\\Temp\\Left"); + + // The fixture for testing paths functions. + class ProjectFileSimpleLeftTest : public testing::Test + { + protected: + // You can remove any or all of the following functions if its body + // is empty. + + ProjectFileSimpleLeftTest() + { + // You can do set-up work for each test here. + } + + virtual ~ProjectFileSimpleLeftTest() + { + // You can do clean-up work that doesn't throw exceptions here. + } + + // If the constructor and destructor are not enough for setting up + // and cleaning up each test, you can define the following methods: + + virtual void SetUp() + { + // Code here will be called immediately after the constructor (right + // before each test). + m_pProjectFile = new ProjectFile; + + String sError; + BOOL success = m_pProjectFile->Read(FileName, &sError); + } + + virtual void TearDown() + { + // Code here will be called immediately after each test (right + // before the destructor). + delete m_pProjectFile; + } + + // Objects declared here can be used by all tests in the test case for ProjectFile. + ProjectFile *m_pProjectFile; + }; + + /** + * @brief Load the projectfile. + */ + TEST_F(ProjectFileSimpleLeftTest, Load) + { + String sError; + + // setUp already created the project file for us, but this + // test is for testing creation and loading.. + if (m_pProjectFile) + delete m_pProjectFile; + m_pProjectFile = new ProjectFile; + EXPECT_TRUE(m_pProjectFile != NULL); + + BOOL success = m_pProjectFile->Read(FileName, &sError); + + // Must succeed + EXPECT_EQ(TRUE, success); + EXPECT_TRUE(sError.empty()); + } + + /** + * @brief Read left path different ways. + */ + TEST_F(ProjectFileSimpleLeftTest, GetLeftPath) + { + // Has left path (only) + BOOL bIsLeft = m_pProjectFile->HasLeft(); + EXPECT_EQ(TRUE, bIsLeft); + + // Get left path without read-only info + String left = m_pProjectFile->GetLeft(); + EXPECT_TRUE(left.compare(LeftPath) == 0); + + // Get left path with read-only info + BOOL bReadOnly; + left = m_pProjectFile->GetLeft(&bReadOnly); + EXPECT_TRUE(left.compare(LeftPath) == 0); + EXPECT_EQ(FALSE, bReadOnly); + } + + /** + * @brief Make sure right path is not get. + */ + TEST_F(ProjectFileSimpleLeftTest, GetRightPath) + { + // We don't have right path + BOOL bIsRight = m_pProjectFile->HasRight(); + EXPECT_EQ(FALSE, bIsRight); + + // Get right path without read-only info + String right = m_pProjectFile->GetRight(); + EXPECT_TRUE(right.empty()); + + // Get right path with read-only info + BOOL bReadOnly; + right = m_pProjectFile->GetRight(&bReadOnly); + EXPECT_TRUE(right.empty()); + EXPECT_EQ(FALSE, bReadOnly); + } + + /** + * @brief Make sure subfolder inclusion is not get. + */ + TEST_F(ProjectFileSimpleLeftTest, GetSubfolders) + { + // We don't have a subfolders + BOOL bHasSubfolders = m_pProjectFile->HasSubfolders(); + EXPECT_EQ(FALSE, bHasSubfolders); + + // Returns -1 if not set + int subfolders = m_pProjectFile->GetSubfolders(); + EXPECT_EQ(-1, subfolders); + } + + /** + * @brief Make sure filter is not get. + */ + TEST_F(ProjectFileSimpleLeftTest, GetFilter) + { + // We don't have a filter + BOOL bHasFilter = m_pProjectFile->HasFilter(); + EXPECT_EQ(FALSE, bHasFilter); + + String filter = m_pProjectFile->GetFilter(); + EXPECT_TRUE(filter.empty()); + } +} Added: trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_SimpleRight.cpp =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_SimpleRight.cpp (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/ProjectFile_test_SimpleRight.cpp 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,149 @@ +/** + * @file ProjectFile_test_SimpleRight.cpp + * + * @brief Implementation for SimpleRight testcase. + */ + +#include <gtest/gtest.h> +#include <windows.h> +#include <tchar.h> + +#include "UnicodeString.h" +#include "ProjectFile.h" + +namespace +{ + /** @brief Projectfile to load. */ + static const TCHAR FileName[] = _T("TestData\\SimpleRight.WinMerge"); + /** @brief Right path we should get from file. */ + static const TCHAR RightPath[] = _T("C:\\Temp\\Right"); + + // The fixture for testing paths functions. + class ProjectFileSimpleRightTest : public testing::Test + { + protected: + // You can remove any or all of the following functions if its body + // is empty. + + ProjectFileSimpleRightTest() + { + // You can do set-up work for each test here. + } + + virtual ~ProjectFileSimpleRightTest() + { + // You can do clean-up work that doesn't throw exceptions here. + } + + // If the constructor and destructor are not enough for setting up + // and cleaning up each test, you can define the following methods: + + virtual void SetUp() + { + // Code here will be called immediately after the constructor (right + // before each test). + m_pProjectFile = new ProjectFile; + + String sError; + BOOL success = m_pProjectFile->Read(FileName, &sError); + } + + virtual void TearDown() + { + // Code here will be called immediately after each test (right + // before the destructor). + delete m_pProjectFile; + } + + // Objects declared here can be used by all tests in the test case for ProjectFile. + ProjectFile *m_pProjectFile; + }; + + /** + * @brief Load the projectfile. + */ + TEST_F(ProjectFileSimpleRightTest, Load) + { + String sError; + + // setUp already created the project file for us, but this + // test is for testing creation and loading.. + if (m_pProjectFile) + delete m_pProjectFile; + m_pProjectFile = new ProjectFile; + EXPECT_TRUE(m_pProjectFile != NULL); + + BOOL success = m_pProjectFile->Read(FileName, &sError); + + // Must succeed + EXPECT_EQ(TRUE, success); + EXPECT_TRUE(sError.empty()); + } + + /** + * @brief Read right path different ways. + */ + TEST_F(ProjectFileSimpleRightTest, GetRightPath) + { + // Has right path (only) + BOOL bIsRight = m_pProjectFile->HasRight(); + EXPECT_EQ(TRUE, bIsRight); + + // Get right path without read-only info + String right = m_pProjectFile->GetRight(); + EXPECT_TRUE(right.compare(RightPath) == 0); + + // Get right path with read-only info + BOOL bReadOnly; + right = m_pProjectFile->GetRight(&bReadOnly); + EXPECT_TRUE(right.compare(RightPath) == 0); + EXPECT_EQ(FALSE, bReadOnly); + } + + /** + * @brief Make sure left path is not get. + */ + TEST_F(ProjectFileSimpleRightTest, GetLeftPath) + { + // We don't have left path + BOOL bIsLeft = m_pProjectFile->HasLeft(); + EXPECT_EQ(FALSE, bIsLeft); + + // Get left path without read-only info + String left = m_pProjectFile->GetLeft(); + EXPECT_TRUE(left.empty()); + + // Get left path with read-only info + BOOL bReadOnly; + left = m_pProjectFile->GetLeft(&bReadOnly); + EXPECT_TRUE(left.empty()); + EXPECT_EQ(FALSE, bReadOnly); + } + + /** + * @brief Make sure subfolder inclusion is not get. + */ + TEST_F(ProjectFileSimpleRightTest, GetSubfolders) + { + // We don't have a subfolders + BOOL bHasSubfolders = m_pProjectFile->HasSubfolders(); + EXPECT_EQ(FALSE, bHasSubfolders); + + // Returns -1 if not set + int subfolders = m_pProjectFile->GetSubfolders(); + EXPECT_EQ(-1, subfolders); + } + + /** + * @brief Make sure filter is not get. + */ + TEST_F(ProjectFileSimpleRightTest, GetFilter) + { + // We don't have a filter + BOOL bHasFilter = m_pProjectFile->HasFilter(); + EXPECT_EQ(FALSE, bHasFilter); + + String filter = m_pProjectFile->GetFilter(); + EXPECT_TRUE(filter.empty()); + } +} Property changes on: trunk/Testing/GoogleTest/ProjectFile/TestData ___________________________________________________________________ Added: bugtraq:url + http://sourceforge.net/support/tracker.php?aid=%BUGID% Added: bugtraq:logregex + (\d{6,}) Added: trunk/Testing/GoogleTest/ProjectFile/TestData/LeftAndRight.WinMerge =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/TestData/LeftAndRight.WinMerge (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/TestData/LeftAndRight.WinMerge 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='UTF-8'?> +<project> + <paths> + <left>C:\Temp\Left</left> + <right>C:\Temp\Right</right> + </paths> +</project> Added: trunk/Testing/GoogleTest/ProjectFile/TestData/LeftAndRightNonRecursive.WinMerge =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/TestData/LeftAndRightNonRecursive.WinMerge (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/TestData/LeftAndRightNonRecursive.WinMerge 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,8 @@ +<?xml version='1.0' encoding='UTF-8'?> +<project> + <paths> + <left>C:\Temp\Left</left> + <right>C:\Temp\Right</right> + <subfolders>0</subfolders> + </paths> +</project> Added: trunk/Testing/GoogleTest/ProjectFile/TestData/LeftAndRightRecursive.WinMerge =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/TestData/LeftAndRightRecursive.WinMerge (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/TestData/LeftAndRightRecursive.WinMerge 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,8 @@ +<?xml version='1.0' encoding='UTF-8'?> +<project> + <paths> + <left>C:\Temp\Left</left> + <right>C:\Temp\Right</right> + <subfolders>1</subfolders> + </paths> +</project> Added: trunk/Testing/GoogleTest/ProjectFile/TestData/PathsAndFilter.WinMerge =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/TestData/PathsAndFilter.WinMerge (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/TestData/PathsAndFilter.WinMerge 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,8 @@ +<?xml version='1.0' encoding='UTF-8'?> +<project> + <paths> + <left>C:\Temp\Left</left> + <right>C:\Temp\Right</right> + <filter>Filter Name</filter> + </paths> +</project> Added: trunk/Testing/GoogleTest/ProjectFile/TestData/SimpleLeft.WinMerge =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/TestData/SimpleLeft.WinMerge (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/TestData/SimpleLeft.WinMerge 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,6 @@ +<?xml version='1.0' encoding='UTF-8'?> +<project> + <paths> + <left>C:\Temp\Left</left> + </paths> +</project> Added: trunk/Testing/GoogleTest/ProjectFile/TestData/SimpleRight.WinMerge =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/TestData/SimpleRight.WinMerge (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/TestData/SimpleRight.WinMerge 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,6 @@ +<?xml version='1.0' encoding='UTF-8'?> +<project> + <paths> + <right>C:\Temp\Right</right> + </paths> +</project> Added: trunk/Testing/GoogleTest/ProjectFile/misc.cpp =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/misc.cpp (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/misc.cpp 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,44 @@ +#include <windows.h> +#include <tchar.h> +#include "UnicodeString.h" + +/* codepage.cpp */ +int getDefaultCodepage() +{ + return 0; +} + + +/* StdAfx.cpp */ +String LoadResString(UINT id) +{ + TCHAR buf[256]; + LoadString(NULL, id, buf, sizeof(buf)); + return String(buf); +} + +/* StdAfx.cpp */ +String GetSysError(int nerr) +{ + LPVOID lpMsgBuf; + String str = _T("?"); + if (FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + nerr, + 0, // Default language + (LPTSTR) &lpMsgBuf, + 0, + NULL + )) + { + str = (LPCTSTR)lpMsgBuf; + } + // Free the buffer. + LocalFree( lpMsgBuf ); + return str; +} + + Added: trunk/Testing/GoogleTest/ProjectFile/test_main.cpp =================================================================== --- trunk/Testing/GoogleTest/ProjectFile/test_main.cpp (rev 0) +++ trunk/Testing/GoogleTest/ProjectFile/test_main.cpp 2011-06-05 11:25:07 UTC (rev 7538) @@ -0,0 +1,8 @@ +#include <gtest/gtest.h> +#include <windows.h> + +int main(int argc, char **argv) +{ + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |