@@ -937,6 +937,100 @@ TEST(EngineTest, CompileFunctions)
937937 ASSERT_EQ (container2->resolveBlockCompileFunc (" test2" ), &compileTest2);
938938}
939939
940+ TEST (EngineTest, HatPredicateCompileFunctions)
941+ {
942+ Engine engine;
943+
944+ auto section1 = std::make_shared<BlockSectionMock>();
945+ EXPECT_CALL (*section1, registerBlocks);
946+ engine.registerSection (section1);
947+ auto container1 = engine.blockSectionContainer (section1.get ());
948+
949+ auto section2 = std::make_shared<BlockSectionMock>();
950+ EXPECT_CALL (*section2, registerBlocks);
951+ engine.registerSection (section2);
952+ auto container2 = engine.blockSectionContainer (section2.get ());
953+
954+ BlockSectionMock section3;
955+
956+ engine.addHatPredicateCompileFunction (section1.get (), " test1" , &compileTest1);
957+ engine.addHatPredicateCompileFunction (section2.get (), " test2" , &compileTest2);
958+ engine.addHatPredicateCompileFunction (section1.get (), " test1" , &compileTest1);
959+ engine.addHatPredicateCompileFunction (§ion3, " test1" , &compileTest1);
960+
961+ ASSERT_EQ (container1->resolveHatPredicateCompileFunc (" test1" ), &compileTest1);
962+ ASSERT_EQ (container1->resolveHatPredicateCompileFunc (" test2" ), nullptr );
963+ ASSERT_EQ (container2->resolveHatPredicateCompileFunc (" test1" ), nullptr );
964+ ASSERT_EQ (container2->resolveHatPredicateCompileFunc (" test2" ), &compileTest2);
965+ }
966+
967+ TEST (EngineTest, MonitorNameFunctions)
968+ {
969+ Engine engine;
970+
971+ auto section1 = std::make_shared<BlockSectionMock>();
972+ EXPECT_CALL (*section1, registerBlocks);
973+ engine.registerSection (section1);
974+ auto container1 = engine.blockSectionContainer (section1.get ());
975+
976+ auto section2 = std::make_shared<BlockSectionMock>();
977+ EXPECT_CALL (*section2, registerBlocks);
978+ engine.registerSection (section2);
979+ auto container2 = engine.blockSectionContainer (section2.get ());
980+
981+ BlockSectionMock section3;
982+
983+ MonitorNameFunc f1 = [](Block *) -> const std::string & {
984+ static const std::string ret;
985+ return ret;
986+ };
987+
988+ MonitorNameFunc f2 = [](Block *) -> const std::string & {
989+ static const std::string ret;
990+ return ret;
991+ };
992+
993+ engine.addMonitorNameFunction (section1.get (), " test1" , f1);
994+ engine.addMonitorNameFunction (section2.get (), " test2" , f2);
995+ engine.addMonitorNameFunction (section1.get (), " test1" , f1);
996+ engine.addMonitorNameFunction (§ion3, " test1" , f1);
997+
998+ ASSERT_EQ (container1->resolveMonitorNameFunc (" test1" ), f1);
999+ ASSERT_EQ (container1->resolveMonitorNameFunc (" test2" ), nullptr );
1000+ ASSERT_EQ (container2->resolveMonitorNameFunc (" test1" ), nullptr );
1001+ ASSERT_EQ (container2->resolveMonitorNameFunc (" test2" ), f2);
1002+ }
1003+
1004+ TEST (EngineTest, MonitorChangeFunctions)
1005+ {
1006+ Engine engine;
1007+
1008+ auto section1 = std::make_shared<BlockSectionMock>();
1009+ EXPECT_CALL (*section1, registerBlocks);
1010+ engine.registerSection (section1);
1011+ auto container1 = engine.blockSectionContainer (section1.get ());
1012+
1013+ auto section2 = std::make_shared<BlockSectionMock>();
1014+ EXPECT_CALL (*section2, registerBlocks);
1015+ engine.registerSection (section2);
1016+ auto container2 = engine.blockSectionContainer (section2.get ());
1017+
1018+ BlockSectionMock section3;
1019+
1020+ MonitorChangeFunc f1 = [](Block *, const Value &) {};
1021+ MonitorChangeFunc f2 = [](Block *, const Value &) {};
1022+
1023+ engine.addMonitorChangeFunction (section1.get (), " test1" , f1);
1024+ engine.addMonitorChangeFunction (section2.get (), " test2" , f2);
1025+ engine.addMonitorChangeFunction (section1.get (), " test1" , f1);
1026+ engine.addMonitorChangeFunction (§ion3, " test1" , f1);
1027+
1028+ ASSERT_EQ (container1->resolveMonitorChangeFunc (" test1" ), f1);
1029+ ASSERT_EQ (container1->resolveMonitorChangeFunc (" test2" ), nullptr );
1030+ ASSERT_EQ (container2->resolveMonitorChangeFunc (" test1" ), nullptr );
1031+ ASSERT_EQ (container2->resolveMonitorChangeFunc (" test2" ), f2);
1032+ }
1033+
9401034TEST (EngineTest, HatBlocks)
9411035{
9421036 Engine engine;
@@ -1040,7 +1134,7 @@ TEST(EngineTest, FieldValues)
10401134
10411135 engine.addFieldValue (section1.get (), " value1" , 1 );
10421136 engine.addFieldValue (section2.get (), " value2" , 2 );
1043- engine.addFieldValue (section1.get (), " value1" , 3 ); // change ID of existing field
1137+ engine.addFieldValue (section1.get (), " value1" , 3 ); // change ID of existing field value
10441138 engine.addFieldValue (§ion3, " value3" , 4 );
10451139
10461140 ASSERT_EQ (container1->resolveFieldValue (" value1" ), 3 );
0 commit comments