您好我正在我的Windows Box上组装一个工具链,用于跨平台C++开发.我计划使用Boost.Build进行构建,使用Boost :: Test进行单元测试.我将使用Mercurial作为我的VCS,因为我可以将repo放在我的外部HD上,然后将其拉到我的windows或linux分区.阻碍我的主要方法是编辑器编译器/调试器.有人有什么建议吗?
使用Boost.Build,我可以在技术上使用它支持的任何编译器轻松构建.这意味着Windows上的MSVC和Linux上的GCC使用带有标志的相同脚本.
我遇到了升压单元测试的问题.基本上我创建了一个fixture,它是一个单元测试资源缓存的套件的一部分.我的主要问题是测试之间资源缓存变空.因此,第一个测试缓存通过的测试然后第二个测试将失败,因为插入缓存的第一个测试的数据不再存在.为了解决这个问题,我不得不重新插入第二次测试的数据.这是打算还是我做错了?这是代码.最后两个测试是问题所在.
#include "UnitTestIncludes.hpp"
#include "ResourceCache.hpp"
#include <SFML/Graphics.hpp>
struct ResourceCacheFixture
{
ResourceCacheFixture()
{
BOOST_TEST_MESSAGE("Setup Fixture...");
key = "graysqr";
imgpath = "../images/graysqr.png";
}
ResourceCache<sf::Image, ImageGenerator> imgCache;
std::string key;
std::string imgpath;
};
// Start of Test Suite
BOOST_FIXTURE_TEST_SUITE(ResourceCacheTestSuite, ResourceCacheFixture)
// Start of tests
BOOST_AUTO_TEST_CASE(ImageGeneratorTest)
{
ImageGenerator imgGen;
BOOST_REQUIRE(imgGen("../images/graysqr.png"));
}
BOOST_AUTO_TEST_CASE(FontGeneratorTest)
{
FontGenerator fntGen;
BOOST_REQUIRE(fntGen("../fonts/arial.ttf"));
}
// This is where the issue is. The data inserted in this test is lost for when I do
// the GetResourceTest. It is fixed here by reinserting …Run Code Online (Sandbox Code Playgroud)