From 9472c115e76f026e5ebd8b8592b57b7d2b0ce1d7 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Fri, 24 Aug 2007 06:02:51 +0200 Subject: [PATCH] tests for time handling --- tests/10timefunctions.tests | 36 +++++++++---- tests/Makefile.am | 6 ++- tests/time/DIR_INFO | 1 + tests/time/test-time.c | 101 ++++++++++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+), 11 deletions(-) create mode 100644 tests/time/DIR_INFO create mode 100644 tests/time/test-time.c diff --git a/tests/10timefunctions.tests b/tests/10timefunctions.tests index dd08aca5f..e2582ddc6 100644 --- a/tests/10timefunctions.tests +++ b/tests/10timefunctions.tests @@ -1,28 +1,44 @@ -TESTING "Time functions" ./test_time +TESTING "Time functions" ./test-time -TEST "time to float" tofloat 15 500000 < + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include +#include + +#include "lib/time.h" + + +CINELERRA_ERROR_DEFINE(TEST, "test error"); + +int +main (int argc, char** argv) +{ + if (argc == 1) + return 0; + + if (!strcmp(argv[1], "init")) + { + cinelerra_time time; + + cinelerra_time_init (&time, atol (argv[2]), atol(argv[3])); + + printf ("%lu %lu\n", (long)cinelerra_time_sec (&time), (long)cinelerra_time_usec (&time)); + } + + if (!strcmp(argv[1], "todouble")) + { + cinelerra_time time; + + cinelerra_time_init (&time, atol (argv[2]), atol(argv[3])); + + printf ("%g\n", cinelerra_time_double_get (&time)); + } + + if (!strcmp(argv[1], "todoublenull")) + { + printf ("%g\n", cinelerra_time_double_get (NULL)); + } + + if (!strcmp(argv[1], "fromdouble")) + { + cinelerra_time time; + + cinelerra_time_set_double (&time, atof (argv[2])); + + printf ("%lu %lu\n", (long)cinelerra_time_sec (&time), (long)cinelerra_time_usec (&time)); + } + + if (!strcmp(argv[1], "currenttime")) + { + cinelerra_time time; + + cinelerra_time_current (&time); + + printf ("%lu %lu\n", (long)cinelerra_time_sec (&time), (long)cinelerra_time_usec (&time)); + } + + if (!strcmp(argv[1], "add")) + { + cinelerra_time time1, time2; + + cinelerra_time_init (&time1, 0, atol (argv[2])); + cinelerra_time_init (&time2, 0, atol (argv[3])); + cinelerra_time_add (&time1, &time2); + + printf ("%lu %lu\n", (long)cinelerra_time_sec (&time1), (long)cinelerra_time_usec (&time1)); + } + + if (!strcmp(argv[1], "sub")) + { + cinelerra_time time1, time2; + + cinelerra_time_init (&time1, 0, atol (argv[2])); + cinelerra_time_init (&time2, 0, atol (argv[3])); + cinelerra_time_sub (&time1, &time2); + + printf ("%lu %lu\n", (long)cinelerra_time_sec (&time1), (long)cinelerra_time_usec (&time1)); + } + + + return 0; +}