Commit 59d29d9e authored by Ivan.Shulga's avatar Ivan.Shulga Committed by Alexander Trofimov

test for our implementation of CStringT::Tokenize and GetSysColor

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@58632 954022d7-b5bf-4e40-9824-e11837661b57
parent 50e5307c

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tokenize_Test", "Tokenize_Test\Tokenize_Test.vcproj", "{48786367-2A10-451E-96C7-D5F99AFF53E2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{48786367-2A10-451E-96C7-D5F99AFF53E2}.Debug|Win32.ActiveCfg = Debug|Win32
{48786367-2A10-451E-96C7-D5F99AFF53E2}.Debug|Win32.Build.0 = Debug|Win32
{48786367-2A10-451E-96C7-D5F99AFF53E2}.Release|Win32.ActiveCfg = Release|Win32
{48786367-2A10-451E-96C7-D5F99AFF53E2}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
========================================================================
CONSOLE APPLICATION : Tokenize_Test Project Overview
========================================================================
AppWizard has created this Tokenize_Test application for you.
This file contains a summary of what you will find in each of the files that
make up your Tokenize_Test application.
Tokenize_Test.vcproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
Tokenize_Test.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
AppWizard has created the following resources:
Tokenize_Test.rc
This is a listing of all of the Microsoft Windows resources that the
program uses. It includes the icons, bitmaps, and cursors that are stored
in the RES subdirectory. This file can be directly edited in Microsoft
Visual C++.
Resource.h
This is the standard header file, which defines new resource IDs.
Microsoft Visual C++ reads and updates this file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named Tokenize_Test.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Tokenize_Test.rc
//
#define IDS_APP_TITLE 103
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
// Tokenize_Test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "Tokenize_Test.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#include <iostream>
#include <vector>
#include <assert.h>
// The one and only application object
CWinApp theApp;
using namespace std;
CStringA Tokenize (CStringA base, char* pTokens, int& iStart)
{
if (iStart < 0 || NULL == pTokens)
return CStringA();
int nSize = base.GetLength();
int nCurrentSymbolPos = iStart;
// iterate all the symbols from iStart pos
while (nCurrentSymbolPos < nSize)
{
char nCurrentSymbol = base[nCurrentSymbolPos];
// iterate all the tokens
char *pCurrentTokenPtr = pTokens;
while (*pCurrentTokenPtr != (char) 0)
{
if (nCurrentSymbol == *pCurrentTokenPtr)
{
// found
int nOldStartValue = iStart;
iStart = nCurrentSymbolPos + 1;
int nCharsCount = nCurrentSymbolPos - nOldStartValue;
if (0 == nCharsCount)
{
// skip this char
break;
}
return base.Mid (nOldStartValue, nCurrentSymbolPos - nOldStartValue);
}
pCurrentTokenPtr++;
}
nCurrentSymbolPos++;
}
// return last string after last token
int nOldStartValue = iStart;
iStart = -1;
return base.Mid (nOldStartValue);
}
bool is_equal (const std::vector<std::string> &sTokenized1, const std::vector<std::string> &sTokenized2)
{
if (sTokenized1.size() != sTokenized2.size())
return false;
for (int i = 0; i < sTokenized1.size(); ++i)
{
if (0 != sTokenized1[i].compare (sTokenized2[i]))
return false;
}
return true;
}
bool tokenizeTest (char *text, char* tokens)
{
std::vector<std::string> sTokenized1;
std::vector<std::string> sTokenized2;
std::cout << "text:" << text << std::endl;
// CString
CStringA str = text;
int curPos = 0;
CStringA resToken= str.Tokenize(tokens,curPos);
while (resToken != "")
{
printf ("Resulting token: %s\n", resToken.GetString());
sTokenized1.push_back (resToken.GetString());
resToken = str.Tokenize(tokens, curPos);
};
// our implementation
curPos = 0;
CStringA resToken2 = Tokenize(str, tokens,curPos);
while (resToken2 != "")
{
printf ("Resulting token: %s\n", resToken2.GetString());
sTokenized2.push_back (resToken2.GetString());
resToken2 = Tokenize(str, tokens, curPos);
};
// test
return is_equal (sTokenized1, sTokenized2);
}
bool DoTokenizeTests ()
{
bool bRes = true;
bRes = tokenizeTest("qwerty!wertyui#qwertyu%qwertyuio% 123456789 &123456789%23456789#", "%#");
assert (bRes);
bRes = tokenizeTest("fhdgf wghfkwjfqlw;idwugyefh fweh fiuw;euwekhfiwefhkwefhilwefjp", " ");
assert (bRes);
bRes = tokenizeTest("1234567890--0762uijacbsdjkfhdfklghbdjhvieuybvgiueytierug", "-");
assert (bRes);
bRes = tokenizeTest("vjdhsfuibyc7qwybr78tr67wtcg78w6rt78tyoi8yrh7wqetrgq876rt87wq", "78");
assert (bRes);
bRes = tokenizeTest("bvcxn", "");
assert (bRes);
bRes = tokenizeTest("bvcxn1234567890-1234567890-123456789012345678901234567890", " ");
assert (bRes);
bRes = tokenizeTest("------############----------#########-------%%%%qwertyu&&&&", "-#%");
assert (bRes);
bRes = tokenizeTest("------############----------#########-------%%%%qwertyu&&&&", "-");
assert (bRes);
bRes = tokenizeTest("------############----------#########-------%%%%qwertyu&&&&", "&");
assert (bRes);
return bRes;
}
bool DoSysColorsTest ()
{
bool bRes = true;
printf ("//***************** GetSysColor values begin (Win7 x64) *****************\n");
DWORD nValue = 0;
printf ("switch (nIndex) {\n");
nValue = GetSysColor(COLOR_3DDKSHADOW);
printf ("case COLOR_3DDKSHADOW: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_3DFACE);
printf ("case COLOR_3DFACE: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_3DHIGHLIGHT);
printf ("case COLOR_3DHIGHLIGHT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_3DHILIGHT);
printf ("case COLOR_3DHILIGHT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_3DLIGHT);
printf ("case COLOR_3DLIGHT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_3DSHADOW);
printf ("case COLOR_3DSHADOW: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_ACTIVEBORDER);
printf ("case COLOR_ACTIVEBORDER: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_ACTIVECAPTION);
printf ("case COLOR_ACTIVECAPTION: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_APPWORKSPACE);
printf ("case COLOR_APPWORKSPACE: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_BACKGROUND);
printf ("case COLOR_BACKGROUND: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_BTNFACE);
printf ("case COLOR_BTNFACE: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_BTNHIGHLIGHT);
printf ("case COLOR_BTNHIGHLIGHT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_BTNHILIGHT);
printf ("case COLOR_BTNHILIGHT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_BTNSHADOW);
printf ("case COLOR_BTNSHADOW: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_BTNTEXT);
printf ("case COLOR_BTNTEXT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_CAPTIONTEXT);
printf ("case COLOR_CAPTIONTEXT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_DESKTOP);
printf ("case COLOR_DESKTOP: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_GRADIENTACTIVECAPTION);
printf ("case COLOR_GRADIENTACTIVECAPTION: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_GRADIENTINACTIVECAPTION);
printf ("case COLOR_GRADIENTINACTIVECAPTION: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_GRAYTEXT);
printf ("case COLOR_GRAYTEXT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_HIGHLIGHT);
printf ("case COLOR_HIGHLIGHT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_HIGHLIGHTTEXT);
printf ("case COLOR_HIGHLIGHTTEXT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_HOTLIGHT);
printf ("case COLOR_HOTLIGHT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_INACTIVEBORDER);
printf ("case COLOR_INACTIVEBORDER: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_INACTIVECAPTION);
printf ("case COLOR_INACTIVECAPTION: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_INACTIVECAPTIONTEXT);
printf ("case COLOR_INACTIVECAPTIONTEXT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_INFOBK);
printf ("case COLOR_INFOBK: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_INFOTEXT);
printf ("case COLOR_INFOTEXT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_MENU);
printf ("case COLOR_MENU: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_MENUHILIGHT);
printf ("case COLOR_MENUHILIGHT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_MENUBAR);
printf ("case COLOR_MENUBAR: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_MENUTEXT);
printf ("case COLOR_MENUTEXT: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_SCROLLBAR);
printf ("case COLOR_SCROLLBAR: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_WINDOW);
printf ("case COLOR_WINDOW: nValue = 0x%x; break;\n", nValue);
nValue = GetSysColor(COLOR_WINDOWFRAME);
printf ("case COLOR_WINDOWFRAME: nValue = 0x%6x; break;\n", nValue);
nValue = GetSysColor(COLOR_WINDOWTEXT);
printf ("case COLOR_WINDOWTEXT: nValue = 0x%x; break;\n", nValue);
printf ("} // switch (nIndex)\n");
printf ("//***************** GetSysColor values end *****************\n");
return bRes;
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
//DoTokenizeTests ();
DoSysColorsTest ();
}
return nRetCode;
}
//Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
LANGUAGE 25, 1
#pragma code_page(1251)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_APP_TITLE "Tokenize_Test"
END
#endif
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#ifndef _AFXDLL
#include "afxres.rc"
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="Tokenize_Test"
ProjectGUID="{48786367-2A10-451E-96C7-D5F99AFF53E2}"
RootNamespace="Tokenize_Test"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
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"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
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="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
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;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Tokenize_Test.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\Resource.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath=".\Tokenize_Test.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\Tokenize_Test.rc"
>
</File>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
// stdafx.cpp : source file that includes just the standard includes
// Tokenize_Test.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows XP or later.
#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
#endif
#include <stdio.h>
#include <tchar.h>
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include <afx.h>
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <iostream>
// TODO: reference additional headers your program requires here
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment