Blender  V2.93
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 
22 
24 {
27 }
28 
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);
34 }
35 
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);
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);
45 }
46 
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 
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
#define CCL_NAMESPACE_END
double time_human_readable_to_seconds(const string &time_string)
Definition: util_time.cpp:93
string time_human_readable_from_seconds(const double seconds)
Definition: util_time.cpp:78
CCL_NAMESPACE_BEGIN TEST(time_human_readable_to_seconds, Empty)