25#ifndef LSST_AFW_TYPEHANDLING_TEST_H
26#define LSST_AFW_TYPEHANDLING_TEST_H
28#define BOOST_TEST_DYN_LINK
29#pragma clang diagnostic push
30#pragma clang diagnostic ignored "-Wunused-variable"
31#include "boost/test/unit_test.hpp"
32#pragma clang diagnostic pop
40#include <boost/mpl/list.hpp>
49namespace typehandling {
60class SimpleStorable :
public Storable {
62 virtual ~SimpleStorable() =
default;
66 std::string toString()
const override {
return "Simplest possible representation"; }
68 bool equals(
Storable const& other)
const noexcept override {
return singleClassEquals(*
this, other); }
69 virtual bool operator==(SimpleStorable
const& other)
const {
return true; }
70 bool operator!=(SimpleStorable
const& other)
const {
return !(*
this == other); }
73class ComplexStorable final :
public SimpleStorable {
75 constexpr ComplexStorable(
double storage) : SimpleStorable(), storage(storage) {}
77 ComplexStorable& operator=(
double newValue) {
83 return std::make_unique<ComplexStorable>(storage);
91 bool equals(
Storable const& other)
const noexcept override {
92 auto complexOther =
dynamic_cast<ComplexStorable const*
>(&other);
94 return this->storage == complexOther->storage;
99 bool operator==(SimpleStorable
const& other)
const override {
return this->equals(other); }
115auto const KEY0 = makeKey<bool>(0);
116bool const VALUE0 =
true;
117auto const KEY1 = makeKey<int>(1);
118int const VALUE1 = 42;
119auto const KEY2 = makeKey<double>(2);
120int const VALUE2 = VALUE1;
121auto const KEY3 = makeKey<std::string>(3);
122std::string const VALUE3 =
"How many roads must a man walk down?";
123auto const KEY4 = makeKey<std::shared_ptr<SimpleStorable const>>(4);
124auto const VALUE4 = SimpleStorable();
125auto const KEY5 = makeKey<ComplexStorable>(5);
126auto const VALUE5 = ComplexStorable(-100.0);
127auto const KEY6 = makeKey<std::shared_ptr<Storable const>>(6);
156 static GenericMapFactory
const factory;
159 BOOST_TEST(demoMap->at(KEY0) == VALUE0);
160 BOOST_TEST(demoMap->at(KEY1) == VALUE1);
161 BOOST_TEST(demoMap->at(KEY2) == VALUE2);
162 BOOST_TEST(demoMap->at(KEY3) == VALUE3);
163 BOOST_TEST(*(demoMap->at(KEY4)) == VALUE4);
164 BOOST_TEST(demoMap->at(KEY5) == VALUE5);
165 BOOST_TEST(demoMap->at(KEY6) == VALUE6);
169 using namespace std::string_literals;
171 static GenericMapFactory
const factory;
174 BOOST_TEST(demoMap->at(KEY0) == VALUE0);
175 demoMap->at(KEY0) =
false;
176 BOOST_TEST(demoMap->at(KEY0) ==
false);
179 BOOST_TEST(demoMap->at(KEY1) == VALUE1);
181 BOOST_TEST(demoMap->at(KEY1) == VALUE1 + 1);
184 BOOST_TEST(demoMap->at(KEY2) == VALUE2);
185 demoMap->at(KEY2) = 0.0;
186 BOOST_TEST(demoMap->at(KEY2) == 0.0);
188 using Type2 = std::remove_const_t<
decltype(VALUE2)>;
191 BOOST_TEST(demoMap->at(KEY3) == VALUE3);
192 demoMap->at(KEY3).append(
" Oops, wrong question."s);
193 BOOST_TEST(demoMap->at(KEY3) == VALUE3 +
" Oops, wrong question."s);
195 BOOST_TEST(*(demoMap->at(KEY4)) == VALUE4);
197 using Type4 = std::remove_const_t<
decltype(VALUE4)>;
200 BOOST_TEST(demoMap->at(KEY5) == VALUE5);
201 BOOST_TEST(demoMap->at(makeKey<SimpleStorable>(KEY5.getId())) == VALUE5);
203 ComplexStorable newValue(5.0);
204 demoMap->at(KEY5) = newValue;
205 BOOST_TEST(demoMap->at(KEY5) == newValue);
207 BOOST_TEST(demoMap->at(KEY6) == VALUE6);
211 static GenericMapFactory
const factory;
212 auto map1 = factory.makeGenericMap();
215 BOOST_CHECK(*map1 == *map1);
217 BOOST_CHECK(*map1 != *(factory.makeGenericMap()));
221 static GenericMapFactory
const factory;
227 auto bruteForcePrinter = [&map](
int key) {
230 return universalToString(map->at(KEY0));
232 return universalToString(map->at(KEY1));
234 return universalToString(map->at(KEY2));
236 return universalToString(map->at(KEY3));
238 return universalToString(map->at(KEY4));
240 return universalToString(map->at(KEY5));
242 return universalToString(map->at(KEY6));
248 for (
int key : mapKeys) {
249 expected.
push_back(bruteForcePrinter(key));
258 void operator()(
int,
bool value) { results.push_back(universalToString(value)); }
259 void operator()(
int,
int const& value) { results.push_back(universalToString(value)); }
260 void operator()(
int,
long value) { results.push_back(universalToString(value)); }
261 void operator()(
int,
long long value) { results.push_back(universalToString(value)); }
262 void operator()(
int,
float const& value) { results.push_back(universalToString(value)); }
263 void operator()(
int,
double value) { results.push_back(universalToString(value)); }
264 void operator()(
int,
std::string const& value) { results.push_back(universalToString(value)); }
265 void operator()(
int,
Storable const& value) { results.push_back(universalToString(value)); }
267 results.push_back(universalToString(value));
271 BOOST_REQUIRE(printer.results.size() == expected.
size());
272 for (
std::size_t i = 0; i < printer.results.size(); ++i) {
273 BOOST_TEST(printer.results[i] == expected[i],
274 printer.results[i] <<
" != " << expected[i] <<
", key = " << mapKeys[i]);
279 map->apply([](
int,
auto const& value) {
return universalToString(value); });
280 BOOST_REQUIRE(strings.
size() == expected.
size());
282 BOOST_TEST(strings[i] == expected[i],
283 strings[i] <<
" != " << expected[i] <<
", key = " << mapKeys[i]);
288 static GenericMapFactory
const factory;
296 void operator()(
int,
bool& value) { value = !value; }
297 void operator()(
int,
int& value) { value *= 2; }
298 void operator()(
int,
long& value) { value *= 2; }
299 void operator()(
int,
long long& value) { value *= 2; }
300 void operator()(
int,
float& value) { value *= 2; }
301 void operator()(
int,
double& value) { value *= 2; }
302 void operator()(
int,
std::string& value) { value +=
"Appendix"; }
303 void operator()(
int,
Storable& value) {
304 auto complexStorable =
dynamic_cast<ComplexStorable*
>(&value);
305 if (complexStorable !=
nullptr) {
306 *complexStorable = 42;
314 BOOST_TEST(newKeys == originalKeys);
315 BOOST_TEST(map->at(KEY0) == !VALUE0);
316 BOOST_TEST(map->at(KEY1) == 2 * VALUE1);
317 BOOST_TEST(map->at(KEY2) == 2 * VALUE2);
318 BOOST_TEST(map->at(KEY3) == VALUE3 +
"Appendix");
319 BOOST_TEST(*(map->at(KEY4)) == VALUE4);
320 BOOST_TEST(map->at(KEY5) != VALUE5);
321 BOOST_TEST(map->at(KEY5) == ComplexStorable(42));
322 BOOST_TEST(map->at(KEY6) ==
nullptr);
326 static GenericMapFactory
const factory;
334 int operator()(
int key,
bool& value) {
338 int operator()(
int key,
int& value) {
342 int operator()(
int key,
long& value) {
346 int operator()(
int key,
long long& value) {
350 int operator()(
int key,
float& value) {
354 int operator()(
int key,
double& value) {
362 int operator()(
int key,
Storable& value) {
363 auto complexStorable =
dynamic_cast<ComplexStorable*
>(&value);
364 if (complexStorable !=
nullptr) {
365 *complexStorable = 42;
372 BOOST_TEST(editedKeys == originalKeys);
375 BOOST_TEST(newKeys == originalKeys);
376 BOOST_TEST(map->at(KEY0) == !VALUE0);
377 BOOST_TEST(map->at(KEY1) == 2 * VALUE1);
378 BOOST_TEST(map->at(KEY2) == 2 * VALUE2);
379 BOOST_TEST(map->at(KEY3) == VALUE3 +
"Appendix");
380 BOOST_TEST(*(map->at(KEY4)) == VALUE4);
381 BOOST_TEST(map->at(KEY5) != VALUE5);
382 BOOST_TEST(map->at(KEY5) == ComplexStorable(42));
383 BOOST_TEST(map->at(KEY6) ==
nullptr);
387 using namespace std::string_literals;
389 static GenericMapFactory
const factory;
390 auto map1 = factory.makeMutableGenericMap();
391 auto map2 = factory.makeMutableGenericMap();
394 BOOST_CHECK(*map1 == *map2);
396 auto primitiveKey = makeKey<int>(
"primitive"s);
397 map1->insert(primitiveKey, 42);
398 BOOST_CHECK(*map1 != *map2);
399 map2->insert(primitiveKey, 42);
400 BOOST_CHECK(*map1 == *map2);
402 auto sharedKey = makeKey<std::shared_ptr<SimpleStorable const>>(
"shared"s);
403 auto common = std::make_shared<SimpleStorable const>(VALUE4);
404 map1->insert(sharedKey, common);
405 BOOST_CHECK(*map1 != *map2);
406 map2->insert(sharedKey, std::make_shared<SimpleStorable const>(VALUE4));
407 BOOST_CHECK(*map1 != *map2);
408 map2->erase(sharedKey);
409 map2->insert(sharedKey, common);
410 BOOST_CHECK(*map1 == *map2);
412 auto storableKey = makeKey<ComplexStorable>(
"storable"s);
413 map1->insert(storableKey, VALUE5);
414 BOOST_CHECK(*map1 != *map2);
415 map2->insert(storableKey, VALUE5);
416 BOOST_CHECK(*map1 == *map2);
418 auto nullKey = makeKey<std::shared_ptr<ComplexStorable const>>(
"null"s);
419 map1->insert(nullKey, std::static_pointer_cast<ComplexStorable const>(VALUE6));
420 BOOST_CHECK(*map1 != *map2);
421 map2->insert(nullKey, std::static_pointer_cast<ComplexStorable const>(VALUE6));
422 BOOST_CHECK(*map1 == *map2);
426 static GenericMapFactory
const factory;
429 BOOST_TEST(demoMap->size() == 7);
430 BOOST_TEST(!demoMap->empty());
434 using namespace std::string_literals;
436 static GenericMapFactory
const factory;
439 BOOST_TEST_REQUIRE(demoMap->size() == 0);
440 BOOST_TEST_REQUIRE(demoMap->empty());
442 demoMap->insert(makeKey<int>(
"Negative One"s), -1);
443 BOOST_TEST(demoMap->size() == 1);
444 BOOST_TEST(!demoMap->empty());
446 demoMap->erase(makeKey<int>(
"Negative One"s));
447 BOOST_TEST(demoMap->size() == 0);
448 BOOST_TEST(demoMap->empty());
452 using namespace std::string_literals;
454 static GenericMapFactory
const factory;
457 BOOST_TEST(demoMap->contains(KEY0.getId()));
458 BOOST_TEST(demoMap->contains(KEY1.getId()));
459 BOOST_TEST(demoMap->contains(KEY2.getId()));
460 BOOST_TEST(demoMap->contains(KEY3.getId()));
461 BOOST_TEST(demoMap->contains(KEY4.getId()));
462 BOOST_TEST(demoMap->contains(KEY5.getId()));
463 BOOST_TEST(demoMap->contains(KEY6.getId()));
467 static GenericMapFactory
const factory;
470 BOOST_TEST(demoMap->contains(KEY0));
471 BOOST_TEST(!demoMap->contains(makeKey<int>(KEY0.getId())));
473 BOOST_TEST(demoMap->contains(KEY1));
474 BOOST_TEST(!demoMap->contains(makeKey<bool>(KEY1.getId())));
476 BOOST_TEST(demoMap->contains(KEY2));
478 BOOST_TEST(!demoMap->contains(
makeKey<
decltype(VALUE2)>(KEY2.getId())));
480 BOOST_TEST(demoMap->contains(KEY3));
482 BOOST_TEST(demoMap->contains(KEY4));
484 BOOST_TEST(!demoMap->contains(
makeKey<
decltype(VALUE4)>(KEY4.getId())));
486 BOOST_TEST(demoMap->contains(KEY5));
487 BOOST_TEST(demoMap->contains(makeKey<SimpleStorable>(KEY5.getId())));
488 BOOST_TEST(demoMap->contains(makeKey<Storable>(KEY5.getId())));
490 BOOST_TEST(demoMap->contains(KEY6));
496 static GenericMapFactory
const factory;
498 auto orderedKeys = demoMap->keys();
502 BOOST_TEST(keys ==
std::set<int>({KEY0.getId(), KEY1.getId(), KEY2.getId(), KEY3.getId(), KEY4.getId(),
503 KEY5.getId(), KEY6.getId()}));
507 static GenericMapFactory
const factory;
509 auto keys = demoMap->keys();
512 demoMap->apply([&iterOrder](
int key,
auto value) { iterOrder.
push_back(key); });
513 BOOST_TEST(keys == iterOrder);
517 static GenericMapFactory
const factory;
520 BOOST_TEST_REQUIRE(demoMap->empty());
522 BOOST_TEST(demoMap->empty());
526 using namespace std::string_literals;
528 static GenericMapFactory
const factory;
531 demoMap->insert(makeKey<int>(
"prime"s), 3);
532 demoMap->insert(makeKey<std::string>(
"foo"s),
"bar"s);
534 BOOST_TEST_REQUIRE(!demoMap->empty());
536 BOOST_TEST(demoMap->empty());
540 using namespace std::string_literals;
542 static GenericMapFactory
const factory;
545 BOOST_TEST_REQUIRE(demoMap->empty());
548 BOOST_TEST(demoMap->insert(makeKey<int>(
"cube"s),
x) ==
true);
549 BOOST_TEST(demoMap->insert(makeKey<int>(
"cube"s), 0) ==
false);
551 BOOST_TEST(!demoMap->empty());
552 BOOST_TEST(demoMap->size() == 1);
553 BOOST_TEST(demoMap->contains(
"cube"s));
554 BOOST_TEST(demoMap->contains(makeKey<int>(
"cube"s)));
555 BOOST_TEST(!demoMap->contains(makeKey<double>(
"cube"s)));
556 BOOST_TEST(demoMap->at(makeKey<int>(
"cube"s)) ==
x);
559 BOOST_TEST(demoMap->at(makeKey<int>(
"cube"s)) !=
x);
561 demoMap->at(makeKey<int>(
"cube"s)) = 0;
562 BOOST_TEST(demoMap->at(makeKey<int>(
"cube"s)) == 0);
566 using namespace std::string_literals;
568 static GenericMapFactory
const factory;
571 BOOST_TEST_REQUIRE(demoMap->empty());
573 auto insertResult = demoMap->insert(
"cube"s, 27);
574 BOOST_TEST(insertResult.second ==
true);
575 BOOST_TEST(demoMap->insert(
"cube"s, 0).second ==
false);
577 BOOST_TEST(!demoMap->empty());
578 BOOST_TEST(demoMap->size() == 1);
579 BOOST_TEST(demoMap->contains(
"cube"s));
580 BOOST_TEST(demoMap->contains(insertResult.first));
581 BOOST_TEST(demoMap->contains(makeKey<int>(
"cube"s)));
582 BOOST_TEST(!demoMap->contains(makeKey<double>(
"cube"s)));
583 BOOST_TEST(demoMap->at(insertResult.first) == 27);
584 BOOST_TEST(demoMap->at(makeKey<int>(
"cube"s)) == 27);
586 demoMap->at(insertResult.first) = 0;
587 BOOST_TEST(demoMap->at(insertResult.first) == 0);
591 using namespace std::string_literals;
593 static GenericMapFactory
const factory;
596 BOOST_TEST_REQUIRE(demoMap->empty());
599 "I have a most elegant and wonderful proof, but this string is too small to contain it."s);
600 BOOST_TEST(demoMap->insert(makeKey<std::string>(
"Ultimate answer"s), answer) ==
true);
601 BOOST_TEST(demoMap->insert(makeKey<std::string>(
"OK"s),
"Ook!"s) ==
true);
602 BOOST_TEST(demoMap->insert(makeKey<std::string>(
"Ultimate answer"s),
"Something philosophical"s) ==
605 BOOST_TEST(!demoMap->empty());
606 BOOST_TEST(demoMap->size() == 2);
607 BOOST_TEST(demoMap->contains(
"OK"s));
608 BOOST_TEST(demoMap->contains(makeKey<std::string>(
"Ultimate answer"s)));
609 BOOST_TEST(demoMap->at(makeKey<std::string>(
"Ultimate answer"s)) == answer);
610 BOOST_TEST(demoMap->at(makeKey<std::string>(
"OK"s)) ==
"Ook!"s);
612 answer =
"I don't know"s;
613 BOOST_TEST(demoMap->at(makeKey<std::string>(
"Ultimate answer"s)) != answer);
617 using namespace std::string_literals;
619 static GenericMapFactory
const factory;
622 BOOST_TEST_REQUIRE(demoMap->empty());
624 auto insertResult1 = demoMap->insert(
"Ultimate answer"s,
"Something philosophical"s);
625 BOOST_TEST(insertResult1.second ==
true);
626 auto insertResult2 = demoMap->insert(
"OK"s,
"Ook!"s);
627 BOOST_TEST(insertResult2.second ==
true);
629 BOOST_TEST(!demoMap->empty());
630 BOOST_TEST(demoMap->size() == 2);
631 BOOST_TEST(demoMap->contains(insertResult1.first));
632 BOOST_TEST(demoMap->contains(insertResult2.first));
633 BOOST_TEST(demoMap->contains(
"OK"s));
634 BOOST_TEST(demoMap->contains(makeKey<std::string>(
"Ultimate answer"s)));
635 BOOST_TEST(demoMap->at(insertResult1.first) ==
"Something philosophical"s);
636 BOOST_TEST(demoMap->at(makeKey<std::string>(
"Ultimate answer"s)) ==
"Something philosophical"s);
637 BOOST_TEST(demoMap->at(insertResult2.first) ==
"Ook!"s);
638 BOOST_TEST(demoMap->at(makeKey<std::string>(
"OK"s)) ==
"Ook!"s);
642 using namespace std::string_literals;
644 static GenericMapFactory
const factory;
647 BOOST_TEST_REQUIRE(demoMap->empty());
649 ComplexStorable
object(3.1416);
650 BOOST_TEST(demoMap->insert<
Storable>(makeKey<Storable>(
"foo"s),
object) ==
true);
652 std::make_shared<ComplexStorable const>(3.141)) ==
true);
653 BOOST_TEST(demoMap->insert<
Storable>(makeKey<Storable>(
"foo"s), SimpleStorable()) ==
false);
655 std::make_shared<SimpleStorable const>()) ==
false);
657 std::make_shared<SimpleStorable const>()) ==
true);
659 BOOST_TEST(!demoMap->empty());
660 BOOST_TEST(demoMap->size() == 3);
661 BOOST_TEST(demoMap->contains(
"foo"s));
662 BOOST_TEST(demoMap->contains(makeKey<Storable>(
"foo"s)));
667 BOOST_TEST(
object == demoMap->at(makeKey<SimpleStorable>(
"foo"s)));
668 object = ComplexStorable(1.4);
669 BOOST_TEST(
object != demoMap->at(makeKey<SimpleStorable>(
"foo"s)));
671 ComplexStorable(3.141));
675 using namespace std::string_literals;
677 static GenericMapFactory
const factory;
680 BOOST_TEST_REQUIRE(demoMap->empty());
682 BOOST_TEST(demoMap->insert(makeKey<int>(
"key1"s), 3) ==
true);
683 BOOST_TEST(demoMap->insert(makeKey<double>(
"key1"s), 1.0) ==
false);
684 BOOST_TEST(demoMap->insert<
Storable>(makeKey<Storable>(
"key2"s), SimpleStorable()) ==
true);
685 BOOST_TEST(demoMap->insert(makeKey<std::string>(
"key3"s),
"Test value"s) ==
true);
686 BOOST_TEST(demoMap->insert(makeKey<std::string>(
"key4"s),
"This is some text"s) ==
true);
687 std::string const message =
"Unknown value for key5."s;
688 BOOST_TEST(demoMap->insert(makeKey<std::string>(
"key5"s), message) ==
true);
689 BOOST_TEST(demoMap->insert(makeKey<int>(
"key3"s), 20) ==
false);
690 BOOST_TEST(demoMap->insert<
double>(makeKey<double>(
"key6"s), 42) ==
true);
692 BOOST_TEST(!demoMap->empty());
693 BOOST_TEST(demoMap->size() == 6);
694 BOOST_TEST(demoMap->at(makeKey<int>(
"key1"s)) == 3);
695 BOOST_TEST(demoMap->at(makeKey<double>(
"key6"s)) == 42);
696 BOOST_TEST(demoMap->at(makeKey<SimpleStorable>(
"key2"s)) == SimpleStorable());
697 BOOST_TEST(demoMap->at(makeKey<std::string>(
"key3"s)) ==
"Test value"s);
698 BOOST_TEST(demoMap->at(makeKey<std::string>(
"key4"s)) ==
"This is some text"s);
699 BOOST_TEST(demoMap->at(makeKey<std::string>(
"key5"s)) == message);
703 using namespace std::string_literals;
705 static GenericMapFactory
const factory;
708 demoMap->insert(makeKey<int>(
"Ultimate answer"s), 42);
709 BOOST_TEST_REQUIRE(demoMap->size() == 1);
711 BOOST_TEST(demoMap->erase(makeKey<std::string>(
"Ultimate answer"s)) ==
false);
712 BOOST_TEST(demoMap->size() == 1);
713 BOOST_TEST(demoMap->erase(makeKey<int>(
"Ultimate answer"s)) ==
true);
714 BOOST_TEST(demoMap->size() == 0);
718 using namespace std::string_literals;
720 static GenericMapFactory
const factory;
723 BOOST_TEST_REQUIRE(demoMap->empty());
725 BOOST_TEST(demoMap->insert(makeKey<int>(
"Ultimate answer"s), 42) ==
true);
726 BOOST_TEST(demoMap->insert(makeKey<int>(
"OK"s), 200) ==
true);
727 BOOST_TEST(demoMap->erase(makeKey<int>(
"Ultimate answer"s)) ==
true);
728 BOOST_TEST(demoMap->insert(makeKey<double>(
"Ultimate answer"s), 3.1415927) ==
true);
730 BOOST_TEST(!demoMap->empty());
731 BOOST_TEST(demoMap->size() == 2);
732 BOOST_TEST(demoMap->contains(
"OK"s));
733 BOOST_TEST(!demoMap->contains(makeKey<int>(
"Ultimate answer"s)));
734 BOOST_TEST(demoMap->contains(makeKey<double>(
"Ultimate answer"s)));
735 BOOST_TEST(demoMap->at(makeKey<double>(
"Ultimate answer"s)) == 3.1415927);
745template <
class GenericMapFactory>
747 using factories = boost::mpl::list<GenericMapFactory>;
749 suite->add(BOOST_TEST_CASE_TEMPLATE(TestConstAt, factories));
750 suite->add(BOOST_TEST_CASE_TEMPLATE(TestAt, factories));
751 suite->add(BOOST_TEST_CASE_TEMPLATE(TestEquals, factories));
752 suite->add(BOOST_TEST_CASE_TEMPLATE(TestSize, factories));
753 suite->add(BOOST_TEST_CASE_TEMPLATE(TestWeakContains, factories));
754 suite->add(BOOST_TEST_CASE_TEMPLATE(TestContains, factories));
755 suite->add(BOOST_TEST_CASE_TEMPLATE(TestKeys, factories));
756 suite->add(BOOST_TEST_CASE_TEMPLATE(TestKeyOrder, factories));
757 suite->add(BOOST_TEST_CASE_TEMPLATE(TestConstVisitor, factories));
758 suite->add(BOOST_TEST_CASE_TEMPLATE(TestModifyingVoidVisitor, factories));
759 suite->add(BOOST_TEST_CASE_TEMPLATE(TestModifyingReturningVisitor, factories));
771template <
class GenericMapFactory>
773 using factories = boost::mpl::list<GenericMapFactory>;
775 addGenericMapTestCases<GenericMapFactory>(suite);
777 suite->add(BOOST_TEST_CASE_TEMPLATE(TestMutableEquals, factories));
778 suite->add(BOOST_TEST_CASE_TEMPLATE(TestMutableSize, factories));
779 suite->add(BOOST_TEST_CASE_TEMPLATE(TestClear, factories));
780 suite->add(BOOST_TEST_CASE_TEMPLATE(TestClearIdempotent, factories));
781 suite->add(BOOST_TEST_CASE_TEMPLATE(TestInsertInt, factories));
782 suite->add(BOOST_TEST_CASE_TEMPLATE(TestInsertString, factories));
783 suite->add(BOOST_TEST_CASE_TEMPLATE(TestInsertStorable, factories));
784 suite->add(BOOST_TEST_CASE_TEMPLATE(TestInterleavedInserts, factories));
785 suite->add(BOOST_TEST_CASE_TEMPLATE(TestErase, factories));
786 suite->add(BOOST_TEST_CASE_TEMPLATE(TestInsertEraseInsert, factories));
797template <
class GenericMapFactory>
799 addGenericMapTestCases<GenericMapFactory>(&(boost::unit_test::framework::master_test_suite()));
811template <
class GenericMapFactory>
813 addMutableGenericMapTestCases<GenericMapFactory>(&(boost::unit_test::framework::master_test_suite()));
table::Key< std::string > object
Interface supporting iteration over heterogenous containers.
Abstract factory that creates GenericMap and MutableGenericMap instances as needed.
virtual std::unique_ptr< GenericMap< int > > makeGenericMap() const =0
Create a map containing the following state:
virtual std::unique_ptr< MutableGenericMap< std::string > > makeMutableGenericMap() const =0
Create an empty map.
virtual ~GenericFactory()=default
Reports attempts to access elements outside a valid range of indices.
void addMutableGenericMapTestCases()
Create generic test cases for a specific MutableGenericMap implementation.
void addGenericMapTestCases()
Create generic test cases for a specific GenericMap implementation.
BOOST_TEST_CASE_TEMPLATE_FUNCTION(TestConstAt, GenericMapFactory)
constexpr Key< K, V > makeKey(K const &id)
Factory function for Key, to enable type parameter inference.