first-ever CppUnit unit tests
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3679 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
bec8d601c2
commit
2da10af05b
4 changed files with 175 additions and 1 deletions
104
Source/Tests/Tests.dsp
Normal file
104
Source/Tests/Tests.dsp
Normal file
|
@ -0,0 +1,104 @@
|
|||
# Microsoft Developer Studio Project File - Name="Tests" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=Tests - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Tests.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Tests.mak" CFG="Tests - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Tests - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "Tests - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Tests - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# ADD BASE RSC /l 0x40d /d "NDEBUG"
|
||||
# ADD RSC /l 0x40d /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# 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 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
|
||||
# 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 cppunit.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "Tests - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# ADD BASE RSC /l 0x40d /d "_DEBUG"
|
||||
# ADD RSC /l 0x40d /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# 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 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
|
||||
# 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
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Tests - Win32 Release"
|
||||
# Name "Tests - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Tests.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
36
Source/Tests/endian.cpp
Normal file
36
Source/Tests/endian.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include "../util.h"
|
||||
|
||||
class EndianTest : public CppUnit::TestFixture {
|
||||
|
||||
CPPUNIT_TEST_SUITE( EndianTest );
|
||||
CPPUNIT_TEST( testSwapEndian );
|
||||
CPPUNIT_TEST( testFixEndian );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
void testSwapEndian() {
|
||||
CPPUNIT_ASSERT_EQUAL( (int)0x78563412, (int)SWAP_ENDIAN_INT32(0x12345678) );
|
||||
CPPUNIT_ASSERT_EQUAL( (int)0xFFFFFFFF, (int)SWAP_ENDIAN_INT32(0xFFFFFFFF) );
|
||||
CPPUNIT_ASSERT_EQUAL( (int)0, (int)SWAP_ENDIAN_INT32(0) );
|
||||
}
|
||||
|
||||
void testFixEndian() {
|
||||
int i=1;
|
||||
int actual = 0x12345678;
|
||||
FIX_ENDIAN_INT32_INPLACE(actual);
|
||||
int expected;
|
||||
if (((char*)&i)[0] == 1) {
|
||||
// little endian
|
||||
expected = 0x12345678;
|
||||
}
|
||||
else {
|
||||
// big endian
|
||||
expected = 0x78563412;
|
||||
}
|
||||
CPPUNIT_ASSERT_EQUAL(expected, actual);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( EndianTest );
|
22
Source/Tests/textrunner.cpp
Normal file
22
Source/Tests/textrunner.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include <cppunit/CompilerOutputter.h>
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// Get the top level suite from the registry
|
||||
CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
|
||||
|
||||
// Adds the test to the list of test to run
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
runner.addTest( suite );
|
||||
|
||||
// Change the default outputter to a compiler error format outputter
|
||||
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
|
||||
std::cerr ) );
|
||||
// Run the tests.
|
||||
bool wasSucessful = runner.run();
|
||||
|
||||
// Return error code 1 if the one of test failed.
|
||||
return wasSucessful ? 0 : 1;
|
||||
}
|
|
@ -3,6 +3,18 @@ Microsoft Developer Studio Workspace File, Format Version 6.00
|
|||
|
||||
###############################################################################
|
||||
|
||||
Project: "Tests"=.\Tests\Tests.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "exehead_bzip2"=".\exehead\exehead-bzip2.dsp" - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
|
@ -39,7 +51,7 @@ Package=<4>
|
|||
|
||||
###############################################################################
|
||||
|
||||
Project: "makenssi"=".\makenssi.dsp" - Package Owner=<4>
|
||||
Project: "makenssi"=.\makenssi.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue