mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-15 16:06:41 +03:00
5f8e958ef3
Due do rounding errors the progress events were fired way too early (especially the complete event on longer videos). This changes use float comparison to mitigate the issue. Further improvements (video with start time, seek handling) will be added in follow up PRs. Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
21 lines
600 B
JavaScript
21 lines
600 B
JavaScript
/*! @license
|
|
* Shaka Player
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
describe('NumberUtils', () => {
|
|
const NumberUtils = shaka.util.NumberUtils;
|
|
|
|
it('compares float', () => {
|
|
expect(NumberUtils.isFloatEqual(0.1 + 0.2, 0.3)).toBe(true);
|
|
expect(NumberUtils.isFloatEqual(0.4 - 0.1, 0.3)).toBe(true);
|
|
expect(NumberUtils.isFloatEqual(0.0004, 0.0003)).toBe(false);
|
|
});
|
|
|
|
it('respects provided tolerance margin', () => {
|
|
expect(NumberUtils.isFloatEqual(1.5, 1.4)).toBe(false);
|
|
expect(NumberUtils.isFloatEqual(1.5, 1.4, 0.1)).toBe(true);
|
|
});
|
|
});
|