Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert missing boost tests to doctest #807

Merged
merged 1 commit into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions plugins/CircuitViewer/tests/addCircuit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,24 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#define BOOST_TEST_MODULE circuitViewerAddCircuit

#include <jsonSerialization.h>

#include <tests/ClientServer.h>
#include <tests/paths.h>

#include <BBP/TestDatasets.h>

#include <boost/test/unit_test.hpp>
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "tests/doctest.h"

const std::string ADD_MODEL("add-model");

BOOST_AUTO_TEST_CASE(file_no_extension_blueconfig)
TEST_CASE("file_no_extension_blueconfig")
{
ClientServer clientServer({"--plugin", "braynsCircuitViewer --density 1"});

auto circuit = makeRequest<brayns::ModelParams, brayns::ModelDescriptor>(
ADD_MODEL, {"circuit", BBP_TEST_BLUECONFIG});
BOOST_CHECK_EQUAL(circuit.getName(), "circuit");
BOOST_CHECK_EQUAL(circuit.getPath(), BBP_TEST_BLUECONFIG);
CHECK_EQ(circuit.getName(), "circuit");
CHECK_EQ(circuit.getPath(), BBP_TEST_BLUECONFIG);
}
51 changes: 21 additions & 30 deletions plugins/CircuitViewer/tests/braynsTestData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,17 @@

#include <BBP/TestDatasets.h>

#define BOOST_TEST_MODULE braynsTestData
#include <boost/test/unit_test.hpp>
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "tests/doctest.h"

#ifdef BRAYNS_USE_NETWORKING
#include "tests/ClientServer.h"
#else
#endif

