Added test for trim_left() and trim_right() functions.
This commit is contained in:
parent
7ab3ea5a95
commit
a0bd22a152
@ -17,6 +17,11 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\MUtilitiesTest.cpp" />
|
<ClCompile Include="src\MUtilitiesTest.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\MUtilities_VS2015.vcxproj">
|
||||||
|
<Project>{55405fe1-149f-434c-9d72-4b64348d2a08}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{B7BCA0A5-17AD-4F20-A42C-CD6FFBD55D89}</ProjectGuid>
|
<ProjectGuid>{B7BCA0A5-17AD-4F20-A42C-CD6FFBD55D89}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
@ -82,7 +87,7 @@
|
|||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\Prerequisites\GoogleTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)\include;$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)\..\Prerequisites\GoogleTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
|
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -102,7 +107,7 @@
|
|||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\Prerequisites\GoogleTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)\include;$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)\..\Prerequisites\GoogleTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||||
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
|
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
@ -115,8 +120,8 @@
|
|||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>$(SolutionDir)\..\Prerequisites\GoogleTest\$(PlatformToolset)\Shared;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(SolutionDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\lib;$(SolutionDir)\..\Prerequisites\GoogleTest\$(PlatformToolset)\Shared;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>gtest.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>gtest.lib;notelemetry.obj;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
|
||||||
@ -127,8 +132,8 @@
|
|||||||
<Optimization>Full</Optimization>
|
<Optimization>Full</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;MUTILS_STATIC_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_NODLL;QT_NO_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(SolutionDir)\..\Prerequisites\GoogleTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(SolutionDir)\include;$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)\..\Prerequisites\GoogleTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
|
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
|
||||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
@ -141,8 +146,8 @@
|
|||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalLibraryDirectories>$(SolutionDir)\..\Prerequisites\GoogleTest\lib\$(PlatformToolset)\Static;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>$(SolutionDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Static\lib;$(SolutionDir)\..\Prerequisites\GoogleTest\lib\$(PlatformToolset)\Static;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>gtest.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>gtest.lib;notelemetry.obj;QtCore.lib;QtGui.lib;Ws2_32.lib;Winmm.lib;Imm32.lib;PowrProf.lib;Version.lib;Psapi.lib;Sensapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
@ -19,14 +19,109 @@
|
|||||||
// http://www.gnu.org/licenses/lgpl-2.1.txt
|
// http://www.gnu.org/licenses/lgpl-2.1.txt
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//Google Test
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
TEST(FactorialTest, Zero) {
|
//MUtils
|
||||||
EXPECT_EQ(1, 1);
|
#include <MUtils/Global.h>
|
||||||
|
#include <MUtils/Version.h>
|
||||||
|
|
||||||
|
//CRT
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
//Utilities
|
||||||
|
#define ASSERT_QSTR(X,Y) ASSERT_EQ((X).compare(QLatin1String(Y)), 0);
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
// Trim String
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
TEST(Global, TrimStringLeft)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
QString test("");
|
||||||
|
MUtils::trim_left(test);
|
||||||
|
ASSERT_QSTR(test, "");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QString test(" ");
|
||||||
|
MUtils::trim_left(test);
|
||||||
|
ASSERT_QSTR(test, "");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QString test("! test !");
|
||||||
|
MUtils::trim_left(test);
|
||||||
|
ASSERT_QSTR(test, "! test !");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QString test(" test ");
|
||||||
|
MUtils::trim_left(test);
|
||||||
|
ASSERT_QSTR(test, "test ");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QString test(" ! test ! ");
|
||||||
|
MUtils::trim_left(test);
|
||||||
|
ASSERT_QSTR(test, "! test ! ");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const QString test(" test ");
|
||||||
|
ASSERT_QSTR(MUtils::trim_left(test), "test ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//MAIN
|
TEST(Global, TrimStringRight)
|
||||||
int main(int argc, char **argv) {
|
{
|
||||||
|
{
|
||||||
|
QString test("");
|
||||||
|
MUtils::trim_right(test);
|
||||||
|
ASSERT_QSTR(test, "");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QString test(" ");
|
||||||
|
MUtils::trim_right(test);
|
||||||
|
ASSERT_QSTR(test, "");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QString test("! test !");
|
||||||
|
MUtils::trim_right(test);
|
||||||
|
ASSERT_QSTR(test, "! test !");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QString test(" test ");
|
||||||
|
MUtils::trim_right(test);
|
||||||
|
ASSERT_QSTR(test, " test");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
QString test(" ! test ! ");
|
||||||
|
MUtils::trim_right(test);
|
||||||
|
ASSERT_QSTR(test, " ! test !");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const QString test(" test ");
|
||||||
|
ASSERT_QSTR(MUtils::trim_right(test), " test");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
// Main function
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
printf("MuldeR's Utilities for Qt - Test Suite\n");
|
||||||
|
printf("Copyright (C) 2004-2016 LoRd_MuldeR <MuldeR2@GMX.de>\n\n");
|
||||||
|
|
||||||
|
printf("Using MUtils v%u.%02u, built %s at %s, %s [%s]\n\n",
|
||||||
|
MUtils::Version::lib_version_major(), MUtils::Version::lib_version_minor(),
|
||||||
|
MUTILS_UTF8(MUtils::Version::lib_build_date().toString(Qt::ISODate)), MUTILS_UTF8(MUtils::Version::lib_build_time().toString(Qt::ISODate)),
|
||||||
|
MUtils::Version::compiler_version(), MUtils::Version::compiler_arch()
|
||||||
|
);
|
||||||
|
|
||||||
|
printf("This library is free software; you can redistribute it and/or\n");
|
||||||
|
printf("modify it under the terms of the GNU Lesser General Public\n");
|
||||||
|
printf("License as published by the Free Software Foundation; either\n");
|
||||||
|
printf("version 2.1 of the License, or (at your option) any later version.\n\n");
|
||||||
|
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user