From a05d8ba2c6618e833c30d4c6afd0448d72d51755 Mon Sep 17 00:00:00 2001 From: jatin Date: Sat, 8 Jun 2024 00:51:33 -0700 Subject: [PATCH] More tests --- .../chowdsp_data_structures/Structures/chowdsp_EnumMap.h | 4 ++-- .../chowdsp_data_structures_test/EnumMapTest.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/common/chowdsp_data_structures/Structures/chowdsp_EnumMap.h b/modules/common/chowdsp_data_structures/Structures/chowdsp_EnumMap.h index d709180b..3095b583 100644 --- a/modules/common/chowdsp_data_structures/Structures/chowdsp_EnumMap.h +++ b/modules/common/chowdsp_data_structures/Structures/chowdsp_EnumMap.h @@ -1,11 +1,11 @@ #pragma once -#include -#if 1 // JUCE_MODULE_AVAILABLE_chowdsp_reflection +#if JUCE_MODULE_AVAILABLE_chowdsp_reflection #include namespace chowdsp { +/** A map-like container designed to be used with enum keys. */ template struct EnumMap { diff --git a/tests/common_tests/chowdsp_data_structures_test/EnumMapTest.cpp b/tests/common_tests/chowdsp_data_structures_test/EnumMapTest.cpp index fce34f65..cb0051c1 100644 --- a/tests/common_tests/chowdsp_data_structures_test/EnumMapTest.cpp +++ b/tests/common_tests/chowdsp_data_structures_test/EnumMapTest.cpp @@ -45,11 +45,13 @@ TEST_CASE ("Enum Map Test", "[common][data-structures]") chowdsp::EnumMap map {}; map.insert_or_assign (Food::Apple, 22); map.emplace (Food::Green_Beans, 23); + map.emplace (Food::Egg); REQUIRE (! map.empty()); - REQUIRE (map.size() == 2); + REQUIRE (map.size() == 3); REQUIRE (*map.at (Food::Apple) == 22); REQUIRE (map[Food::Green_Beans] == 23); + REQUIRE (map[Food::Egg] == 0); REQUIRE (*std::as_const (map).at (Food::Apple) == 22); REQUIRE (std::as_const (map)[Food::Green_Beans] == 23); REQUIRE (map.at (Food::Banana) == std::nullopt); @@ -59,6 +61,9 @@ TEST_CASE ("Enum Map Test", "[common][data-structures]") REQUIRE (map.contains (Food::Apple)); REQUIRE (! map.contains (Food::Green_Beans)); + + map.clear(); + REQUIRE (map.empty()); } SECTION ("Iteration")