diff options
author | Thomas White <taw@bitwiz.org.uk> | 2009-03-04 23:22:32 +0000 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2009-03-04 23:23:00 +0000 |
commit | a0a8c6218d027dd4b8b877cd9941a55fc6b4de65 (patch) | |
tree | e1c4e07803b33c1a72f26d19c9a6016c9915fb42 | |
parent | 219f63c4bcbf877a41a70c6fd37ac63bd90b85b6 (diff) |
Add a unit test program
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | crystal.c | 4 | ||||
-rw-r--r-- | crystal.h | 3 | ||||
-rw-r--r-- | test.c | 33 |
5 files changed, 45 insertions, 4 deletions
@@ -1,2 +1,4 @@ *.o triclinator +test + @@ -1,5 +1,8 @@ triclinator: main.o crystal.o util.o - gcc main.o crystal.o util.o -o triclinator -lgsl -lgslcblas + gcc main.o crystal.o util.o -o triclinator -lgsl -lgslcblas -lm + +test: test.o crystal.o util.o + gcc test.o crystal.o util.o -o test -lm main.o: main.c gcc -g -c -I/usr/include main.c -o main.o @@ -11,6 +14,6 @@ util.o: util.c gcc -g -c -I/usr/include util.c -o util.o clean: - rm -f triclinator main.o crystal.o util.o + rm -f triclinator test main.o crystal.o util.o test.o .PHONY: clean @@ -65,7 +65,7 @@ static double volume(Cell cell) } -static double dspacing(Cell cell, double h, double k, double l) +double dspacing(Cell cell, double h, double k, double l) { double sum_S_terms, one_over_Vsq, one_over_LHS; @@ -80,7 +80,7 @@ static double dspacing(Cell cell, double h, double k, double l) } -static double plane_angle(Cell cell, double h1, double k1, double l1, +double plane_angle(Cell cell, double h1, double k1, double l1, double h2, double k2, double l2) { double sum_S_terms, d1, d2, dd_over_Vsq; @@ -29,5 +29,8 @@ typedef struct /* Return what the measurement 'val' would have been if the cell were 'cell' */ extern double crystal_calc(MVal val, Cell cell); +extern double dspacing(Cell cell, double h, double k, double l); +extern double plane_angle(Cell cell, double h1, double k1, double l1, + double h2, double k2, double l2); #endif /* CRYSTAL_H */ @@ -0,0 +1,33 @@ +/* + * test.c + * + * Unit tests + * + * (c) 2009 Thomas White <taw27@cam.ac.uk> + * + * Triclinator - solve nasty triclinic unit cells + * + */ + + +#include <stdlib.h> +#include <stdio.h> +#include <math.h> + +#include "crystal.h" + +int main(void) +{ + Cell cell; + + cell.a = 1.0; + cell.b = 1.0; + cell.c = 1.0; + cell.al = DEG2RAD(90.0); + cell.be = DEG2RAD(120.0); + cell.ga = DEG2RAD(90.0); + + printf("%8.5f deg\n", RAD2DEG(plane_angle(cell, 0, 0, 1, 0, 1, 0))); + + return 0; +} |