From dc7901793d5fa81327cf620e9b8e9b072e85c2d6 Mon Sep 17 00:00:00 2001 From: Jamiras Date: Mon, 18 Mar 2019 18:41:41 -0600 Subject: [PATCH] add test to document functionality where AddHits is ignored if post condition does not have a hit target --- test/test.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/test.c b/test/test.c index e545ef73..3a22d9c0 100644 --- a/test/test.c +++ b/test/test.c @@ -1126,6 +1126,32 @@ static void test_trigger(void) { assert(condset_get_cond(trigger_get_set(trigger, 0), 1)->current_hits == 3U); } + { + /*------------------------------------------------------------------------ + TestAddHitsNoHitCount + Odd use case: AddHits a=1 + b=1 + Since b=1 doesn't have a hitcount, it ignores the hits tallied by a=1 + ------------------------------------------------------------------------*/ + + unsigned char ram[] = {0x00, 0x12, 0x34, 0xAB, 0x56}; + memory_t memory; + rc_trigger_t* trigger; + + memory.ram = ram; + memory.size = sizeof(ram); + + parse_trigger(&trigger, buffer, "C:0xH0001=18_0xH0000=1"); + comp_trigger(trigger, &memory, 0); + assert(condset_get_cond(trigger_get_set(trigger, 0), 0)->current_hits == 1U); + assert(condset_get_cond(trigger_get_set(trigger, 0), 1)->current_hits == 0U); + + ram[0] = 1; + comp_trigger(trigger, &memory, 1); + assert(condset_get_cond(trigger_get_set(trigger, 0), 0)->current_hits == 2U); + assert(condset_get_cond(trigger_get_set(trigger, 0), 1)->current_hits == 1U); + } + { /*------------------------------------------------------------------------ TestHitCountPauseIfResetIf