Gamp v0.0.7-54-gccdc599
Gamp: Graphics, Audio, Multimedia and Processing
Loading...
Searching...
No Matches
Test_GampAVPTS.cpp
Go to the documentation of this file.
1/*
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright Gothel Software e.K.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * This Source Code Form is subject to the terms of the MIT License
8 * If a copy of the MIT was not distributed with this file,
9 * you can obtain one at https://opensource.org/license/mit/.
10 */
11
12#include <cassert>
13#include <cstring>
14
15#include <jau/test/catch2_ext.hpp>
16
17#include <jau/basic_types.hpp>
18
19using namespace jau;
20using namespace jau::fractions_i64_literals;
21using namespace jau::int_literals;
22
23#include <gamp/av/PTS.hpp>
24
25using namespace gamp::av;
26
27TEST_CASE( "PTS toMillis Test 01.01", "[PTS][time]" ) {
28 {
29 REQUIRE(0 == PTS::toMillis("00:00:00") );
30 REQUIRE(0 == PTS::toMillis("00:00") );
31 REQUIRE( 0 == PTS::toMillis("00:00.0001") );
32 REQUIRE( 1 == PTS::toMillis("00:00.001") );
33 REQUIRE( 10 == PTS::toMillis("00:00.010") );
34 REQUIRE( 10 == PTS::toMillis("00:00.01" ) );
35 REQUIRE( 100 == PTS::toMillis("00:00.100") );
36 REQUIRE( 100 == PTS::toMillis("00:00.1" ) );
37 REQUIRE( 111 == PTS::toMillis("00:00.111") );
38 REQUIRE(1000 == PTS::toMillis("00:01.000") );
39 REQUIRE(1111 == PTS::toMillis("00:01.111") );
40 REQUIRE(1111 == PTS::toMillis("00:00:01.111") );
41 }
42 {
43 uint64_t t00a = fraction_timespec::from("1970-01-01T12:34:56.789Z").to_ms();
44 uint64_t t00b = PTS::toMillis("12:34:56.789");
45
46 REQUIRE(t00a == t00b);
47 }
48}
TEST_CASE("PTS toMillis Test 01.01", "[PTS][time]")
static uint32_t toMillis(const std::string &datestr) noexcept
Returns milliseconds from given string representation in '[H[H]:]m[m]:s[s][.S*]'.
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
Definition backtrace.hpp:32
constexpr uint64_t to_ms() const noexcept
Returns time in milliseconds.
static fraction_timespec from(const std::string &datestr, int64_t &utcOffsetSec, size_t &consumedChars) noexcept
Conversion constructor from an ISO8601 time string, as produced via to_iso8601_string().