OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <math.h> | 11 #include <math.h> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "webrtc/base/array_view.h" | 14 #include "webrtc/base/array_view.h" |
15 #include "webrtc/modules/audio_processing/test/bitexactness_tools.h" | 15 #include "webrtc/modules/audio_processing/test/bitexactness_tools.h" |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 namespace test { | 18 namespace test { |
19 | 19 |
20 ::testing::AssertionResult AssertBoolsNotEqual(const char* m_expr, | |
hlundin-webrtc
2016/03/16 15:50:20
No, use EXPECT_EQ instead.
peah-webrtc
2016/03/18 05:56:05
Done.
| |
21 const char* n_expr, | |
22 const bool& output, | |
23 const bool& reference) { | |
24 // If the values are deemed not to be similar, return a report of the | |
25 // difference. | |
26 if (output != reference) { | |
27 // Lambda function that produces a string containing the bool name. | |
28 auto bool_description = [](bool v) { | |
29 if (v) { | |
30 return std::string("true"); | |
31 } else { | |
32 return std::string("false"); | |
33 } | |
34 }; | |
35 | |
36 return ::testing::AssertionFailure() | |
37 << "Actual: " << bool_description(output) << std::endl | |
38 << "Expected: " << bool_description(reference) << std::endl; | |
39 } | |
40 return ::testing::AssertionSuccess(); | |
41 } | |
42 | |
20 ::testing::AssertionResult AssertIntegersNotEqual(const char* m_expr, | 43 ::testing::AssertionResult AssertIntegersNotEqual(const char* m_expr, |
21 const char* n_expr, | 44 const char* n_expr, |
22 const int& output, | 45 const int& output, |
23 const int& reference) { | 46 const int& reference) { |
24 // Compare the output in the reference in a soft manner. | 47 // Compare the output in the reference in a soft manner. |
25 const int kThreshold = 1.0; | 48 const int kThreshold = 1.0; |
26 bool equal = (abs(output - reference) <= kThreshold); | 49 bool equal = (abs(output - reference) <= kThreshold); |
27 | 50 |
28 // If the values are deemed not to be similar, return a report of the | 51 // If the values are deemed not to be similar, return a report of the |
29 // difference. | 52 // difference. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 << std::endl | 111 << std::endl |
89 << "Expected: " | 112 << "Expected: " |
90 << print_vector_in_c_format(reference, reference.size()) | 113 << print_vector_in_c_format(reference, reference.size()) |
91 << std::endl; | 114 << std::endl; |
92 } | 115 } |
93 return ::testing::AssertionSuccess(); | 116 return ::testing::AssertionSuccess(); |
94 } | 117 } |
95 | 118 |
96 } // namespace test | 119 } // namespace test |
97 } // namespace webrtc | 120 } // namespace webrtc |
OLD | NEW |