Reputation: 260
I am currently learning Unit Testing in Visual Studio 2015 but I am finding it hard to find good resources on the topic.
I have set up a C++ Native Unit Test project in the same solution as my main project. I then Set up the main project as a reference in the test project.
My issue is, when I include a file from the main project in the test, almost every single function is giving out compiler errors like these.
This is the test class
#include "stdafx.h"
#include "CppUnitTest.h"
#include <Windows.h>
#include <Util\fileutil.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace EngineTest
{
using namespace Engine;
TEST_CLASS(EngineTests)
{
public:
TEST_METHOD(UnitTestTest)
{
int i = 1;
Assert::IsTrue(i == 1);
}
TEST_METHOD(FilePathSplit)
{
FileUtils testClass;
std::string examplePath = "./FolderOne/FolderTwo/File.file";
std::string exampleName = "File.file";
std::set<char> delims{ '\\', '/' };
std::string fileName = testClass.test_splitpath(examplePath, delims).back();
Assert::AreSame(fileName, exampleName);
}
};
}
The build works just fine, so I assume it is an issue with dependencies not being loaded in, I have tried adding all the headers into stdafx but that did not change anything.
Any help is appreciated.
Upvotes: 1
Views: 236
Reputation: 260
Okay so it was a stupid issue.
The main project was set to support Multi-Byte character sets and the other was set to use Unicode. So all the errors where me trying to convert const char* into win32 formats and it didnt like it.
Properties -> General -> Character Sets
Upvotes: 1