Blender  V3.3
util_time_test.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #include "testing/testing.h"
5 
6 #include "util/time.h"
7 
9 
11 {
14 }
15 
17 {
18  EXPECT_NEAR(time_human_readable_to_seconds(".1"), 0.1, 1e-8f);
19  EXPECT_NEAR(time_human_readable_to_seconds(".10"), 0.1, 1e-8f);
21 }
22 
24 {
25  EXPECT_NEAR(time_human_readable_to_seconds("2.1"), 2.1, 1e-8f);
26  EXPECT_NEAR(time_human_readable_to_seconds("02.10"), 2.1, 1e-8f);
28 
29  EXPECT_NEAR(time_human_readable_to_seconds("12.1"), 12.1, 1e-8f);
30  EXPECT_NEAR(time_human_readable_to_seconds("12.10"), 12.1, 1e-8f);
32 }
33 
35 {
36  EXPECT_NEAR(time_human_readable_to_seconds("3:2.1"), 182.1, 1e-8f);
37  EXPECT_NEAR(time_human_readable_to_seconds("03:02.10"), 182.1, 1e-8f);
38  EXPECT_EQ(time_human_readable_from_seconds(182.1), "03:02.10");
39 
40  EXPECT_NEAR(time_human_readable_to_seconds("34:12.1"), 2052.1, 1e-8f);
41  EXPECT_NEAR(time_human_readable_to_seconds("34:12.10"), 2052.1, 1e-8f);
42  EXPECT_EQ(time_human_readable_from_seconds(2052.1), "34:12.10");
43 }
44 
45 TEST(time_human_readable_to_seconds, HoursMinutesSeconds)
46 {
47  EXPECT_NEAR(time_human_readable_to_seconds("4:3:2.1"), 14582.1, 1e-8f);
48  EXPECT_NEAR(time_human_readable_to_seconds("04:03:02.10"), 14582.1, 1e-8f);
49  EXPECT_EQ(time_human_readable_from_seconds(14582.1), "04:03:02.10");
50 
51  EXPECT_NEAR(time_human_readable_to_seconds("56:34:12.1"), 203652.1, 1e-8f);
52  EXPECT_NEAR(time_human_readable_to_seconds("56:34:12.10"), 203652.1, 1e-8f);
53  EXPECT_EQ(time_human_readable_from_seconds(203652.1), "56:34:12.10");
54 }
55 
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
double time_human_readable_to_seconds(const string &time_string)
Definition: time.cpp:80
string time_human_readable_from_seconds(const double seconds)
Definition: time.cpp:65
CCL_NAMESPACE_BEGIN TEST(time_human_readable_to_seconds, Empty)