mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2025-04-21 12:27:27 +03:00
poly2d/: Yet another 2D polygon library (WIP)
This commit is contained in:
99
poly2d/test/Common
Executable file
99
poly2d/test/Common
Executable file
@@ -0,0 +1,99 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Common - Elements shared by all regression tests for poly2d
|
||||
#
|
||||
# Written 2010, 2011 by Werner Almesberger
|
||||
# Copyright 2010, 2011 Werner Almesberger
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
|
||||
|
||||
compile_and_run()
|
||||
{
|
||||
LIBS="-lpoly2d -lCGAL -lCGAL_Core -lboost_thread"
|
||||
LIBS="$LIBS -lstdc++ -lmpfr -lgmp -lm"
|
||||
|
||||
cat <<EOF >_.c
|
||||
#include <poly2d.h>
|
||||
#include "p2d_hsort.h"
|
||||
|
||||
|
||||
static void recurse_hier(const struct p2d_hier *h, int level)
|
||||
{
|
||||
const struct v2d *v;
|
||||
|
||||
while (h) {
|
||||
printf("%*s", level*2, "");
|
||||
v = h->p.v;
|
||||
while (v) {
|
||||
printf("%s%g %g", v == h->p.v ? "" : " ", v->x, v->y);
|
||||
v = v->next;
|
||||
if (v == h->p.v)
|
||||
break;
|
||||
}
|
||||
printf("\n");
|
||||
recurse_hier(h->holes, level+1);
|
||||
h = p2d_to_hier(h->p.next);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void __attribute__((unused)) print_hier(const struct p2d_hier *h)
|
||||
{
|
||||
recurse_hier(h, 0);
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
`cat _in`
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
gcc -Wall -Werror -g -I.. _.c -L.. $LIBS || return
|
||||
$VALGRIND ./a.out
|
||||
}
|
||||
|
||||
|
||||
tst()
|
||||
{
|
||||
echo -n "$1: " 1>&2
|
||||
shift
|
||||
cat >_in
|
||||
compile_and_run "$@" >_out 2>&1 || {
|
||||
echo FAILED "($SCRIPT)" 1>&2
|
||||
cat _out
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tst_fail()
|
||||
{
|
||||
echo -n "$1: " 1>&2
|
||||
shift
|
||||
cat >_in
|
||||
compile_and_run "$@" >_out 2>&1 && {
|
||||
echo FAILED "($SCRIPT)" 1>&2
|
||||
cat _out
|
||||
exit 1
|
||||
}
|
||||
rm -f _in _.c a.out
|
||||
}
|
||||
|
||||
|
||||
expect()
|
||||
{
|
||||
diff -u - "$@" _out >_diff || {
|
||||
echo FAILED "($SCRIPT)" 1>&2
|
||||
cat _diff 1>&2
|
||||
exit 1
|
||||
}
|
||||
echo PASSED 1>&2
|
||||
rm -f _in _out _diff _.c a.out
|
||||
passed=`expr ${passed:-0} + 1`
|
||||
}
|
||||
Reference in New Issue
Block a user