This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/blenlib/tests/BLI_math_time_test.cc
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

36 lines
1.3 KiB
C++

/* SPDX-License-Identifier: Apache-2.0 */
#include "testing/testing.h"
#include "BLI_math.h"
TEST(math_time, SecondsExplode)
{
const double seconds = 2.0 * SECONDS_IN_DAY + 13.0 * SECONDS_IN_HOUR + 33.0 * SECONDS_IN_MINUTE +
9.0 + 369.0 * SECONDS_IN_MILLISECONDS;
const double epsilon = 1e-8;
double r_days, r_hours, r_minutes, r_seconds, r_milliseconds;
BLI_math_time_seconds_decompose(
seconds, &r_days, &r_hours, &r_minutes, &r_seconds, &r_milliseconds);
EXPECT_NEAR(2.0, r_days, epsilon);
EXPECT_NEAR(13.0, r_hours, epsilon);
EXPECT_NEAR(33.0, r_minutes, epsilon);
EXPECT_NEAR(9.0, r_seconds, epsilon);
EXPECT_NEAR(369.0, r_milliseconds, epsilon);
BLI_math_time_seconds_decompose(seconds, nullptr, &r_hours, &r_minutes, &r_seconds, nullptr);
EXPECT_NEAR(61.0, r_hours, epsilon);
EXPECT_NEAR(33.0, r_minutes, epsilon);
EXPECT_NEAR(9.369, r_seconds, epsilon);
BLI_math_time_seconds_decompose(seconds, nullptr, nullptr, nullptr, &r_seconds, nullptr);
EXPECT_NEAR(seconds, r_seconds, epsilon);
BLI_math_time_seconds_decompose(seconds, &r_days, nullptr, &r_minutes, nullptr, &r_milliseconds);
EXPECT_NEAR(2.0, r_days, epsilon);
EXPECT_NEAR(813.0, r_minutes, epsilon);
EXPECT_NEAR(9369.0, r_milliseconds, epsilon);
}