Create a tiny test suite

This commit is contained in:
Brandon Rhodes 2021-12-18 09:00:18 -05:00
parent 5522e1039b
commit f34c87ae8a
4 changed files with 47 additions and 0 deletions

2
tests/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/output.actual
/test

15
tests/Makefile Normal file
View File

@ -0,0 +1,15 @@
CFLAGS = -I../libastro
run-test: test
./test > output.actual
diff -u output.expected output.actual
test: test.o ../libastro/libastro.a
$(CC) $< ../libastro/libastro.a -lm -o $@
test.o: test.c
../libastro/libastro.a: .FORCE
make -C ../libastro
.PHONY: .FORCE

15
tests/output.expected Normal file
View File

@ -0,0 +1,15 @@
Precession J2000 -> J2015
RA +0.0000000000000000 -> +0.0033543649473764
Dec -0.0000000000000000 -> +0.0014575063671504
RA +1.0000000000000000 -> +1.0014450289313686
Dec -1.0000000000000000 -> -0.9992134064184917
RA +2.0000000000000000 -> +5.1478363700948195
Dec -2.0000000000000000 -> -1.1409819639181964
RA +3.0000000000000000 -> +6.1449758360061262
Dec -3.0000000000000000 -> -0.1401493826857086
RA +4.0000000000000000 -> +0.8630426367929015
Dec -4.0000000000000000 -> +0.8593574646184613
RA +5.0000000000000000 -> +4.9986250865903390
Dec -5.0000000000000000 -> +1.2835978054231891
RA +6.0000000000000000 -> +6.0032362075042789
Dec -6.0000000000000000 -> +0.2845854258344847

15
tests/test.c Normal file
View File

@ -0,0 +1,15 @@
#include "astro.h"
int main() {
printf("Precession J2000 -> J2015\n");
double ra, pra;
double dec, pdec;
for (double i=0.0; i<7.0; i+=1.0) {
ra = pra = i;
dec = pdec = -i;
precess(J2000, J2015, &pra, &pdec);
printf("RA %+.16f -> %+.16f\n", ra, pra);
printf("Dec %+.16f -> %+.16f\n", dec, pdec);
}
return 0;
}