Blender
V5.3
source
blender
blenlib
tests
BLI_math_time_test.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2023 Blender Authors
2
*
3
* SPDX-License-Identifier: Apache-2.0 */
4
5
#include "testing/testing.h"
6
7
#include "
BLI_math_time.hh
"
8
9
namespace
blender
{
10
11
TEST
(math_time, SecondsExplode)
12
{
13
const
double
seconds = 2.0 *
SECONDS_IN_DAY
+ 13.0 *
SECONDS_IN_HOUR
+ 33.0 *
SECONDS_IN_MINUTE
+
14
9.0 + 369.0 *
SECONDS_IN_MILLISECONDS
;
15
const
double
epsilon = 1
e
-8;
16
17
double
r_days, r_hours, r_minutes, r_seconds, r_milliseconds;
18
19
BLI_math_time_seconds_decompose
(
20
seconds, &r_days, &r_hours, &r_minutes, &r_seconds, &r_milliseconds);
21
EXPECT_NEAR
(2.0, r_days, epsilon);
22
EXPECT_NEAR
(13.0, r_hours, epsilon);
23
EXPECT_NEAR
(33.0, r_minutes, epsilon);
24
EXPECT_NEAR
(9.0, r_seconds, epsilon);
25
EXPECT_NEAR
(369.0, r_milliseconds, epsilon);
26
27
BLI_math_time_seconds_decompose
(seconds,
nullptr
, &r_hours, &r_minutes, &r_seconds,
nullptr
);
28
EXPECT_NEAR
(61.0, r_hours, epsilon);
29
EXPECT_NEAR
(33.0, r_minutes, epsilon);
30
EXPECT_NEAR
(9.369, r_seconds, epsilon);
31
32
BLI_math_time_seconds_decompose
(seconds,
nullptr
,
nullptr
,
nullptr
, &r_seconds,
nullptr
);
33
EXPECT_NEAR
(seconds, r_seconds, epsilon);
34
35
BLI_math_time_seconds_decompose
(seconds, &r_days,
nullptr
, &r_minutes,
nullptr
, &r_milliseconds);
36
EXPECT_NEAR
(2.0, r_days, epsilon);
37
EXPECT_NEAR
(813.0, r_minutes, epsilon);
38
EXPECT_NEAR
(9369.0, r_milliseconds, epsilon);
39
}
40
41
}
// namespace blender
BLI_math_time.hh
SECONDS_IN_MILLISECONDS
#define SECONDS_IN_MILLISECONDS
Definition
BLI_math_time.hh:17
SECONDS_IN_MINUTE
#define SECONDS_IN_MINUTE
Definition
BLI_math_time.hh:18
SECONDS_IN_HOUR
#define SECONDS_IN_HOUR
Definition
BLI_math_time.hh:24
SECONDS_IN_DAY
#define SECONDS_IN_DAY
Definition
BLI_math_time.hh:23
EXPECT_NEAR
#define EXPECT_NEAR(result, expect, threshold)
Definition
gpu_shader_test_lib.bsl.hh:201
blender
BMesh Iterators.
Definition
ANIM_action.hh:30
blender::BLI_math_time_seconds_decompose
void BLI_math_time_seconds_decompose(double seconds, double *r_days, double *r_hours, double *r_minutes, double *r_seconds, double *r_milliseconds)
Definition
math_time.cc:14
blender::TEST
TEST(array_store, Nop)
Definition
BLI_array_store_test.cc:313
blender::e
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
Definition
bmesh_query_inline.hh:44
Generated on
for Blender by
doxygen
1.18.0