t/ guardamos los programas de prueba.
Veamos el Makefile y una ejecución de una prueba:
lhp@nereida:~/Lperl/src/XSUB/h2xsexample/coordlib/t$ cat -n Makefile 1 #Makefile s stands for static d for dynamic 2 alld:01testd.t 02testd.t 3 alls:01tests.t 02tests.t 4 LIBS=../lib 5 INCLUDE=../include 6 7 01testd.t:01test.c ../lib/libpl.so ../include/coord.h 8 cc -g -o 01testd.t 01test.c -L$(LIBS) -I$(INCLUDE) -lm -lpl 9 10 01tests.t:01test.c ../lib/libpl.a ../include/coord.h 11 cc -g -o 01tests.t 01test.c -L$(LIBS) -I$(INCLUDE) -lm -lpl 12 13 02testd.t:02test.c ../lib/libpl.so ../include/coord.h 14 cc -g -o 02testd.t 02test.c -L$(LIBS) -I$(INCLUDE) -lm -lpl 15 16 02tests.t:02test.c ../lib/libpl.a ../include/coord.h 17 cc -g -o 02tests.t 02test.c -L$(LIBS) -I$(INCLUDE) -lm -lpl 18 19 run01:01testd.t 20 LD_LIBRARY_PATH=$(LIBS) ./01testd.t 21 22 run02:02testd.t 23 LD_LIBRARY_PATH=$(LIBS) ./02testd.t 24 25 ../lib/libpl.so:../lib/rc2pl.c ../lib/pl2rc.c ../include/coord.h 26 cd ../lib; make 27 28 .PHONY: clean 29 clean veryclean: 30 -rm -f ??test?.t core lhp@nereida:~/Lperl/src/XSUB/h2xsexample/coordlib/t$ make run01 cd ../lib; make make[1]: se ingresa al directorio `/home/lhp/projects/perl/src/XSUB/h2xsexample/coordlib/lib' cc -I../include -g -c -o pl2rc.o pl2rc.c cc -I../include -g -c -o rc2pl.o rc2pl.c cc -shared -I../include -g pl2rc.o rc2pl.o -o libpl.so make[1]: se sale del directorio `/home/lhp/projects/perl/src/XSUB/h2xsexample/coordlib/lib' cc -g -o 01testd.t 01test.c -L../lib -I../include -lm -lpl LD_LIBRARY_PATH=../lib ./01testd.t Introduce coordenadas polares (mod arg): mod: 1 arg: 0.7853982 Rectangular: 0.707107 0.707107 Polar: 1 0.785398 Introduce coordenadas rectangulares (x y): x: 1 y: 1 Polar: 1.41421 0.785398 Rectangular: 1 1El código de la prueba ejecutada es:
lhp@nereida:~/Lperl/src/XSUB/h2xsexample/coordlib/t$ cat -n 01test.c
 1  #include <stdlib.h>
 2  #include <coord.h>
 3
 4  main() {
 5    polar p;
 6    rectangular r;
 7    char *f = "%g %g";
 8
 9    printf("Introduce coordenadas polares (mod arg):\n");
10    p = getpolar();
11    r = pl2rc(p);
12    printf("Rectangular: %s\n", rectangular2str(f,r));
13    p = rc2pl(r);
14    printf("Polar: %s\n", polar2str(f, p));
15
16    printf("Introduce coordenadas rectangulares (x y):\n");
17    r = getrectangular();
18    p = rc2pl(r);
19    printf("Polar: %s\n", polar2str(f, p));
20    r = pl2rc(p);
21    printf("Rectangular: %s\n", rectangular2str(f,r));
22    exit(0);
23  }
Para completar la información, veamos el código de la otra prueba:
lhp@nereida:~/Lperl/src/XSUB/h2xsexample/coordlib/t$ cat -n 02test.c
 1  #include <stdlib.h>
 2  #include <coord.h>
 3
 4  main() {
 5    double alpha;
 6    rectangular r;
 7    polar p;
 8
 9    p.mod = 1;
10    for(alpha=0; alpha<=PI; alpha+= PI/10) {
11      p.arg = alpha;
12      r = pl2rc(p);
13      printf("Rectangular: %s\n", rectangular2str("%.2lf",r));
14    }
15    exit(0);
16  }
Casiano Rodríguez León
