Skip to content

Commit 6e13ce0

Browse files
Testing: Added test for ClearState()
Now full testing of the public API is performed. No throws known in code. Only known vulnerabilities come from API array inputs: can cause reads out of memory, if the array allocated memory is smaller than the filter expects
1 parent 6f32dc1 commit 6e13ce0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/Filter_testing.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,29 @@ TEST(PublicAPITests,InitialziationTest_SetState) {
170170
ASSERT_FLOAT_EQ(input_state[i],input_copied[i]);
171171
ASSERT_FLOAT_EQ(output_state[i],output_copied[i]);
172172
}
173+
}
174+
175+
/**
176+
* @brief Tests ClearState() resets properly to 0
177+
*
178+
*/
179+
TEST(PublicAPITests,InitialziationTest_ClearState) {
180+
// Test values are computed properly
181+
constexpr unsigned int N = 5;
182+
FilterTestHelper<float,N> test_filter;
183+
184+
// Assign numerator & denominator
185+
float input_state[N] = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f};
186+
float output_state[N] = {-1.0f, -2.0f, -3.0f, -4.0f, -5.0f};
187+
188+
test_filter.SetState(input_state,output_state);
189+
test_filter.ClearState();
190+
// Check inputs & outputs copy is correct
191+
float* input_copied = test_filter.GetInputState();
192+
float* output_copied = test_filter.GetOutputState();
193+
194+
for(unsigned int i = 0; i < N ; i++){
195+
ASSERT_FLOAT_EQ(0.0f,input_copied[i]);
196+
ASSERT_FLOAT_EQ(0.0f,output_copied[i]);
197+
}
173198
}

0 commit comments

Comments
 (0)