• entries
23
12
• views
1967

# C++ Set Up GTest for TDD. C++, VS

1759 views

I made an example of project in VS 2015: SortFunctions.zip  This project will show you how set up Google Test in Visual Studio and run simple unit tests.

Note. If you have another version of VS then before you will run unit tests you need to select VS 2017, like in this screenshot:

Spoiler

Google Test library is included in the project as source folder and it is placed in "Libs" folder. You need to:

• open the solution. The solution is file with name: "SortFunctions.sln"
• select your version of VS, for example VS 2017 instead of VS 2015 as in screenshot above
• make the "SortFunction_UnitTests" project as "StartUp Project". For this: make right mouse button click on the "SortFunction_UnitTests" project -> select "Set as StartUp Project"
• press Ctrl+F5 to run unit tests

You will see this settings in the "SortFunction_UnitTests" project properties:

$(SolutionDir)Libs\gtest-1.8.1\include$(SolutionDir)Libs\gtest-1.8.1

## Create an account

Register a new account

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• ### Similar Content

• By belfegor
I had some code that worked before and it doesn't now. I have created minimal c++ project that can reproduce problem.
#include <iostream> void PrintFooM(); class Foo { int m; explicit Foo(int dummy) {} Foo(); public: static Foo& GetInstance() { static Foo f; return f; } int GetM() const { return m; } }; Foo::Foo() : Foo(-1) { m = 3; PrintFooM(); } void PrintFooM() { std::cout << "M = " << Foo::GetInstance().GetM() << std::endl; } int main() { Foo::GetInstance(); return 0; } Code runs till PrintFooM function is called and its stuck there (like in some endless loop). Never prints anything in console.
I am using VS2017 community.
• By ArcEcho
Recently，I am studying bullet3 and DirectX 11.And I got some wired results like the attachments shows.It should be a sphere not a flat plane.
I extended the btIDebugDraw to draw lines.The draw line api works correctly independently.And I traced the call stack and found there was some thing wrong with the bullet transform .I have no idea about how it acts like that. So I ask for help here.Any help or tips will  be apreciated.

• By maltman
I have used EnTT for a few half finished projects. I like it because, as a more intermediate programmer, it forced me into the pattern. Sort of like coding on rails a bit in a good way.
Part of my feels that it is too much of a bother for most projects. Another part of me feels like that the ECS pattern is only going to get more common and that I should be concerned about data locality and speed no matter what (otherwise why am I even writing in C++?). I've honestly never had a project which needed the extra performance boost that an ECS library would give me. Usually my bottleneck is inefficient collision detection and noob rendering.
Two parts of my mind are conflicting: one tells me that using a library is great because it lets me how things are supposed to be done, and that I should use a library of every type before I try to roll my own. Another part of my mind tells me that I will never fully learn this stuff without rolling my own and that I am wasting my time using a library when I can't even roll my own and don't know completely how it all works.
Anyhow, let me know your thoughts and experiences with ECS libraries.

Hi
It is possible at all to copy descriptors between _two different_ heaps ? The documentation says so:

First (source) heap is:
D3D12_DESCRIPTOR_HEAP_DESC HeapDesc;     HeapDesc.NumDescriptors = 256;     HeapDesc.Type           = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER;     HeapDesc.Flags          = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;     HeapDesc.NodeMask       = 0; and SrcHeap->GetCPUDescriptorHandleForHeapStart() ==> Handle.ptr == 4 (strange, value indeed, I'd expected ptr as in case of GPU handles)
Second (destination) heap is:
HeapDesc.NumDescriptors = 128;     HeapDesc.Type           = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER;     HeapDesc.Flags          = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;     HeapDesc.NodeMask       = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; and DstHeap->GetCPUDescriptorHandleForHeapStart() ==> Handle.ptr == 9 (strange, value indeed, I'd expected ptr as in case of GPU handles)
and I want to copy elements 5, 6, and 7 from first one to the second one
auto Increment = Device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); // Return 32 CD3DX12_CPU_DESCRIPTOR_HANDLE Src = CD3DX12_CPU_DESCRIPTOR_HANDLE(SrcHeap->GetCPUDescriptorHandleForHeapStart(), 5, Increment); CD3DX12_CPU_DESCRIPTOR_HANDLE Dst = CD3DX12_CPU_DESCRIPTOR_HANDLE(DstHeap->GetCPUDescriptorHandleForHeapStart(), 0, Increment); Device->CopyDescriptorsSimple(3, Dst, Src, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); and debug layers says:
D3D12 ERROR: ID3D12Device::CopyDescriptors: Source ranges and dest ranges overlap, which results in undefined behavior. [ EXECUTION ERROR #653: COPY_DESCRIPTORS_INVALID_RANGES]
and indeed samplers are not copied to the shader visible descriptors heap ... why ?
I have win10 1809 (x64), latest nvidia drivers and 2080RTX (I do not have any other cards, and device is initialized on 2080RTX)
I'v compilled ModelViewer from DXSamples MiniEngine ... and it spills out that same error from within it's DynamicDescriptorHeap implementation :/

• Hello,
I am new to game development and am 4 courses away from obtaining an undergraduate degree in the field where I am specializing in game play programming. The course I am currently in is designed to help us with the transition period from being a student and entering the job search and making this passion a profession. By the end of the course I should have a pretty good start on what will become a portfolio.
This course is what actually brought me to this site and suggested it would be a great place to get support and to provide support when our skill level was up enough to be able to help others. So first, I would like to say hello to anyone who has taken the time to read my very first post here and a special thanks to anyone that replies with any feedback at all. I really do appreciate any and all help or criticism.
We were asked to create a proof of concept this week and will eventually need to create a prototype that illustrates our skills in programming. I always want to push myself to see what I can accomplish and decided to come up with an inventory system. I am not sure if it is an original thought, but I feel it would be unique enough to help me stand out from the crowd. At least I hope.
The concept is that a player can equip and fill a backpack. They can then drop the filled backpack and all the items will remain accounted for within it. The play can then pickup another backpack and repeat this process. It is important to note that if this is used in a multiplayer game, that another player can loot that filled backpack or pick it up and equip it.
The question and support I am asking for is more in the realm of guidance. I have searched several places and have not had much luck in finding a good reference to build off from when it comes to developing a complex inventory system that is essentially independent from the player character. Would anyone have any tips or resource suggestions that may help me narrow the search down?
Any suggestions would be greatly appreciated.
It might be important to note I plan on making the prototype using C++ within the Unreal Engine.
Thanks again for the time it took to read this post and I look forward to any feedback.
Happy Gaming
Devan Luciano
×