tests for time handling
This commit is contained in:
parent
2976b2ab29
commit
9472c115e7
4 changed files with 133 additions and 11 deletions
|
|
@ -1,28 +1,44 @@
|
|||
|
||||
TESTING "Time functions" ./test_time
|
||||
TESTING "Time functions" ./test-time
|
||||
|
||||
TEST "time to float" tofloat 15 500000 <<END
|
||||
TEST "time init" init 15 500000 <<END
|
||||
out: 15 500000
|
||||
END
|
||||
|
||||
TEST "time normalize" init 0 1500000 <<END
|
||||
out: 1 500000
|
||||
END
|
||||
|
||||
TEST "time to float" todouble 15 500000 <<END
|
||||
out: 15.5
|
||||
END
|
||||
|
||||
PLANNED "float to time" fromfloat 33.6666666661 <<END
|
||||
TEST "time to float, NULL gives a NaN" todoublenull <<END
|
||||
out: nan
|
||||
END
|
||||
|
||||
TEST "float to time" fromdouble 33.6666666661 <<END
|
||||
out: 33 666667
|
||||
END
|
||||
|
||||
PLANNED "from rational" fromrational 4 3 <<END
|
||||
out: 1 333333
|
||||
TEST "float to time, round down" fromdouble 0.00000049 <<END
|
||||
out: 0 0
|
||||
END
|
||||
|
||||
PLANNED "get time" gettime <<END
|
||||
TEST "float to time, round up" fromdouble 0.0000005 <<END
|
||||
out: 0 1
|
||||
END
|
||||
|
||||
TEST "current time" currenttime <<END
|
||||
return: 0
|
||||
END
|
||||
|
||||
PLANNED "add time, normalized" add 1234567890 123456789 <<END
|
||||
out: 13580 24679
|
||||
TEST "add time, normalized" add 1000001 2000002 <<END
|
||||
out: 3 3
|
||||
END
|
||||
|
||||
PLANNED "substract time, normalized" sub 1234567890 123456789 <<END
|
||||
out: 11111 11101
|
||||
TEST "substract time, normalized" sub 3000003 2000002 <<END
|
||||
out: 1 1
|
||||
END
|
||||
|
||||
PLANNED "overflow"
|
||||
|
|
|
|||
|
|
@ -18,10 +18,14 @@
|
|||
|
||||
tests_srcdir = $(top_srcdir)/tests
|
||||
|
||||
check_PROGRAMS += test-error
|
||||
check_PROGRAMS += test-error test-time
|
||||
|
||||
test_error_SOURCES = $(tests_srcdir)/error/errortest.c
|
||||
test_error_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/
|
||||
test_error_LDADD = $(builddir)/libcin3.a -lnobugmt -lpthread -ldl
|
||||
|
||||
test_time_SOURCES = $(tests_srcdir)/time/test-time.c
|
||||
test_time_CPPFLAGS = $(AM_CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/
|
||||
test_time_LDADD = $(builddir)/libcin3.a -lnobugmt -lpthread -ldl -lm
|
||||
|
||||
TESTS = $(tests_srcdir)/test.sh
|
||||
|
|
|
|||
1
tests/time/DIR_INFO
Normal file
1
tests/time/DIR_INFO
Normal file
|
|
@ -0,0 +1 @@
|
|||
test time and frame calculations
|
||||
101
tests/time/test-time.c
Normal file
101
tests/time/test-time.c
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
test-time.c - test time and framerate functions
|
||||
|
||||
Copyright (C) CinelerraCV
|
||||
2007, Christian Thaeter <ct@pipapo.org>
|
||||
|
||||
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 <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
Loading…
Reference in a new issue