-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// DynaMix | ||
// Copyright (c) 2013-2017 Borislav Stanimirov, Zahary Karadjov | ||
// | ||
// Distributed under the MIT Software License | ||
// See accompanying file LICENSE.txt or copy at | ||
// https://opensource.org/licenses/MIT | ||
// | ||
#include <dynamix/dynamix.hpp> | ||
|
||
#include "mutation_rules/test_mixins.hpp" | ||
|
||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN | ||
#include "doctest/doctest.h" | ||
|
||
TEST_SUITE("obj optional metrics"); | ||
|
||
using namespace dynamix; | ||
|
||
TEST_CASE("metrics") | ||
{ | ||
object o1; | ||
|
||
auto& mta = _dynamix_get_mixin_type_info((a*)(nullptr)); | ||
auto& mtb = _dynamix_get_mixin_type_info((b*)(nullptr)); | ||
auto& mtc = _dynamix_get_mixin_type_info((c*)(nullptr)); | ||
|
||
CHECK(mta.num_mixins == 0); | ||
CHECK(mtb.num_mixins == 0); | ||
CHECK(mtc.num_mixins == 0); | ||
|
||
mutate(o1) | ||
.add<a>() | ||
.add<b>(); | ||
|
||
auto t1 = o1._type_info; | ||
|
||
CHECK(t1->num_objects == 1); | ||
CHECK(mta.num_mixins == 1); | ||
CHECK(mtb.num_mixins == 1); | ||
CHECK(mtc.num_mixins == 0); | ||
|
||
o1.clear(); | ||
|
||
CHECK(t1->num_objects == 0); | ||
CHECK(mta.num_mixins == 0); | ||
CHECK(mtb.num_mixins == 0); | ||
CHECK(mtc.num_mixins == 0); | ||
|
||
object o2; | ||
|
||
mutate(o2) | ||
.add<a>() | ||
.add<b>(); | ||
|
||
CHECK(t1->num_objects == 1); | ||
CHECK(mta.num_mixins == 1); | ||
CHECK(mtb.num_mixins == 1); | ||
CHECK(mtc.num_mixins == 0); | ||
|
||
mutate(o1) | ||
.add<a>() | ||
.add<b>(); | ||
|
||
CHECK(t1->num_objects == 2); | ||
CHECK(mta.num_mixins == 2); | ||
CHECK(mtb.num_mixins == 2); | ||
CHECK(mtc.num_mixins == 0); | ||
|
||
mutate(o1) | ||
.remove<a>() | ||
.add<c>(); | ||
|
||
auto t2 = o1._type_info; | ||
|
||
CHECK(t1->num_objects == 1); | ||
CHECK(t2->num_objects == 1); | ||
CHECK(mta.num_mixins == 1); | ||
CHECK(mtb.num_mixins == 2); | ||
CHECK(mtc.num_mixins == 1); | ||
|
||
} | ||
|