Blender
V2.93
intern
cycles
test
util_time_test.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2011-2019 Blender Foundation
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#include "testing/testing.h"
18
19
#include "
util/util_time.h
"
20
21
CCL_NAMESPACE_BEGIN
22
23
TEST
(
time_human_readable_to_seconds
, Empty)
24
{
25
EXPECT_EQ
(
time_human_readable_to_seconds
(
""
), 0.0);
26
EXPECT_EQ
(
time_human_readable_from_seconds
(0.0),
"00:00.00"
);
27
}
28
29
TEST
(
time_human_readable_to_seconds
, Fraction)
30
{
31
EXPECT_NEAR(
time_human_readable_to_seconds
(
".1"
), 0.1, 1e-8f);
32
EXPECT_NEAR(
time_human_readable_to_seconds
(
".10"
), 0.1, 1e-8f);
33
EXPECT_EQ
(
time_human_readable_from_seconds
(0.1),
"00:00.10"
);
34
}
35
36
TEST
(
time_human_readable_to_seconds
, Seconds)
37
{
38
EXPECT_NEAR(
time_human_readable_to_seconds
(
"2.1"
), 2.1, 1e-8f);
39
EXPECT_NEAR(
time_human_readable_to_seconds
(
"02.10"
), 2.1, 1e-8f);
40
EXPECT_EQ
(
time_human_readable_from_seconds
(2.1),
"00:02.10"
);
41
42
EXPECT_NEAR(
time_human_readable_to_seconds
(
"12.1"
), 12.1, 1e-8f);
43
EXPECT_NEAR(
time_human_readable_to_seconds
(
"12.10"
), 12.1, 1e-8f);
44
EXPECT_EQ
(
time_human_readable_from_seconds
(12.1),
"00:12.10"
);
45
}
46
47
TEST
(
time_human_readable_to_seconds
, MinutesSeconds)
48
{
49
EXPECT_NEAR(
time_human_readable_to_seconds
(
"3:2.1"
), 182.1, 1e-8f);
50
EXPECT_NEAR(
time_human_readable_to_seconds
(
"03:02.10"
), 182.1, 1e-8f);
51
EXPECT_EQ
(
time_human_readable_from_seconds
(182.1),
"03:02.10"
);
52
53
EXPECT_NEAR(
time_human_readable_to_seconds
(
"34:12.1"
), 2052.1, 1e-8f);
54
EXPECT_NEAR(
time_human_readable_to_seconds
(
"34:12.10"
), 2052.1, 1e-8f);
55
EXPECT_EQ
(
time_human_readable_from_seconds
(2052.1),
"34:12.10"
);
56
}
57
58
TEST
(
time_human_readable_to_seconds
, HoursMinutesSeconds)
59
{
60
EXPECT_NEAR(
time_human_readable_to_seconds
(
"4:3:2.1"
), 14582.1, 1e-8f);
61
EXPECT_NEAR(
time_human_readable_to_seconds
(
"04:03:02.10"
), 14582.1, 1e-8f);
62
EXPECT_EQ
(
time_human_readable_from_seconds
(14582.1),
"04:03:02.10"
);
63
64
EXPECT_NEAR(
time_human_readable_to_seconds
(
"56:34:12.1"
), 203652.1, 1e-8f);
65
EXPECT_NEAR(
time_human_readable_to_seconds
(
"56:34:12.10"
), 203652.1, 1e-8f);
66
EXPECT_EQ
(
time_human_readable_from_seconds
(203652.1),
"56:34:12.10"
);
67
}
68
69
CCL_NAMESPACE_END
EXPECT_EQ
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
CCL_NAMESPACE_END
#define CCL_NAMESPACE_END
Definition:
kernel_compat_cuda.h:23
CCL_NAMESPACE_BEGIN
Definition:
blender_python.cpp:54
time_human_readable_to_seconds
double time_human_readable_to_seconds(const string &time_string)
Definition:
util_time.cpp:93
time_human_readable_from_seconds
string time_human_readable_from_seconds(const double seconds)
Definition:
util_time.cpp:78
util_time.h
TEST
CCL_NAMESPACE_BEGIN TEST(time_human_readable_to_seconds, Empty)
Definition:
util_time_test.cpp:23
Generated on Tue Jan 31 2023 14:37:24 for Blender by
doxygen
1.9.1