BOOST_AUTO_TEST_CASE(simple_circuit)
TEST_CASE("simple_circuit")
{
auto& testSuite = boost::unit_test::framework::master_test_suite();

const char* app = testSuite.argv[0];
const char* argv[] = {app,
const char* argv[] = {"simple_circuit",
BBP_TEST_BLUECONFIG3,
"--disable-accumulation",
"--samples-per-pixel",
Expand All @@ -64,17 +61,14 @@ BOOST_AUTO_TEST_CASE(simple_circuit)
brayns.getParametersManager().getRenderingParameters().setCurrentRenderer(
"basic");
brayns.commitAndRender();
BOOST_CHECK(compareTestImage("testdataLayer1.png",
brayns.getEngine().getFrameBuffer()));
CHECK(compareTestImage("testdataLayer1.png",
brayns.getEngine().getFrameBuffer()));
}

BOOST_AUTO_TEST_CASE(circuit_with_color_by_mtype)
TEST_CASE("circuit_with_color_by_mtype")
{
auto& testSuite = boost::unit_test::framework::master_test_suite();

const char* app = testSuite.argv[0];
const char* argv[] = {
app,
"circuit_with_color_by_mtype",
BBP_TEST_BLUECONFIG3,
"--disable-accumulation",
"--samples-per-pixel",
Expand All @@ -89,12 +83,12 @@ BOOST_AUTO_TEST_CASE(circuit_with_color_by_mtype)
brayns.getEngine().getScene().setMaterialsColorMap(
brayns::MaterialsColorMap::gradient);
brayns.commitAndRender();
BOOST_CHECK(compareTestImage("testdataMiniColumn0_mtypes.png",
brayns.getEngine().getFrameBuffer()));
CHECK(compareTestImage("testdataMiniColumn0_mtypes.png",
brayns.getEngine().getFrameBuffer()));
}

#ifdef BRAYNS_USE_NETWORKING
BOOST_AUTO_TEST_CASE(circuit_with_simulation_mapping)
TEST_CASE("circuit_with_simulation_mapping")
{
const std::vector<const char*> argv = {
BBP_TEST_BLUECONFIG3, "--samples-per-pixel", "16", "--animation-frame",
Expand Down Expand Up @@ -122,7 +116,7 @@ BOOST_AUTO_TEST_CASE(circuit_with_simulation_mapping)
clientServer.getBrayns().commit();
modelDesc->getModel().getSimulationHandler()->waitReady();
clientServer.getBrayns().commitAndRender();
BOOST_CHECK(compareTestImage(
CHECK(compareTestImage(
"testdataallmini50basicsimulation.png",
clientServer.getBrayns().getEngine().getFrameBuffer()));

Expand All @@ -143,16 +137,13 @@ BOOST_AUTO_TEST_CASE(circuit_with_simulation_mapping)
brayns::SnapshotParams, brayns::ImageGenerator::ImageBase64>("snapshot",
params);

BOOST_CHECK(compareBase64TestImage(
CHECK(compareBase64TestImage(
image, "testdataallmini50basicsimulation_snapshot.png"));
}
#endif

void testSdfGeometries(bool dampened)
void testSdfGeometries(bool dampened, const char* app)
{
auto& testSuite = boost::unit_test::framework::master_test_suite();

const char* app = testSuite.argv[0];
auto argv = std::vector<const char*>{app,
BBP_TEST_BLUECONFIG3,
"--disable-accumulation",
Expand Down Expand Up @@ -186,17 +177,17 @@ void testSdfGeometries(bool dampened)
camera.setPosition(camPos + 0.92 * (rotCenter - camPos));

brayns.commitAndRender();
BOOST_CHECK(compareTestImage(dampened ? "testDampenedSdfCircuit.png"
: "testSdfCircuit.png",
brayns.getEngine().getFrameBuffer()));
CHECK(compareTestImage(dampened ? "testDampenedSdfCircuit.png"
: "testSdfCircuit.png",
brayns.getEngine().getFrameBuffer()));
}

BOOST_AUTO_TEST_CASE(circuit_with_sdf_geometries)
TEST_CASE("circuit_with_sdf_geometries")
{
testSdfGeometries(false);
testSdfGeometries(false, "circuit_with_sdf_geometries");
}

BOOST_AUTO_TEST_CASE(circuit_with_dampened_sdf_geometries)
TEST_CASE("circuit_with_dampened_sdf_geometries")
{
testSdfGeometries(true);
testSdfGeometries(true, "circuit_with_dampened_sdf_geometries");
}
10 changes: 5 additions & 5 deletions plugins/CircuitViewer/tests/optixCircuit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@

#include <BBP/TestDatasets.h>

#define BOOST_TEST_MODULE optixCircuit
#include <boost/test/unit_test.hpp>
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "tests/doctest.h"

BOOST_AUTO_TEST_CASE(circuit_with_simulation_mapping_optix)
TEST_CASE("circuit_with_simulation_mapping_optix")
{
std::vector<const char*> argv = {
"brayns", BBP_TEST_BLUECONFIG3, "--animation-frame", "50", "--engine",
Expand All @@ -54,6 +54,6 @@ BOOST_AUTO_TEST_CASE(circuit_with_simulation_mapping_optix)
modelDesc->getModel().getSimulationHandler()->waitReady();
brayns.commitAndRender();

BOOST_CHECK(compareTestImage("testdataallmini50basicsimulation_optix.png",
brayns.getEngine().getFrameBuffer()));
CHECK(compareTestImage("testdataallmini50basicsimulation_optix.png",
brayns.getEngine().getFrameBuffer()));
}
32 changes: 15 additions & 17 deletions plugins/CircuitViewer/tests/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

#include "../io/utils.h"

#define BOOST_TEST_MODULE circuitViewerUtils
#include <boost/test/unit_test.hpp>
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "tests/doctest.h"

using GIDSet = brion::GIDSet;
GIDSet keyToGIDorRange(std::string s, const double fraction = 1.f,
Expand All @@ -30,26 +30,24 @@ GIDSet keyToGIDorRange(std::string s, const double fraction = 1.f,
return brayns::_keyToGIDorRange(s, fraction, seed);
}

BOOST_AUTO_TEST_CASE(gids)
TEST_CASE("gids")
{
BOOST_CHECK(keyToGIDorRange("1") == GIDSet{1});
CHECK_EQ(keyToGIDorRange("1"), GIDSet{1});
}

BOOST_AUTO_TEST_CASE(gid_ranges)
TEST_CASE("gid_ranges")
{
BOOST_CHECK(keyToGIDorRange("1-1") == GIDSet{1});
BOOST_CHECK(keyToGIDorRange("1-2") == GIDSet({1, 2}));
BOOST_CHECK_EQUAL(keyToGIDorRange("1-10", 0.5, 0).size(), 5);
BOOST_CHECK_THROW(keyToGIDorRange("1-0"), std::runtime_error);
CHECK_EQ(keyToGIDorRange("1-1"), GIDSet{1});
CHECK_EQ(keyToGIDorRange("1-2"), GIDSet({1, 2}));
CHECK_EQ(keyToGIDorRange("1-10", 0.5, 0).size(), 5);
CHECK_THROWS(keyToGIDorRange("1-0"));
}

BOOST_AUTO_TEST_CASE(invalid)
TEST_CASE("invalid")
{
BOOST_CHECK(keyToGIDorRange("1a").empty());
BOOST_CHECK(keyToGIDorRange("1 a").empty());
BOOST_CHECK(keyToGIDorRange("1a").empty());
BOOST_CHECK(keyToGIDorRange("1-2a").empty());
BOOST_CHECK(keyToGIDorRange("1 1-2").empty());
CHECK(keyToGIDorRange("1a").empty());
CHECK(keyToGIDorRange("1 a").empty());
CHECK(keyToGIDorRange("1a").empty());
CHECK(keyToGIDorRange("1-2a").empty());
CHECK(keyToGIDorRange("1 1-2").empty());
}