Clean Up
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 600 KiB |
@@ -150,8 +150,9 @@
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="UTest\UTest.cpp" />
|
||||
<ClCompile Include="UtilityEngineTest\StringTest.cpp" />
|
||||
<ClCompile Include="VideoEngineTest\ImageTest.cpp" />
|
||||
<ClCompile Include="VideoEngineTest\ImageFileTest.cpp" />
|
||||
<ClCompile Include="VideoEngineTest\RendererTest.cpp" />
|
||||
<ClCompile Include="VideoEngineTest\VideoEngineTest.cpp" />
|
||||
<ClCompile Include="VideoEngineTest\VideoTest.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -159,8 +160,9 @@
|
||||
<ClInclude Include="GUIEngineTest\GUIXMLTest.hpp" />
|
||||
<ClInclude Include="UTest\UTest.hpp" />
|
||||
<ClInclude Include="UtilityEngineTest\StringTest.hpp" />
|
||||
<ClInclude Include="VideoEngineTest\ImageTest.hpp" />
|
||||
<ClInclude Include="VideoEngineTest\ImageFileTest.hpp" />
|
||||
<ClInclude Include="VideoEngineTest\RendererTest.hpp" />
|
||||
<ClInclude Include="VideoEngineTest\VideoEngineTest.hpp" />
|
||||
<ClInclude Include="VideoEngineTest\VideoTest.hpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -39,7 +39,10 @@
|
||||
<ClInclude Include="VideoEngineTest\VideoTest.hpp">
|
||||
<Filter>VideoEngineTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="VideoEngineTest\ImageTest.hpp">
|
||||
<ClInclude Include="VideoEngineTest\ImageFileTest.hpp">
|
||||
<Filter>VideoEngineTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="VideoEngineTest\VideoEngineTest.hpp">
|
||||
<Filter>VideoEngineTest</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
@@ -63,7 +66,10 @@
|
||||
<ClCompile Include="VideoEngineTest\VideoTest.cpp">
|
||||
<Filter>VideoEngineTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="VideoEngineTest\ImageTest.cpp">
|
||||
<ClCompile Include="VideoEngineTest\ImageFileTest.cpp">
|
||||
<Filter>VideoEngineTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="VideoEngineTest\VideoEngineTest.cpp">
|
||||
<Filter>VideoEngineTest</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
#include "UTest.hpp"
|
||||
|
||||
const /*static*/ char * UTest::sp_pstr = "pass";
|
||||
const /*static*/ char * UTest::sp_fstr = "fail";
|
||||
#include <stdio.h>
|
||||
|
||||
/*static*/ const char* UTest::sp_pstr = "pass";
|
||||
/*static*/ const char* UTest::sp_fstr = "fail";
|
||||
|
||||
/*static*/ unsigned long int UTest::s_pass = 0;
|
||||
/*static*/ unsigned long int UTest::s_fail = 0;
|
||||
|
||||
UTest::UTest( const char * tstr ) {
|
||||
UTest::UTest( const char* tstr )
|
||||
: m_pass(0), m_fail(0)
|
||||
{
|
||||
init(tstr);
|
||||
}
|
||||
|
||||
void UTest::init( const char * tstr ) {
|
||||
void UTest::init( const char* tstr )
|
||||
{
|
||||
mp_tstr = tstr;
|
||||
m_pass = m_fail = 0;
|
||||
}
|
||||
|
||||
void UTest::test( const char * description, const int flag ) {
|
||||
void UTest::test( const char* description, const int flag )
|
||||
{
|
||||
const char * pf = nullptr;
|
||||
if (flag) {
|
||||
pf = sp_pstr;
|
||||
@@ -29,7 +35,8 @@ void UTest::test( const char * description, const int flag ) {
|
||||
printf("%s: %s -> %s\n", mp_tstr, description, pf);
|
||||
}
|
||||
|
||||
void UTest::report() const {
|
||||
void UTest::report() const
|
||||
{
|
||||
printf("%s: pass: %ld, fail: %ld\n", mp_tstr, m_pass, m_fail);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef __UTEST__
|
||||
#define __UTEST__
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#define __UTest_VERSION "1.0.0"
|
||||
|
||||
class UTest {
|
||||
@@ -11,11 +9,11 @@ private:
|
||||
UTest operator = ( UTest & ); // no assignment operator
|
||||
UTest(){}
|
||||
public:
|
||||
static const char * version() { return __UTest_VERSION; }
|
||||
static const char* version() { return __UTest_VERSION; }
|
||||
|
||||
UTest( const char * );
|
||||
void init( const char * );
|
||||
void test( const char * description, const int flag );
|
||||
UTest( const char* tstr );
|
||||
void init( const char* tstr );
|
||||
void test( const char* description, const int flag );
|
||||
void report() const;
|
||||
|
||||
static void OverAllReport();
|
||||
@@ -24,13 +22,13 @@ private:
|
||||
unsigned long int m_pass = 0;
|
||||
unsigned long int m_fail = 0;
|
||||
|
||||
const char * mp_tstr = nullptr;
|
||||
const char* mp_tstr = nullptr;
|
||||
|
||||
const static char * sp_pstr; /*= "pass";*/
|
||||
const static char * sp_fstr; /*= "fail";*/
|
||||
static const char* sp_pstr; /*= "pass";*/
|
||||
static const char* sp_fstr; /*= "fail";*/
|
||||
|
||||
static unsigned long int s_pass;
|
||||
static unsigned long int s_fail;
|
||||
static unsigned long int s_pass; //= 0
|
||||
static unsigned long int s_fail; //= 0
|
||||
};
|
||||
|
||||
#endif // __UTEST__
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "ImageFileTest.hpp"
|
||||
|
||||
#include "../UTest/UTest.hpp"
|
||||
|
||||
/*** TrooperEngine DLL Header Files ***/
|
||||
#include "TrooperEngine.hpp"
|
||||
|
||||
using VideoEngine::cImageFile;
|
||||
|
||||
using VideoEngine::cSprite;
|
||||
|
||||
void ImageFileTest()
|
||||
{
|
||||
// cImageFile
|
||||
printf("\nTesting cImageFile -----\n\n");
|
||||
|
||||
UTest u("cImageFile");
|
||||
|
||||
cImageFile* image = new cImageFile("ImageTest.bmp");
|
||||
|
||||
//u.test()
|
||||
|
||||
//image->SaveImage("ImageTestSaved.bmp");
|
||||
|
||||
//cSprite* sprite = new cSprite(&image);
|
||||
|
||||
//sprite->Draw();
|
||||
|
||||
|
||||
u.report();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef __IMAGEFILETEST__
|
||||
#define __IMAGEFILETEST__
|
||||
|
||||
void ImageFileTest();
|
||||
|
||||
#endif // __IMAGEFILETEST__
|
||||
@@ -1,29 +0,0 @@
|
||||
#include "ImageTest.hpp"
|
||||
|
||||
#include "../UTest/UTest.hpp"
|
||||
|
||||
/*** TrooperEngine DLL Header Files ***/
|
||||
#include "TrooperEngine.hpp"
|
||||
|
||||
using VideoEngine::cImage;
|
||||
|
||||
using VideoEngine::cSprite;
|
||||
|
||||
void ImageTest()
|
||||
{
|
||||
// cRenderer
|
||||
printf("\nTesting cImage -----\n\n");
|
||||
|
||||
UTest u("cImage");
|
||||
|
||||
cImage* image = new cImage("ImageTest.bmp", "", false, 0, 0, 255, 255, true);
|
||||
|
||||
image->SaveImage("ImageTestSaved.bmp");
|
||||
|
||||
cSprite* sprite = new cSprite(&image);
|
||||
|
||||
sprite->Draw();
|
||||
|
||||
|
||||
u.report();
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
#ifndef __IMAGETEST__
|
||||
#define __IMAGETEST__
|
||||
|
||||
void ImageTest();
|
||||
|
||||
#endif // __IMAGETEST__
|
||||
@@ -14,8 +14,50 @@ void RendererTest()
|
||||
|
||||
UTest u("cRenderer");
|
||||
|
||||
SDL_Surface* sur = nullptr;
|
||||
//cRenderer::Inst()->TextureToSurface();
|
||||
u.test("cRenderer. Setup()", cRenderer::Inst().Setup());
|
||||
|
||||
u.test("Are Surface Equal. AreEqual()", RendererAreaEqual());
|
||||
u.test("Are Surface Equal Not Equal. AreEqual()", RendererAreaEqualNotEqual());
|
||||
|
||||
u.test("Texture To Surface. TextureToSurface()", RendererTextureToSurface());
|
||||
|
||||
|
||||
|
||||
//u.test("Screen Shot", RendererTextureToSurface());
|
||||
|
||||
|
||||
u.report();
|
||||
}
|
||||
|
||||
const bool RendererAreaEqual()
|
||||
{
|
||||
SDL_Surface* one = SDL_LoadBMP("ImageTest.bmp");
|
||||
SDL_Surface* two = SDL_LoadBMP("ImageTest.bmp");
|
||||
|
||||
return cRenderer::Inst().AreEqual(*one, *two);
|
||||
}
|
||||
|
||||
const bool RendererAreaEqualNotEqual()
|
||||
{
|
||||
SDL_Surface* one = SDL_LoadBMP("ImageTest.bmp");
|
||||
SDL_Surface* two = SDL_LoadBMP("ImageTest.bmp");
|
||||
|
||||
one = SDL_ConvertSurfaceFormat(one, SDL_PIXELFORMAT_RGBA32, 0);
|
||||
|
||||
bool rtn = false;
|
||||
if (cRenderer::Inst().AreEqual(*one, *two) == false)
|
||||
rtn = true;
|
||||
return rtn;
|
||||
}
|
||||
|
||||
const bool RendererTextureToSurface()
|
||||
{
|
||||
SDL_Texture* text = IMG_LoadTexture(cRenderer::Inst().getRendererCopy(), "ImageTest.bmp");
|
||||
|
||||
SDL_Surface* one = SDL_LoadBMP("ImageTest.bmp");
|
||||
one = SDL_ConvertSurfaceFormat(one, SDL_PIXELFORMAT_RGBA32, 0);
|
||||
|
||||
SDL_Surface* sur = cRenderer::Inst().TextureToSurface(text);
|
||||
|
||||
return cRenderer::Inst().AreEqual(*one, *sur);
|
||||
}
|
||||
@@ -3,4 +3,10 @@
|
||||
|
||||
void RendererTest();
|
||||
|
||||
const bool RendererAreaEqual();
|
||||
|
||||
const bool RendererAreaEqualNotEqual();
|
||||
|
||||
const bool RendererTextureToSurface();
|
||||
|
||||
#endif // __RENDERERTEST__
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "VideoEngineTest.hpp"
|
||||
|
||||
#include "VideoTest.hpp"
|
||||
#include "RendererTest.hpp"
|
||||
#include "ImageFileTest.hpp"
|
||||
|
||||
void VideoEngineTest()
|
||||
{
|
||||
VideoTest();
|
||||
|
||||
RendererTest();
|
||||
|
||||
ImageFileTest();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef __VIDEOENGINETEST__
|
||||
#define __VIDEOENGINETEST__
|
||||
|
||||
void VideoEngineTest();
|
||||
|
||||
#endif // __VIDEOENGINETEST__
|
||||
@@ -18,16 +18,26 @@ void VideoTest()
|
||||
VideoEngine::cVideo& video = VideoEngine::cVideo::Inst();
|
||||
video.Initialize();
|
||||
|
||||
u.test("Video Initialize", video.IsInit());
|
||||
u.test("Video Initialize. IsInit()", video.IsInit());
|
||||
|
||||
u.test("Video Setup", video.Setup());
|
||||
u.test("Video Setup. Setup()", video.Setup());
|
||||
|
||||
// CaptionTest
|
||||
cString cap_set = "Hello World";
|
||||
u.test("setCaption() and getCaption()", CaptionTest());
|
||||
|
||||
u.report();
|
||||
}
|
||||
|
||||
const bool CaptionTest()
|
||||
{
|
||||
bool rtn = false;
|
||||
|
||||
cString cap_set = "Caption Test";
|
||||
cVideo::Inst().setCaption(cap_set);
|
||||
cString cap_get = cVideo::Inst().getCaption();
|
||||
u.test("setCaption() and getCaption()", (cap_get == cap_set));
|
||||
|
||||
if (cap_get == cap_set)
|
||||
rtn = true;
|
||||
|
||||
u.report();
|
||||
return rtn;
|
||||
}
|
||||
@@ -3,4 +3,6 @@
|
||||
|
||||
void VideoTest();
|
||||
|
||||
const bool CaptionTest();
|
||||
|
||||
#endif // __VIDEOTEST__
|
||||
+11
-10
@@ -1,12 +1,12 @@
|
||||
/* Copyright (C) 2016 Richard W. Allen
|
||||
Program Name: SDL Pong C++
|
||||
Program Name: TrooperEngineTest
|
||||
Author: Richard W. Allen
|
||||
Version: V1.0
|
||||
Date Started: August 24, 2016
|
||||
Date End:
|
||||
Webpage: http://www.richardallenonline.com
|
||||
IDE: Visual Studio 2015
|
||||
Compiler: C\C++ 2014
|
||||
IDE: Visual Studio 2017
|
||||
Compiler: C\C++ 2017
|
||||
Langage: C++
|
||||
License: GNU GENERAL PUBLIC LICENSE Version 2
|
||||
see license.txt for details
|
||||
@@ -19,11 +19,11 @@ see license.txt for details
|
||||
/*** SDL Header Files ***/
|
||||
#include "SDL.h"
|
||||
|
||||
/*** Unit Testing ***/
|
||||
#include "UTest/UTest.hpp"
|
||||
|
||||
/*** Video Engine Test ***/
|
||||
#include "VideoEngineTest/VideoTest.hpp"
|
||||
#include "VideoEngineTest/ImageTest.hpp"
|
||||
#include "VideoEngineTest/VideoEngineTest.hpp"
|
||||
|
||||
/*** Utility Engine Test ***/
|
||||
#include "UtilityEngineTest/StringTest.hpp"
|
||||
@@ -45,15 +45,16 @@ int main(int argc, char *argv[])
|
||||
printf(cString("TrooperEngine V") + TrooperEngineCore::cTrooperEngineCore::Version() + "\n");
|
||||
|
||||
|
||||
VideoTest();
|
||||
VideoEngineTest();
|
||||
|
||||
|
||||
//UtilityEngineTest();
|
||||
|
||||
|
||||
StringTest();
|
||||
//StringTest();
|
||||
|
||||
GUIXMLTest();
|
||||
//GUIXMLTest();
|
||||
|
||||
ImageTest();
|
||||
//ImageTest();
|
||||
|
||||
|
||||
UTest::OverAllReport();
|
||||
|
||||
Reference in New Issue
Block a user