Index: webrtc/modules/audio_processing/test/bitexactness_tools.cc |
diff --git a/webrtc/modules/audio_processing/test/bitexactness_tools.cc b/webrtc/modules/audio_processing/test/bitexactness_tools.cc |
index b3c10480718dd0f918a37f2f536525a4a12c8df3..881471145c9f948eb9b1f10d4841da61672b554b 100644 |
--- a/webrtc/modules/audio_processing/test/bitexactness_tools.cc |
+++ b/webrtc/modules/audio_processing/test/bitexactness_tools.cc |
@@ -17,18 +17,35 @@ |
namespace webrtc { |
namespace test { |
+::testing::AssertionResult AssertIntegersNotEqual(const char* m_expr, |
hlundin-webrtc
2016/03/16 12:57:05
Consider using EXPECT_NEAR instead of this custom
peah-webrtc
2016/03/17 14:18:06
Done.
|
+ const char* n_expr, |
+ const int& output, |
+ const int& reference) { |
+ // Compare the output in the reference in a soft manner. |
+ const int kThreshold = 1.0; |
+ bool equal = (abs(output - reference) <= kThreshold); |
+ |
+ // If the values are deemed not to be similar, return a report of the |
+ // difference. |
+ if (!equal) { |
+ return ::testing::AssertionFailure() |
+ << "Actual: " << std::to_string(output) << std::endl |
+ << "Expected: " << std::to_string(reference) << std::endl; |
+ } |
+ return ::testing::AssertionSuccess(); |
+} |
+ |
::testing::AssertionResult AssertFloatsNotEqual(const char* m_expr, |
const char* n_expr, |
const float& output, |
const float& reference) { |
// Compare the output in the reference in a soft manner. |
- float threshold = 1.0f / 32768.0f; |
- bool equal = (fabs(output - reference) <= threshold); |
+ const float kThreshold = 1.0f / 32768.0f; |
+ bool equal = (fabs(output - reference) <= kThreshold); |
// If the values are deemed not to be similar, return a report of the |
// difference. |
if (!equal) { |
- // Lambda function that produces a formatted string with the values. |
return ::testing::AssertionFailure() |
<< "Actual: " << std::to_string(output) + "f" << std::endl |
<< "Expected: " << std::to_string(reference) + "f" << std::endl; |
@@ -42,10 +59,10 @@ namespace test { |
const rtc::ArrayView<const float>& output, |
const rtc::ArrayView<const float>& reference) { |
// Compare the output in the reference in a soft manner. |
- float threshold = 1.0f / 32768.0f; |
+ float kThreshold = 1.0f / 32768.0f; |
bool equal = true; |
for (size_t k = 0; k < reference.size(); ++k) { |
- if (fabs(output[k] - reference[k]) > threshold) { |
+ if (fabs(output[k] - reference[k]) > kThreshold) { |
equal = false; |
break; |
} |