| 20 | namespace test { |
| 21 | |
| 22 | TEST(AudioDecoderImpl, ProcessOffsetAndLength) { |
| 23 | int64_t start = 0; |
| 24 | int64_t total_length = static_cast<int64_t>(3.4 * 16000); |
| 25 | AudioMetadata meta{total_length, 16000, 1}; // 3.40s at 16kHz |
| 26 | { |
| 27 | int64_t offset = static_cast<int64_t>(0.5 * meta.sample_rate); |
| 28 | int64_t length = static_cast<int64_t>(1.0 * meta.sample_rate); |
| 29 | ASSERT_EQ(std::make_pair(offset, length), ProcessOffsetAndLength(meta, 0.5, 1.0)); |
| 30 | } |
| 31 | { |
| 32 | ASSERT_EQ(std::make_pair(start, total_length), ProcessOffsetAndLength(meta, -1.0, 5.0)); |
| 33 | ASSERT_EQ(std::make_pair(start, total_length), ProcessOffsetAndLength(meta, -1.0, -1.0)); |
| 34 | } |
| 35 | |
| 36 | { |
| 37 | int64_t offset = static_cast<int64_t>(2.0 * meta.sample_rate); |
| 38 | int64_t duration = total_length - offset; |
| 39 | ASSERT_EQ(std::make_pair(offset, duration), ProcessOffsetAndLength(meta, 2.0, 3.4)); |
| 40 | } |
| 41 | |
| 42 | { |
| 43 | int64_t offset = 0; |
| 44 | int64_t duration = static_cast<int64_t>(2.4 * meta.sample_rate); |
| 45 | ASSERT_EQ(std::make_pair(offset, duration), ProcessOffsetAndLength(meta, -1.0, 2.4)); |
| 46 | } |
| 47 | |
| 48 | { |
| 49 | int64_t offset = static_cast<int64_t>(0.45 * meta.sample_rate); |
| 50 | int64_t duration = total_length - offset; |
| 51 | ASSERT_EQ(std::make_pair(offset, duration), ProcessOffsetAndLength(meta, 0.45, -1.0)); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | } // namespace test |
| 56 | } // namespace dali |
nothing calls this directly
no test coverage detected