Commit e09a0900 authored by Luis Anton Rebollo's avatar Luis Anton Rebollo

Merge pull request #706 from eightyeight/add-gtest

Add Google test library
parents 4510e294 d1070210
# This file contains a list of people who've made non-trivial
# contribution to the Google C++ Testing Framework project. People
# who commit code to the project are encouraged to add their names
# here. Please keep the list sorted by first names.
Ajay Joshi <jaj@google.com>
Balázs Dán <balazs.dan@gmail.com>
Bharat Mediratta <bharat@menalto.com>
Chandler Carruth <chandlerc@google.com>
Chris Prince <cprince@google.com>
Chris Taylor <taylorc@google.com>
Dan Egnor <egnor@google.com>
Eric Roman <eroman@chromium.org>
Hady Zalek <hady.zalek@gmail.com>
Jeffrey Yasskin <jyasskin@google.com>
Jói Sigurðsson <joi@google.com>
Keir Mierle <mierle@gmail.com>
Keith Ray <keith.ray@gmail.com>
Kenton Varda <kenton@google.com>
Manuel Klimek <klimek@google.com>
Markus Heule <markus.heule@gmail.com>
Mika Raento <mikie@iki.fi>
Miklós Fazekas <mfazekas@szemafor.com>
Pasi Valminen <pasi.valminen@gmail.com>
Patrick Hanna <phanna@google.com>
Patrick Riley <pfr@google.com>
Peter Kaminski <piotrk@google.com>
Preston Jackson <preston.a.jackson@gmail.com>
Rainer Klaffenboeck <rainer.klaffenboeck@dynatrace.com>
Russ Cox <rsc@google.com>
Russ Rufer <russ@pentad.com>
Sean Mcafee <eefacm@gmail.com>
Sigurður Ásgeirsson <siggi@google.com>
Tracy Bialik <tracy@pentad.com>
Vadim Berman <vadimb@google.com>
Vlad Losev <vladl@google.com>
Zhanyong Wan <wan@google.com>
Copyright 2008, Google Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// Copyright 2006, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdio.h>
#include "gtest/gtest.h"
GTEST_API_ int main(int argc, char **argv) {
printf("Running main() from gtest_main.cc\n");
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
//-----------------------------------------------------------------------------
// Copyright (c) 2013 Stephan Brenner https://github.com/ymx/gtest_mem
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include <iostream>
#include <gtest/gtest.h>
#if defined(TORQUE_OS_WIN)
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#endif
namespace testing
{
class MemoryLeakDetector : public EmptyTestEventListener
{
public:
virtual void OnTestStart(const TestInfo&)
{
#if defined(TORQUE_OS_WIN)
_CrtMemCheckpoint(&memState_);
#endif
}
virtual void OnTestEnd(const TestInfo& test_info)
{
if(test_info.result()->Passed())
{
#if defined(TORQUE_OS_WIN)
_CrtMemState stateNow, stateDiff;
_CrtMemCheckpoint(&stateNow);
int diffResult = _CrtMemDifference(&stateDiff, &memState_, &stateNow);
if (diffResult)
{
FAIL() << "Memory leak of " << stateDiff.lSizes[1] << " byte(s) detected.";
}
#endif
}
}
private:
#if defined(TORQUE_OS_WIN)
_CrtMemState memState_;
#endif
};
}
\ No newline at end of file
//-----------------------------------------------------------------------------
// Copyright (c) 2014 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifdef TORQUE_TESTS_ENABLED
#include "console/engineAPI.h"
#include "console/consoleInternal.h"
#include "unitTesting.h"
#include "memoryTester.h"
#include <gtest/gtest-all.cc>
//-----------------------------------------------------------------------------
class TorqueUnitTestListener : public ::testing::EmptyTestEventListener
{
// Called before a test starts.
virtual void OnTestStart( const ::testing::TestInfo& testInfo )
{
Con::printf("> Starting Test '%s.%s'",
testInfo.test_case_name(), testInfo.name());
}
// Called after a failed assertion or a SUCCEED() invocation.
virtual void OnTestPartResult( const ::testing::TestPartResult& testPartResult )
{
if ( testPartResult.failed() )
{
Con::warnf(">> Failed with '%s' in '%s' at (line:%d)",
testPartResult.summary(),
testPartResult.file_name(),
testPartResult.line_number()
);
}
else
{
Con::printf(">> Passed with '%s' in '%s' at (line:%d)",
testPartResult.summary(),
testPartResult.file_name(),
testPartResult.line_number()
);
}
}
// Called after a test ends.
virtual void OnTestEnd( const ::testing::TestInfo& testInfo )
{
Con::printf("> Ending Test '%s.%s'\n",
testInfo.test_case_name(), testInfo.name());
}
};
DefineConsoleFunction( runAllUnitTests, int, (),,
"" )
{
// Set-up some empty arguments.
S32 testArgc = 0;
char** testArgv = NULL;
// Initialize Google Test.
testing::InitGoogleTest( &testArgc, testArgv );
// Fetch the unit test instance.
testing::UnitTest& unitTest = *testing::UnitTest::GetInstance();
// Fetch the unit test event listeners.
testing::TestEventListeners& listeners = unitTest.listeners();
// Release the default listener.
delete listeners.Release( listeners.default_result_printer() );
if ( Con::getBoolVariable( "$testing::checkMemoryLeaks", false ) ) {
// Add the memory leak tester.
listeners.Append( new testing::MemoryLeakDetector );
}
// Add the Torque unit test listener.
listeners.Append( new TorqueUnitTestListener );
Con::printf( "\nUnit Tests Starting...\n" );
const S32 result = RUN_ALL_TESTS();
Con::printf( "\n... Unit Tests Ended.\n" );
return result;
}
#endif // TORQUE_TESTS_ENABLED
//-----------------------------------------------------------------------------
// Copyright (c) 2014 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _UNIT_TESTING_H_
#define _UNIT_TESTING_H_
#ifdef TORQUE_TESTS_ENABLED
#include <gtest/gtest.h>
/// Allow test fixtures named with a Fixture suffix, so that we can name tests
/// after a class name rather than having to call them XXTest.
#define TEST_FIX(test_fixture, test_name)\
GTEST_TEST_(test_fixture, test_name, test_fixture##Fixture, \
::testing::internal::GetTypeId<test_fixture##Fixture>())
/// Convenience to define a test fixture with a Fixture suffix for use with
/// TEST_FIX.
#define FIXTURE(test_fixture)\
class test_fixture##Fixture : public ::testing::Test
#endif // TORQUE_TESTS_ENABLED
#endif // _UNIT_TESTING_H_
new GuiControlProfile(GuiDefaultProfile);
new GuiControlProfile(GuiToolTipProfile);
new GuiCanvas(Canvas);
function onLightManagerActivate() {}
function onLightManagerDeactivate() {}
Canvas.setWindowTitle("Torque 3D Unit Tests");
new RenderPassManager(DiffuseRenderPassManager);
setLightManager("Basic Lighting");
setLogMode(2);
$Con::LogBufferEnabled = false;
$Testing::checkMemoryLeaks = false;
runAllUnitTests();
quit();
new GuiControlProfile(GuiDefaultProfile);
new GuiControlProfile(GuiToolTipProfile);
new GuiCanvas(Canvas);
function onLightManagerActivate() {}
function onLightManagerDeactivate() {}
Canvas.setWindowTitle("Torque 3D Unit Tests");
new RenderPassManager(DiffuseRenderPassManager);
setLightManager("Basic Lighting");
setLogMode(2);
$Con::LogBufferEnabled = false;
$Testing::checkMemoryLeaks = false;
runAllUnitTests();
quit();
# Project defines
addDef( "TORQUE_TESTS_ENABLED" )
addDef( "_VARIADIC_MAX" 10 )
# Add source files
addPathRec( "${srcDir}/testing" )
# Add include paths
addInclude( "${libDir}/gtest/fused-src/" )
<?php
//-----------------------------------------------------------------------------
// Copyright (c) 2013 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
beginModule( 'testing' );
addProjectDefine( 'TORQUE_TESTS_ENABLED' );
addProjectDefine( '_VARIADIC_MAX', 10 );
addSrcDir(getEngineSrcDir() . 'testing', true);
addLibIncludePath( 'gtest/fused-src/' );
endModule();
?>
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