小编ble*_*sjr的帖子

跨平台C++工具链

您好我正在我的Windows Box上组装一个工具链,用于跨平台C++开发.我计划使用Boost.Build进行构建,使用Boost :: Test进行单元测试.我将使用Mercurial作为我的VCS,因为我可以将repo放在我的外部HD上,然后将其拉到我的windows或linux分区.阻碍我的主要方法是编辑器编译器/调试器.有人有什么建议吗?

使用Boost.Build,我可以在技术上使用它支持的任何编译器轻松构建.这意味着Windows上的MSVC和Linux上的GCC使用带有标志的相同脚本.

c++ cross-platform

7
推荐指数
3
解决办法
2802
查看次数

在测试之间增强测试夹具对象清除

我遇到了升压单元测试的问题.基本上我创建了一个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)

c++ boost unit-testing

2
推荐指数
1
解决办法
2051
查看次数

标签 统计

c++ ×2

boost ×1

cross-platform ×1

unit-testing ×1