Browse Source

unitests: add mathlib test

pull/241/head
nillerusr 2 years ago
parent
commit
1ccbe2bbb6
  1. 41
      unittests/mathlibtest/mathlib_performance_test.cpp
  2. 43
      unittests/mathlibtest/mathlib_test.cpp
  3. 39
      unittests/mathlibtest/wscript
  4. 2
      wscript

41
unittests/mathlibtest/mathlib_performance_test.cpp

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Unit test program for CommandBuffer
//
// $NoKeywords: $
//=============================================================================//
#include "unitlib/unitlib.h"
#include "tier1/CommandBuffer.h"
#include "tier1/strtools.h"
#include "tier0/platform.h"
#include "tier0/fasttimer.h"
DEFINE_TESTSUITE( MathlibTestSuite )
DEFINE_TESTCASE( MathlibTestSSE, MathlibTestSuite )
{
CFastTimer timer;
timer.Start();
float sum = 0.f;
for( float a = 0.f; a <= M_PI; a += 0.000001f )
sum += sinf(a);
timer.End();
Msg("cos Cycles: %llu\n", timer.GetDuration().GetLongCycles());
Msg("cos sum - %f\n", sum);
timer.Start();
for( float a = 0.f; a <= M_PI; a += 0.000001f )
sum += FastCos(a);
timer.End();
Msg("ssecos Cycles: %llu\n", timer.GetDuration().GetLongCycles());
Msg("ssecos sum - %f\n", sum);
}

43
unittests/mathlibtest/mathlib_test.cpp

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Unit test program for testing of mathlib
//
// $NoKeywords: $
//=============================================================================//
#include "unitlib/unitlib.h"
#include "filesystem.h"
#include "tier2/tier2.h"
#include "mathlib/mathlib.h"
//-----------------------------------------------------------------------------
// Used to connect/disconnect the DLL
//-----------------------------------------------------------------------------
class CTier2TestAppSystem : public CTier2AppSystem< IAppSystem >
{
typedef CTier2AppSystem< IAppSystem > BaseClass;
public:
virtual bool Connect( CreateInterfaceFn factory )
{
if ( !BaseClass::Connect( factory ) )
return false;
if ( !g_pFullFileSystem )
return false;
return true;
}
virtual InitReturnVal_t Init()
{
MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f );
InitReturnVal_t nRetVal = BaseClass::Init();
if ( nRetVal != INIT_OK )
return nRetVal;
return INIT_OK;
}
};
USE_UNITTEST_APPSYSTEM( CTier2TestAppSystem )

39
unittests/mathlibtest/wscript

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
#! /usr/bin/env python
# encoding: utf-8
from waflib import Utils
import os
top = '.'
PROJECT_NAME = 'mathlibtest'
def options(opt):
return
def configure(conf):
conf.define('TIER2TEST_EXPORTS', 1)
def build(bld):
source = ['mathlib_performance_test.cpp', 'mathlib_test.cpp']
includes = ['../../public', '../../public/tier0']
defines = []
libs = ['tier0', 'tier1','tier2', 'mathlib', 'unitlib']
if bld.env.DEST_OS != 'win32':
libs += [ 'DL', 'LOG' ]
else:
libs += ['USER32', 'SHELL32']
install_path = bld.env.TESTDIR
bld.shlib(
source = source,
target = PROJECT_NAME,
name = PROJECT_NAME,
features = 'c cxx',
includes = includes,
defines = defines,
use = libs,
install_path = install_path,
subsystem = bld.env.MSVC_SUBSYSTEM,
idx = bld.get_taskgen_count()
)

2
wscript

@ -51,6 +51,7 @@ projects={ @@ -51,6 +51,7 @@ projects={
'launcher',
'launcher_main',
'materialsystem',
# 'materialsystem/shaderapiempty',
'materialsystem/shaderapidx9',
'materialsystem/shaderlib',
'materialsystem/stdshaders',
@ -94,6 +95,7 @@ projects={ @@ -94,6 +95,7 @@ projects={
'unittests/tier1test',
'unittests/tier2test',
'unittests/tier3test',
'unittests/mathlibtest',
'utils/unittest'
],
'dedicated': [

Loading…
Cancel
Save