From 0a2793c64280c1ae6a18dd8f2f9b5a789e863f09 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 16 Aug 2017 21:48:33 +0100 Subject: Assert behaviour of ModelPartForClass::GetTypeId with a non-local class --- slicer/test/compilation.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/slicer/test/compilation.cpp b/slicer/test/compilation.cpp index bea08a5..0ba6b11 100644 --- a/slicer/test/compilation.cpp +++ b/slicer/test/compilation.cpp @@ -140,3 +140,35 @@ BOOST_AUTO_TEST_CASE( compile_auto_modelpart_type_enum ) BOOST_REQUIRE_EQUAL(mpp.get(), mpp->GetContainedModelPart().get()); } +BOOST_AUTO_TEST_CASE( normalClassTypeId ) +{ + TestModule::BasePtr base = new TestModule::Base(1); + BOOST_REQUIRE(base); + auto a = Slicer::ModelPart::CreateFor(base); + BOOST_REQUIRE(a); + auto baseType = a->GetTypeId(); + BOOST_REQUIRE(!baseType); +} + +BOOST_AUTO_TEST_CASE( normalSubClassTypeId ) +{ + TestModule::BasePtr base = new TestModule::D1(1, 2); + BOOST_REQUIRE(base); + auto a = Slicer::ModelPart::CreateFor(base); + BOOST_REQUIRE(a); + auto baseType = a->GetTypeId(); + BOOST_REQUIRE(baseType); + BOOST_REQUIRE_EQUAL(*baseType, "::TestModule::D1"); +} + +BOOST_AUTO_TEST_CASE( normalSubSubClassTypeId ) +{ + TestModule::BasePtr base = new TestModule::D3(1, 2, 3); + BOOST_REQUIRE(base); + auto a = Slicer::ModelPart::CreateFor(base); + BOOST_REQUIRE(a); + auto baseType = a->GetTypeId(); + BOOST_REQUIRE(baseType); + BOOST_REQUIRE_EQUAL(*baseType, "::TestModule::D3"); +} + -- cgit v1.2.3