Пример #1
0
// Tests the filter factor setter
TEST(HighPassFilter, TestCutoffFrequencySet) {
  
  HighPassFilter hpf;

  //Check the id's matches
  EXPECT_TRUE( hpf.getId() == HighPassFilter::getId() );

  const Float delta = 1.0 / 500.0f; //Set a delta for 500Hz

  //Set the gain with a valid value
  EXPECT_TRUE( hpf.setCutoffFrequency( 10, delta ) );
  EXPECT_EQ( hpf.getFilterFactor(), GET_FILTER_FACTOR( 10.0, delta ) );

  //Set the gain with a non valid value
  EXPECT_FALSE( hpf.setCutoffFrequency( -1, delta ) );
  EXPECT_EQ( hpf.getFilterFactor(), GET_FILTER_FACTOR( 10.0, delta ) ); //The gain should not have changed

  //Set the gain with a non valid value
  EXPECT_FALSE( hpf.setCutoffFrequency( 0, delta ) );
  EXPECT_EQ( hpf.getFilterFactor(), GET_FILTER_FACTOR( 10.0, delta ) ); //The gain should not have changed

  //Set the gain with a non valid value
  EXPECT_FALSE( hpf.setCutoffFrequency( 10, 0 ) );
  EXPECT_EQ( hpf.getFilterFactor(), GET_FILTER_FACTOR( 10.0, delta ) ); //The gain should not have changed
}
Пример #2
0
// Tests the filter factor getter/setter
TEST(HighPassFilter, TestFilterFactorGetSet) {
  
  HighPassFilter hpf;

  //Check the id's matches
  EXPECT_TRUE( hpf.getId() == HighPassFilter::getId() );

  //Set the gain with a valid value
  EXPECT_TRUE( hpf.setFilterFactor( 0.9 ) );
  EXPECT_EQ( hpf.getFilterFactor(), 0.9 );

  //Set the gain with a non valid value
  EXPECT_FALSE( hpf.setFilterFactor( -1 ) );
  EXPECT_EQ( hpf.getFilterFactor(), 0.9 ); //The gain should not have changed

  //Set the gain with a non valid value
  EXPECT_FALSE( hpf.setFilterFactor( 1.1 ) );
  EXPECT_EQ( hpf.getFilterFactor(), 0.9 ); //The gain should not have changed
}
Пример #3
0
// Tests the save/load functions
TEST(HighPassFilter, TestSaveLoad) {
  
  HighPassFilter hpf;

  //Check the id's matches
  EXPECT_TRUE( hpf.getId() == HighPassFilter::getId() );

  const Float delta = 1.0 / 500.0f; //Set a delta for 500Hz

  //Set the gain with a valid value
  EXPECT_TRUE( hpf.setCutoffFrequency( 10, delta ) );
  EXPECT_EQ( hpf.getFilterFactor(), GET_FILTER_FACTOR( 10.0, delta ) );

  EXPECT_TRUE( hpf.save("hpf_unit_test_model.grt") );

  EXPECT_TRUE( hpf.clear() );

  EXPECT_TRUE( hpf.load("hpf_unit_test_model.grt") );
  EXPECT_EQ( ROUND( hpf.getFilterFactor() ), ROUND( GET_FILTER_FACTOR( 10.0, delta ) ) ); //Due to differences in how things are load from the file, we need to round the expected value
}