From e0dc3b0a2186e2e6c76c3428fd123f33f6d79c5a Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Sun, 13 Oct 2019 18:06:04 -0700 Subject: [PATCH] Add test for time_diff_to_str --- tracetools_analysis/test/test_utils.py | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tracetools_analysis/test/test_utils.py diff --git a/tracetools_analysis/test/test_utils.py b/tracetools_analysis/test/test_utils.py new file mode 100644 index 0000000..16d0886 --- /dev/null +++ b/tracetools_analysis/test/test_utils.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# Copyright 2019 Apex.AI, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + +from tracetools_analysis import time_diff_to_str + + +class TestUtils(unittest.TestCase): + + def __init__(self, *args) -> None: + super().__init__( + *args, + ) + + def test_time_diff_to_str(self) -> None: + self.assertEqual('11 ms', time_diff_to_str(0.0106)) + self.assertEqual('6.9 s', time_diff_to_str(6.9069)) + self.assertEqual('1 m 10 s', time_diff_to_str(69.6969)) + self.assertEqual('6 m 10 s', time_diff_to_str(369.6969)) + self.assertEqual('2 m 0 s', time_diff_to_str(120.499999999))