2015-09-29 12:08:48 -07:00
|
|
|
/********************************************************************\
|
|
|
|
|
* 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, contact: *
|
|
|
|
|
* *
|
|
|
|
|
* Free Software Foundation Voice: +1-617-542-5942 *
|
|
|
|
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
|
|
|
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
|
|
|
|
* *
|
|
|
|
|
\********************************************************************/
|
2015-11-29 17:11:29 -08:00
|
|
|
extern "C"
|
|
|
|
|
{
|
2017-10-26 11:14:21 +02:00
|
|
|
#include <config.h>
|
2001-08-18 20:39:37 +00:00
|
|
|
|
|
|
|
|
#include "test-stuff.h"
|
|
|
|
|
#include "test-engine-stuff.h"
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2015-11-29 17:11:29 -08:00
|
|
|
}
|
2001-08-18 20:39:37 +00:00
|
|
|
|
2015-11-29 17:11:29 -08:00
|
|
|
#include "test-file-stuff.h"
|
2001-08-18 20:39:37 +00:00
|
|
|
#include "sixtp-utils.h"
|
|
|
|
|
#include "sixtp-dom-generators.h"
|
|
|
|
|
|
2012-01-29 01:12:30 +00:00
|
|
|
#define GNC_V2_STRING "gnc-v2"
|
2016-03-12 14:04:40 -08:00
|
|
|
const gchar* gnc_v2_xml_version_string = GNC_V2_STRING;
|
2012-01-29 01:12:30 +00:00
|
|
|
|
2001-08-18 20:39:37 +00:00
|
|
|
int
|
2016-03-12 14:04:40 -08:00
|
|
|
main (int argc, char** argv)
|
2001-08-18 20:39:37 +00:00
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
for (i = 0; i < 20; i++)
|
2001-08-18 20:39:37 +00:00
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
Timespec* spec1;
|
2001-08-18 20:39:37 +00:00
|
|
|
Timespec spec2;
|
2016-03-12 14:04:40 -08:00
|
|
|
gchar* sec_str;
|
|
|
|
|
gchar* nsec_str;
|
2009-12-29 20:12:48 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
spec1 = get_random_timespec ();
|
2001-08-18 20:39:37 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
sec_str = timespec_sec_to_string (spec1);
|
|
|
|
|
nsec_str = timespec_nsec_to_string (spec1);
|
2001-08-18 20:39:37 +00:00
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
if (!string_to_timespec_secs (sec_str, &spec2))
|
2001-08-18 20:39:37 +00:00
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
failure_args ("string_to_timespec_secs", __FILE__, __LINE__,
|
|
|
|
|
"string is %s", sec_str);
|
2001-08-18 20:39:37 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
else if (!string_to_timespec_nsecs (nsec_str, &spec2))
|
2001-08-18 20:39:37 +00:00
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
failure_args ("string_to_timespec_nsecs", __FILE__, __LINE__,
|
|
|
|
|
"string is %s", nsec_str);
|
2001-08-18 20:39:37 +00:00
|
|
|
}
|
|
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
else if (spec1->tv_sec != spec2.tv_sec)
|
2001-08-18 20:39:37 +00:00
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
failure_args ("timespec_secs", __FILE__, __LINE__,
|
|
|
|
|
"not equal ints are %" G_GINT64_FORMAT
|
|
|
|
|
" and %" G_GINT64_FORMAT "\n",
|
|
|
|
|
spec1->tv_sec, spec2.tv_sec);
|
2001-08-18 20:39:37 +00:00
|
|
|
}
|
|
|
|
|
|
2009-12-29 20:12:48 +00:00
|
|
|
else if (spec1->tv_nsec != spec2.tv_nsec)
|
2001-08-18 20:39:37 +00:00
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
failure_args ("timespec_nsecs", __FILE__, __LINE__,
|
|
|
|
|
"not equal ints are %ld and %ld\n",
|
|
|
|
|
spec1->tv_nsec, spec2.tv_nsec);
|
2001-08-18 20:39:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-03-12 14:04:40 -08:00
|
|
|
success ("timespec");
|
2001-08-18 20:39:37 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-12 14:04:40 -08:00
|
|
|
g_free (spec1);
|
|
|
|
|
g_free (sec_str);
|
|
|
|
|
g_free (nsec_str);
|
2001-08-18 20:39:37 +00:00
|
|
|
}
|
2016-03-12 14:04:40 -08:00
|
|
|
print_test_results ();
|
|
|
|
|
exit (get_rv ());
|
2001-08-18 20:39:37 +00:00
|
|
|
}
|