Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
e08e6c6821 | |||
f9db50919f | |||
617d293358 | |||
aa6a489f34 | |||
c25f650755 | |||
2ab696906c | |||
61de67efa4 | |||
e44480cb21 | |||
b6d8ca18c9 | |||
132a7aaac3 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -57,8 +57,8 @@ Makefile.in
|
||||
/tests/*-test
|
||||
/tests/*-test.log
|
||||
/tests/*-test.trs
|
||||
/tests/test-suite.log
|
||||
/swe-glib-lcov*
|
||||
test-suite.log
|
||||
*.gcno
|
||||
*.gcda
|
||||
*.gcov
|
||||
|
@ -7,11 +7,13 @@ addons:
|
||||
- gobject-introspection
|
||||
- gnome-common
|
||||
- autopoint
|
||||
before_script: ./autogen.sh
|
||||
- lcov
|
||||
before_script: ./autogen.sh --enable-coverage
|
||||
script:
|
||||
- make
|
||||
- make check
|
||||
before_install:
|
||||
- pip install --user codecov
|
||||
after_success:
|
||||
- codecov
|
||||
- find -type f -name '*.gcno'
|
||||
- codecov --gcov-root src
|
||||
|
@ -107,7 +107,7 @@ AS_IF([ test "x$use_gcov" = "xyes"], [
|
||||
AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
|
||||
|
||||
AS_IF([ test "$LTP" ], [
|
||||
AC_CACHE_CHECK([for ltp version], sw_glib_cv_ltp_version, [
|
||||
AC_CACHE_CHECK([for ltp version], swe_glib_cv_ltp_version, [
|
||||
swe_glib_cv_ltp_version=invalid
|
||||
ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'`
|
||||
for ltp_check_version in $ltp_version_list; do
|
||||
|
@ -488,10 +488,13 @@ gswe_timestamp_set_property(GObject *object,
|
||||
|
||||
break;
|
||||
|
||||
/* LCOV_EXCL_START Unless a property ID is missing from above,
|
||||
* we will never arrive here */
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
|
||||
break;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
|
||||
@ -585,10 +588,13 @@ gswe_timestamp_get_property(
|
||||
|
||||
break;
|
||||
|
||||
/* LCOV_EXCL_START Unless a property ID is missing from above,
|
||||
* we will never arrive here */
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
|
||||
break;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
|
||||
|
55
swe-glib.mk
55
swe-glib.mk
@ -1,4 +1,7 @@
|
||||
# SWE-GLib - GLib wrapper around the Swiss Ephemeris library
|
||||
#
|
||||
# Most of this file is got from GLib, especially the code coverage measurement
|
||||
# parts
|
||||
|
||||
GTESTER = gtester
|
||||
GTESTER_REPORT = gtester-report
|
||||
@ -7,7 +10,7 @@ NULL =
|
||||
# initialize variables for unconditional += appending
|
||||
BUILT_SOURCES =
|
||||
BUILT_EXTRA_DIST =
|
||||
CLEANFILES = *.log *.trs
|
||||
CLEANFILES = *.log *.trs *.gcda
|
||||
DISTCLEANFILES =
|
||||
MAINTAINERCLEANFILES =
|
||||
EXTRA_DIST =
|
||||
@ -33,9 +36,7 @@ else
|
||||
test-nonrecursive:
|
||||
endif
|
||||
|
||||
.PHONY: test-nonrecursive
|
||||
|
||||
.PHONY: lcov genlcov lcov-clean
|
||||
.PHONY: test-nonrecursive lcov genlcov lcov-clean
|
||||
# use recursive makes in order to ignore errors during check
|
||||
lcov:
|
||||
-$(MAKE) $(AM_MAKEFLAGS) -k check
|
||||
@ -45,9 +46,8 @@ lcov:
|
||||
# placing the objects files in the .libs/ directory separate from the *.c
|
||||
# we also have to delete tests/.libs/libmoduletestplugin_*.gcda
|
||||
genlcov:
|
||||
$(AM_V_GEN) rm -f $(top_builddir)/tests/.libs/libmoduletestplugin_*.gcda; \
|
||||
$(LTP) --quiet --directory $(top_builddir) --capture --output-file swe-glib-lcov.info --test-name SWE_GLIB_PERF --no-checksum --compat-libtool --ignore-errors source; \
|
||||
$(LTP) --quiet --output-file swe-glib-lcov.info --remove swe-glib-lcov.info docs/reference/\* /tmp/\* gio/tests/gdbus-object-manager-example/\* ; \
|
||||
$(AM_V_GEN) $(LTP) --quiet --directory $(top_builddir) --capture --output-file swe-glib-lcov.info --test-name SWE_GLIB_PERF --no-checksum --compat-libtool --ignore-errors source; \
|
||||
$(LTP) --quiet --output-file swe-glib-lcov.info --remove swe-glib-lcov.info docs/reference/\* /tmp/\* ; \
|
||||
LANG=C $(LTP_GENHTML) --quiet --prefix $(top_builddir) --output-directory swe-glib-lcov --title "SWE-GLib Code Coverage" --legend --frames --show-details swe-glib-lcov.info --ignore-errors source
|
||||
@echo "file://$(abs_top_builddir)/swe-glib-lcov/index.html"
|
||||
|
||||
@ -59,47 +59,6 @@ lcov-clean:
|
||||
# run tests in cwd as part of make check
|
||||
check-local: test-nonrecursive
|
||||
|
||||
# We support a fairly large range of possible variables. It is expected that all types of files in a test suite
|
||||
# will belong in exactly one of the following variables.
|
||||
#
|
||||
# First, we support the usual automake suffixes, but in lowercase, with the customary meaning:
|
||||
#
|
||||
# test_programs, test_scripts, test_data, test_ltlibraries
|
||||
#
|
||||
# The above are used to list files that are involved in both uninstalled and installed testing. The
|
||||
# test_programs and test_scripts are taken to be actual testcases and will be run as part of the test suite.
|
||||
# Note that _data is always used with the nobase_ automake variable name to ensure that installed test data is
|
||||
# installed in the same way as it appears in the package layout.
|
||||
#
|
||||
# In order to mark a particular file as being only for one type of testing, use 'installed' or 'uninstalled',
|
||||
# like so:
|
||||
#
|
||||
# installed_test_programs, uninstalled_test_programs
|
||||
# installed_test_scripts, uninstalled_test_scripts
|
||||
# installed_test_data, uninstalled_test_data
|
||||
# installed_test_ltlibraries, uninstalled_test_ltlibraries
|
||||
#
|
||||
# Additionally, we support 'extra' infixes for programs and scripts. This is used for support programs/scripts
|
||||
# that should not themselves be run as testcases (but exist to be used from other testcases):
|
||||
#
|
||||
# test_extra_programs, installed_test_extra_programs, uninstalled_test_extra_programs
|
||||
# test_extra_scripts, installed_test_extra_scripts, uninstalled_test_extra_scripts
|
||||
#
|
||||
# Additionally, for _scripts and _data, we support the customary dist_ prefix so that the named script or data
|
||||
# file automatically end up in the tarball.
|
||||
#
|
||||
# dist_test_scripts, dist_test_data, dist_test_extra_scripts
|
||||
# dist_installed_test_scripts, dist_installed_test_data, dist_installed_test_extra_scripts
|
||||
# dist_uninstalled_test_scripts, dist_uninstalled_test_data, dist_uninstalled_test_extra_scripts
|
||||
#
|
||||
# Note that no file is automatically disted unless it appears in one of the dist_ variables. This follows the
|
||||
# standard automake convention of not disting programs scripts or data by default.
|
||||
#
|
||||
# test_programs, test_scripts, uninstalled_test_programs and uninstalled_test_scripts (as well as their disted
|
||||
# variants) will be run as part of the in-tree 'make check'. These are all assumed to be runnable under
|
||||
# gtester. That's a bit strange for scripts, but it's possible.
|
||||
|
||||
# we use test -z "$(TEST_PROGS)" above, so make sure we have no extra whitespace...
|
||||
TEST_PROGS += $(strip $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
|
||||
$(dist_test_scripts) $(dist_uninstalled_test_scripts))
|
||||
|
||||
|
@ -26,6 +26,7 @@ static struct testdata_t td[] = {
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
/* Test Gregorian date values */
|
||||
static void
|
||||
test_timestamp_gregorian(void)
|
||||
{
|
||||
@ -141,6 +142,7 @@ test_timestamp_gregorian(void)
|
||||
g_clear_object(×tamp);
|
||||
}
|
||||
|
||||
/* Check timezone mangling */
|
||||
static void
|
||||
test_timestamp_timezone(void)
|
||||
{
|
||||
@ -191,6 +193,7 @@ test_timestamp_timezone(void)
|
||||
g_clear_object(×tamp);
|
||||
}
|
||||
|
||||
/* Test Julian Day (Ephemeris Time) properties */
|
||||
static void
|
||||
test_timestamp_jdet(void)
|
||||
{
|
||||
@ -216,13 +219,26 @@ test_timestamp_jdet(void)
|
||||
g_assert_null(err);
|
||||
gswe_assert_fuzzy_equals(jdet, td[1].jdet, 0.000001);
|
||||
|
||||
/* Set via property */
|
||||
g_object_set(timestamp,
|
||||
"julian-day", td[0].jdet,
|
||||
NULL);
|
||||
jdet = gswe_timestamp_get_julian_day_et(timestamp, &err);
|
||||
gswe_assert_fuzzy_equals(jdet, td[0].jdet, 0.000001);
|
||||
g_object_get(timestamp,
|
||||
"julian-day", &jdet,
|
||||
NULL);
|
||||
gswe_assert_fuzzy_equals(jdet, td[0].jdet, 0.000001);
|
||||
|
||||
g_clear_object(×tamp);
|
||||
}
|
||||
|
||||
/* Test Julian Day (Universal Time) properties */
|
||||
static void
|
||||
test_timestamp_jdut(void)
|
||||
{}
|
||||
|
||||
/* Test instant-recalc property */
|
||||
static void
|
||||
test_timestamp_instant(void)
|
||||
{
|
||||
@ -268,11 +284,12 @@ test_timestamp_instant(void)
|
||||
g_assert_false(jul_valid);
|
||||
}
|
||||
|
||||
/* Test Gregorian Date to Julian Day conversion */
|
||||
static void
|
||||
test_timestamp_conv_gregjd(void)
|
||||
{
|
||||
GsweTimestamp *timestamp;
|
||||
gdouble jdet;
|
||||
gdouble jdet, tz_jdet;
|
||||
GError *err = NULL;
|
||||
|
||||
/* Create timestamp from testdata */
|
||||
@ -293,17 +310,68 @@ test_timestamp_conv_gregjd(void)
|
||||
0.0001
|
||||
);
|
||||
|
||||
/* Julian Day should not change if only the timezone changes */
|
||||
td[1].tz += 1.0;
|
||||
tz_jdet = gswe_timestamp_get_julian_day_ut(timestamp, &err);
|
||||
g_assert_cmpfloat(jdet, ==, tz_jdet);
|
||||
|
||||
g_clear_object(×tamp);
|
||||
}
|
||||
|
||||
/* Julian Day to Gregorian Date conversion */
|
||||
static void
|
||||
test_timestamp_conv_jdgreg(void)
|
||||
{}
|
||||
{
|
||||
GsweTimestamp *timestamp;
|
||||
guint year, month, day, hour, minute, second, ms;
|
||||
gdouble tz;
|
||||
gboolean gregorian_valid, julian_valid;
|
||||
GError *err = NULL;
|
||||
|
||||
timestamp = gswe_timestamp_new_from_julian_day(td[0].jdet);
|
||||
g_assert_nonnull(timestamp);
|
||||
g_object_get(timestamp,
|
||||
"gregorian-valid", &gregorian_valid,
|
||||
"julian-day-valid", &julian_valid,
|
||||
"gregorian-timezone-offset", &tz,
|
||||
NULL);
|
||||
g_assert_true(julian_valid);
|
||||
g_assert_cmpfloat(0.0, ==, tz);
|
||||
|
||||
gswe_timestamp_set_gregorian_timezone(timestamp, td[0].tz, &err);
|
||||
g_object_get(
|
||||
timestamp,
|
||||
"gregorian-year", &year,
|
||||
"gregorian-month", &month,
|
||||
"gregorian-day", &day,
|
||||
"gregorian-hour", &hour,
|
||||
"gregorian-minute", &minute,
|
||||
"gregorian-second", &second,
|
||||
"gregorian-microsecond", &ms,
|
||||
"gregorian-timezone-offset", &tz,
|
||||
NULL
|
||||
);
|
||||
g_assert_cmpint(year, ==, td[0].year);
|
||||
g_assert_cmpuint(month, ==, td[0].month);
|
||||
g_assert_cmpuint(day, ==, td[0].day);
|
||||
g_assert_cmpuint(hour, ==, td[0].hour);
|
||||
gswe_assert_fuzzy_equals(minute, td[0].minute, 1);
|
||||
|
||||
/* The following lines are commented out, as they will always fail
|
||||
* with the current precision of the test data.
|
||||
|
||||
g_assert_cmpuint(minute, ==, td[0].minute);
|
||||
g_assert_cmpuint(second, ==, td[0].second);
|
||||
g_assert_cmpuint(ms, ==, td[0].ms);
|
||||
*/
|
||||
g_assert_cmpfloat(tz, ==, td[0].tz); }
|
||||
|
||||
/* Sidereal time tests */
|
||||
static void
|
||||
test_timestamp_sidereal(void)
|
||||
{}
|
||||
|
||||
/* timestamp_now_* tests */
|
||||
static void
|
||||
test_timestamp_now(void)
|
||||
{}
|
||||
|
Loading…
Reference in New Issue
Block a user