Compare commits
1 Commits
testing
...
ruby-examp
Author | SHA1 | Date | |
---|---|---|---|
1a8f5613b2 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -57,8 +57,8 @@ Makefile.in
|
|||||||
/tests/*-test
|
/tests/*-test
|
||||||
/tests/*-test.log
|
/tests/*-test.log
|
||||||
/tests/*-test.trs
|
/tests/*-test.trs
|
||||||
/tests/test-suite.log
|
|
||||||
/swe-glib-lcov*
|
/swe-glib-lcov*
|
||||||
|
test-suite.log
|
||||||
*.gcno
|
*.gcno
|
||||||
*.gcda
|
*.gcda
|
||||||
*.gcov
|
*.gcov
|
||||||
|
@@ -7,13 +7,11 @@ addons:
|
|||||||
- gobject-introspection
|
- gobject-introspection
|
||||||
- gnome-common
|
- gnome-common
|
||||||
- autopoint
|
- autopoint
|
||||||
- lcov
|
before_script: ./autogen.sh
|
||||||
before_script: ./autogen.sh --enable-coverage
|
|
||||||
script:
|
script:
|
||||||
- make
|
- make
|
||||||
- make check
|
- make check
|
||||||
before_install:
|
before_install:
|
||||||
- pip install --user codecov
|
- pip install --user codecov
|
||||||
after_success:
|
after_success:
|
||||||
- find -type f -name '*.gcno'
|
- codecov
|
||||||
- codecov --gcov-root src
|
|
||||||
|
@@ -107,7 +107,7 @@ AS_IF([ test "x$use_gcov" = "xyes"], [
|
|||||||
AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
|
AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
|
||||||
|
|
||||||
AS_IF([ test "$LTP" ], [
|
AS_IF([ test "$LTP" ], [
|
||||||
AC_CACHE_CHECK([for ltp version], swe_glib_cv_ltp_version, [
|
AC_CACHE_CHECK([for ltp version], sw_glib_cv_ltp_version, [
|
||||||
swe_glib_cv_ltp_version=invalid
|
swe_glib_cv_ltp_version=invalid
|
||||||
ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'`
|
ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'`
|
||||||
for ltp_check_version in $ltp_version_list; do
|
for ltp_check_version in $ltp_version_list; do
|
||||||
|
22
examples/basic.rb
Normal file
22
examples/basic.rb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
require "gir_ffi"
|
||||||
|
|
||||||
|
GirFFI.setup :SweGlib
|
||||||
|
|
||||||
|
SweGlib.init
|
||||||
|
|
||||||
|
timestamp = SweGlib::Timestamp.new
|
||||||
|
timestamp.set_gregorian_full(1983, 3, 7, 11, 54, 45, 0, 1)
|
||||||
|
|
||||||
|
moment = SweGlib::Moment.new
|
||||||
|
|
||||||
|
moment.set_timestamp(timestamp)
|
||||||
|
moment.set_coordinates(19.03991, 47.49801, 280)
|
||||||
|
moment.set_house_system :placidus
|
||||||
|
moment.add_all_planets
|
||||||
|
|
||||||
|
all_planets = moment.get_all_planets()
|
||||||
|
|
||||||
|
all_planets.each do |planet|
|
||||||
|
# TODO Why do I get numbers here, instead of GswePlanets?
|
||||||
|
print planet, "\n"
|
||||||
|
end
|
@@ -488,13 +488,10 @@ gswe_timestamp_set_property(GObject *object,
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* LCOV_EXCL_START Unless a property ID is missing from above,
|
|
||||||
* we will never arrive here */
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
/* LCOV_EXCL_STOP */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,13 +585,10 @@ gswe_timestamp_get_property(
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* LCOV_EXCL_START Unless a property ID is missing from above,
|
|
||||||
* we will never arrive here */
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
/* LCOV_EXCL_STOP */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
55
swe-glib.mk
55
swe-glib.mk
@@ -1,7 +1,4 @@
|
|||||||
# SWE-GLib - GLib wrapper around the Swiss Ephemeris library
|
# 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 = gtester
|
||||||
GTESTER_REPORT = gtester-report
|
GTESTER_REPORT = gtester-report
|
||||||
@@ -10,7 +7,7 @@ NULL =
|
|||||||
# initialize variables for unconditional += appending
|
# initialize variables for unconditional += appending
|
||||||
BUILT_SOURCES =
|
BUILT_SOURCES =
|
||||||
BUILT_EXTRA_DIST =
|
BUILT_EXTRA_DIST =
|
||||||
CLEANFILES = *.log *.trs *.gcda
|
CLEANFILES = *.log *.trs
|
||||||
DISTCLEANFILES =
|
DISTCLEANFILES =
|
||||||
MAINTAINERCLEANFILES =
|
MAINTAINERCLEANFILES =
|
||||||
EXTRA_DIST =
|
EXTRA_DIST =
|
||||||
@@ -36,7 +33,9 @@ else
|
|||||||
test-nonrecursive:
|
test-nonrecursive:
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: test-nonrecursive lcov genlcov lcov-clean
|
.PHONY: test-nonrecursive
|
||||||
|
|
||||||
|
.PHONY: lcov genlcov lcov-clean
|
||||||
# use recursive makes in order to ignore errors during check
|
# use recursive makes in order to ignore errors during check
|
||||||
lcov:
|
lcov:
|
||||||
-$(MAKE) $(AM_MAKEFLAGS) -k check
|
-$(MAKE) $(AM_MAKEFLAGS) -k check
|
||||||
@@ -46,8 +45,9 @@ lcov:
|
|||||||
# placing the objects files in the .libs/ directory separate from the *.c
|
# placing the objects files in the .libs/ directory separate from the *.c
|
||||||
# we also have to delete tests/.libs/libmoduletestplugin_*.gcda
|
# we also have to delete tests/.libs/libmoduletestplugin_*.gcda
|
||||||
genlcov:
|
genlcov:
|
||||||
$(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; \
|
$(AM_V_GEN) rm -f $(top_builddir)/tests/.libs/libmoduletestplugin_*.gcda; \
|
||||||
$(LTP) --quiet --output-file swe-glib-lcov.info --remove swe-glib-lcov.info docs/reference/\* /tmp/\* ; \
|
$(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/\* ; \
|
||||||
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
|
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"
|
@echo "file://$(abs_top_builddir)/swe-glib-lcov/index.html"
|
||||||
|
|
||||||
@@ -59,6 +59,47 @@ lcov-clean:
|
|||||||
# run tests in cwd as part of make check
|
# run tests in cwd as part of make check
|
||||||
check-local: test-nonrecursive
|
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) \
|
TEST_PROGS += $(strip $(test_programs) $(test_scripts) $(uninstalled_test_programs) $(uninstalled_test_scripts) \
|
||||||
$(dist_test_scripts) $(dist_uninstalled_test_scripts))
|
$(dist_test_scripts) $(dist_uninstalled_test_scripts))
|
||||||
|
|
||||||
|
@@ -26,7 +26,6 @@ static struct testdata_t td[] = {
|
|||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Test Gregorian date values */
|
|
||||||
static void
|
static void
|
||||||
test_timestamp_gregorian(void)
|
test_timestamp_gregorian(void)
|
||||||
{
|
{
|
||||||
@@ -142,7 +141,6 @@ test_timestamp_gregorian(void)
|
|||||||
g_clear_object(×tamp);
|
g_clear_object(×tamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check timezone mangling */
|
|
||||||
static void
|
static void
|
||||||
test_timestamp_timezone(void)
|
test_timestamp_timezone(void)
|
||||||
{
|
{
|
||||||
@@ -193,7 +191,6 @@ test_timestamp_timezone(void)
|
|||||||
g_clear_object(×tamp);
|
g_clear_object(×tamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test Julian Day (Ephemeris Time) properties */
|
|
||||||
static void
|
static void
|
||||||
test_timestamp_jdet(void)
|
test_timestamp_jdet(void)
|
||||||
{
|
{
|
||||||
@@ -219,26 +216,13 @@ test_timestamp_jdet(void)
|
|||||||
g_assert_null(err);
|
g_assert_null(err);
|
||||||
gswe_assert_fuzzy_equals(jdet, td[1].jdet, 0.000001);
|
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);
|
g_clear_object(×tamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test Julian Day (Universal Time) properties */
|
|
||||||
static void
|
static void
|
||||||
test_timestamp_jdut(void)
|
test_timestamp_jdut(void)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/* Test instant-recalc property */
|
|
||||||
static void
|
static void
|
||||||
test_timestamp_instant(void)
|
test_timestamp_instant(void)
|
||||||
{
|
{
|
||||||
@@ -284,12 +268,11 @@ test_timestamp_instant(void)
|
|||||||
g_assert_false(jul_valid);
|
g_assert_false(jul_valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test Gregorian Date to Julian Day conversion */
|
|
||||||
static void
|
static void
|
||||||
test_timestamp_conv_gregjd(void)
|
test_timestamp_conv_gregjd(void)
|
||||||
{
|
{
|
||||||
GsweTimestamp *timestamp;
|
GsweTimestamp *timestamp;
|
||||||
gdouble jdet, tz_jdet;
|
gdouble jdet;
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
|
|
||||||
/* Create timestamp from testdata */
|
/* Create timestamp from testdata */
|
||||||
@@ -310,68 +293,17 @@ test_timestamp_conv_gregjd(void)
|
|||||||
0.0001
|
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);
|
g_clear_object(×tamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Julian Day to Gregorian Date conversion */
|
|
||||||
static void
|
static void
|
||||||
test_timestamp_conv_jdgreg(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
|
static void
|
||||||
test_timestamp_sidereal(void)
|
test_timestamp_sidereal(void)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/* timestamp_now_* tests */
|
|
||||||
static void
|
static void
|
||||||
test_timestamp_now(void)
|
test_timestamp_now(void)
|
||||||
{}
|
{}
|
||||||
|
Reference in New Issue
Block a user