Add gvc_render and gvc_render tests

This commit is contained in:
c9s 2014-05-18 08:13:58 +08:00
parent dc861157cf
commit 9858c5cd5a
9 changed files with 241 additions and 30 deletions

View file

@ -111,7 +111,7 @@ if ( $error ) {
Install
----------------------
sudo apt-get install check libpcre3 libpcre3-dev libjemalloc-dev libjemalloc1 build-essential libtool automake autoconf
sudo apt-get install check libpcre3 libpcre3-dev libjemalloc-dev libjemalloc1 build-essential libtool automake autoconf graphviz-dev graphviz
./autogen.sh
./configure && make
make check # run tests

View file

@ -816,8 +816,8 @@ cat >>"$ac_tmp/subs1.awk" <<\_ACAWK &&
S["am__EXEEXT_FALSE"]=""
S["am__EXEEXT_TRUE"]="#"
S["LTLIBOBJS"]=""
S["DEPS_LIBS"]="-L/opt/local/lib -lpcre -lcheck "
S["DEPS_CFLAGS"]="-D_THREAD_SAFE -I/opt/local/include "
S["DEPS_LIBS"]="-L/opt/local/lib -lpcre -lcheck -lgvc -lcgraph -lcdt "
S["DEPS_CFLAGS"]="-D_THREAD_SAFE -I/opt/local/include -I/opt/local/include/graphviz "
S["PKG_CONFIG_LIBDIR"]=""
S["PKG_CONFIG_PATH"]=""
S["PKG_CONFIG"]="/opt/local/bin/pkg-config"

18
configure vendored
View file

@ -13131,12 +13131,12 @@ if test -n "$DEPS_CFLAGS"; then
pkg_cv_DEPS_CFLAGS="$DEPS_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpcre check gvc\""; } >&5
($PKG_CONFIG --exists --print-errors "libpcre check gvc") 2>&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpcre check libgvc\""; } >&5
($PKG_CONFIG --exists --print-errors "libpcre check libgvc") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_DEPS_CFLAGS=`$PKG_CONFIG --cflags "libpcre check gvc" 2>/dev/null`
pkg_cv_DEPS_CFLAGS=`$PKG_CONFIG --cflags "libpcre check libgvc" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@ -13148,12 +13148,12 @@ if test -n "$DEPS_LIBS"; then
pkg_cv_DEPS_LIBS="$DEPS_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpcre check gvc\""; } >&5
($PKG_CONFIG --exists --print-errors "libpcre check gvc") 2>&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpcre check libgvc\""; } >&5
($PKG_CONFIG --exists --print-errors "libpcre check libgvc") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_DEPS_LIBS=`$PKG_CONFIG --libs "libpcre check gvc" 2>/dev/null`
pkg_cv_DEPS_LIBS=`$PKG_CONFIG --libs "libpcre check libgvc" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@ -13174,14 +13174,14 @@ else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
DEPS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libpcre check gvc" 2>&1`
DEPS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libpcre check libgvc" 2>&1`
else
DEPS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libpcre check gvc" 2>&1`
DEPS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libpcre check libgvc" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$DEPS_PKG_ERRORS" >&5
as_fn_error $? "Package requirements (libpcre check gvc) were not met:
as_fn_error $? "Package requirements (libpcre check libgvc) were not met:
$DEPS_PKG_ERRORS

View file

@ -106,6 +106,8 @@ void r3_tree_dump(node * n, int level);
int r3_tree_render_file(node * tree, char * format, char * filename);
int r3_tree_render_dot(node * tree);
edge * r3_node_find_edge_str(node * n, char * str, int str_len);

View file

@ -10,12 +10,71 @@
#include <stdlib.h>
#include "r3.h"
// int main(int argc, char **argv)
char * node_id_str(int id) {
char * name = malloc(sizeof(char) * 20);
sprintf(name, "#%d", id);
return name;
}
int r3_tree_build_ag_nodes(Agraph_t * g, Agnode_t * ag_parent_node, node * n, int node_cnt) {
edge * e;
Agnode_t *agn_child;
Agedge_t *agn_edge;
for ( int i = 0 ; i < n->edge_len ; i++ ) {
e = n->edges[i];
node_cnt++;
agn_child = agnode(g, node_id_str(node_cnt) , 1);
agn_edge = agedge(g, ag_parent_node, agn_child, 0, 1);
agsafeset(agn_edge, "label", e->pattern, "");
r3_tree_build_ag_nodes(g, agn_child, e->child, node_cnt);
// agedgeattr(agn_edge, "label", e->pattern );
// agattr(gr, AGEDGE, "style","invis");
// agattr(agn_edge, AGEDGE, "label", "test");
}
}
/**
* Render a tree to tree graph image via graphviz (dot)
*/
int r3_tree_render_dot(node * tree)
{
Agraph_t *g;
/* set up a graphviz context - but only once even for multiple graphs */
static GVC_t *gvc;
if (!gvc) {
gvc = gvContext();
}
/* Create a simple digraph */
g = agopen("g", Agdirected, 0);
// create self node
Agnode_t *ag_root = agnode(g, "{root}", 1);
r3_tree_build_ag_nodes(g, ag_root, tree, 0);
gvLayout(gvc, g, "dot");
gvRender(gvc, g, "dot", stdout);
gvFreeLayout(gvc, g);
agclose(g);
return 0;
}
/**
* Render a tree to tree graph image via graphviz (dot)
*/
int r3_tree_render_file(node * tree, char * format, char * filename)
{
Agraph_t *g;
Agnode_t *n, *m;
Agedge_t *e;
/* set up a graphviz context - but only once even for multiple graphs */
static GVC_t *gvc;
@ -27,13 +86,10 @@ int r3_tree_render_file(node * tree, char * format, char * filename)
/* Create a simple digraph */
g = agopen("g", Agdirected, 0);
n = agnode(g, "n", 1);
m = agnode(g, "m", 1);
e = agedge(g, n, m, 0, 1);
// create self node
Agnode_t *ag_root = agnode(g, "{root}", 1);
r3_tree_build_ag_nodes(g, ag_root, tree, 0);
/* Set an attribute - in this case one that affects the visible rendering */
agsafeset(n, "color", "red", "");
/* Use the directed graph layout engine */
gvLayout(gvc, g, "dot");
gvRenderFilename(gvc, g, format, filename);
gvFreeLayout(gvc, g);

View file

@ -4,12 +4,17 @@
# else
# TESTS =
# endif
TESTS = check_tree
TESTS = check_tree check_gvc
# noinst_PROGRAMS = $(TESTS)
check_PROGRAMS = $(TESTS)
check_tree_SOURCES = check_tree.c bench.c
check_tree_LDADD=$(DEPS_LIBS) -L$(top_builddir)/src -lr3 @CHECK_LIBS@
check_tree_CFLAGS=$(DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include @CHECK_CFLAGS@
check_gvc_SOURCES = check_gvc.c bench.c
check_gvc_LDADD=$(DEPS_LIBS) -L$(top_builddir)/src -lr3 @CHECK_LIBS@
check_gvc_CFLAGS=$(DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include @CHECK_CFLAGS@
# AM_CFLAGS=$(DEPS_CFLAGS) -I$(top_builddir)/include
# AM_CFLAGS=$(DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include
CLEANFILES = check_tree.log

View file

@ -77,7 +77,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
TESTS = check_tree$(EXEEXT)
TESTS = check_tree$(EXEEXT) check_gvc$(EXEEXT)
check_PROGRAMS = $(am__EXEEXT_1)
subdir = tests
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
@ -93,16 +93,23 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__EXEEXT_1 = check_tree$(EXEEXT)
am_check_tree_OBJECTS = check_tree-check_tree.$(OBJEXT) \
check_tree-bench.$(OBJEXT)
check_tree_OBJECTS = $(am_check_tree_OBJECTS)
am__EXEEXT_1 = check_tree$(EXEEXT) check_gvc$(EXEEXT)
am_check_gvc_OBJECTS = check_gvc-check_gvc.$(OBJEXT) \
check_gvc-bench.$(OBJEXT)
check_gvc_OBJECTS = $(am_check_gvc_OBJECTS)
am__DEPENDENCIES_1 =
check_tree_DEPENDENCIES = $(am__DEPENDENCIES_1)
check_gvc_DEPENDENCIES = $(am__DEPENDENCIES_1)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
check_gvc_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(check_gvc_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
am_check_tree_OBJECTS = check_tree-check_tree.$(OBJEXT) \
check_tree-bench.$(OBJEXT)
check_tree_OBJECTS = $(am_check_tree_OBJECTS)
check_tree_DEPENDENCIES = $(am__DEPENDENCIES_1)
check_tree_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(check_tree_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
@ -140,8 +147,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(check_tree_SOURCES)
DIST_SOURCES = $(check_tree_SOURCES)
SOURCES = $(check_gvc_SOURCES) $(check_tree_SOURCES)
DIST_SOURCES = $(check_gvc_SOURCES) $(check_tree_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@ -495,6 +502,10 @@ top_srcdir = @top_srcdir@
check_tree_SOURCES = check_tree.c bench.c
check_tree_LDADD = $(DEPS_LIBS) -L$(top_builddir)/src -lr3 @CHECK_LIBS@
check_tree_CFLAGS = $(DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include @CHECK_CFLAGS@
check_gvc_SOURCES = check_gvc.c bench.c
check_gvc_LDADD = $(DEPS_LIBS) -L$(top_builddir)/src -lr3 @CHECK_LIBS@
check_gvc_CFLAGS = $(DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include @CHECK_CFLAGS@
# AM_CFLAGS=$(DEPS_CFLAGS) -I$(top_builddir)/include
# AM_CFLAGS=$(DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include
CLEANFILES = check_tree.log
@ -542,6 +553,10 @@ clean-checkPROGRAMS:
echo " rm -f" $$list; \
rm -f $$list
check_gvc$(EXEEXT): $(check_gvc_OBJECTS) $(check_gvc_DEPENDENCIES) $(EXTRA_check_gvc_DEPENDENCIES)
@rm -f check_gvc$(EXEEXT)
$(AM_V_CCLD)$(check_gvc_LINK) $(check_gvc_OBJECTS) $(check_gvc_LDADD) $(LIBS)
check_tree$(EXEEXT): $(check_tree_OBJECTS) $(check_tree_DEPENDENCIES) $(EXTRA_check_tree_DEPENDENCIES)
@rm -f check_tree$(EXEEXT)
$(AM_V_CCLD)$(check_tree_LINK) $(check_tree_OBJECTS) $(check_tree_LDADD) $(LIBS)
@ -552,6 +567,8 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_gvc-bench.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_gvc-check_gvc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_tree-bench.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_tree-check_tree.Po@am__quote@
@ -576,6 +593,34 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
check_gvc-check_gvc.o: check_gvc.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_gvc_CFLAGS) $(CFLAGS) -MT check_gvc-check_gvc.o -MD -MP -MF $(DEPDIR)/check_gvc-check_gvc.Tpo -c -o check_gvc-check_gvc.o `test -f 'check_gvc.c' || echo '$(srcdir)/'`check_gvc.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/check_gvc-check_gvc.Tpo $(DEPDIR)/check_gvc-check_gvc.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='check_gvc.c' object='check_gvc-check_gvc.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_gvc_CFLAGS) $(CFLAGS) -c -o check_gvc-check_gvc.o `test -f 'check_gvc.c' || echo '$(srcdir)/'`check_gvc.c
check_gvc-check_gvc.obj: check_gvc.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_gvc_CFLAGS) $(CFLAGS) -MT check_gvc-check_gvc.obj -MD -MP -MF $(DEPDIR)/check_gvc-check_gvc.Tpo -c -o check_gvc-check_gvc.obj `if test -f 'check_gvc.c'; then $(CYGPATH_W) 'check_gvc.c'; else $(CYGPATH_W) '$(srcdir)/check_gvc.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/check_gvc-check_gvc.Tpo $(DEPDIR)/check_gvc-check_gvc.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='check_gvc.c' object='check_gvc-check_gvc.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_gvc_CFLAGS) $(CFLAGS) -c -o check_gvc-check_gvc.obj `if test -f 'check_gvc.c'; then $(CYGPATH_W) 'check_gvc.c'; else $(CYGPATH_W) '$(srcdir)/check_gvc.c'; fi`
check_gvc-bench.o: bench.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_gvc_CFLAGS) $(CFLAGS) -MT check_gvc-bench.o -MD -MP -MF $(DEPDIR)/check_gvc-bench.Tpo -c -o check_gvc-bench.o `test -f 'bench.c' || echo '$(srcdir)/'`bench.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/check_gvc-bench.Tpo $(DEPDIR)/check_gvc-bench.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bench.c' object='check_gvc-bench.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_gvc_CFLAGS) $(CFLAGS) -c -o check_gvc-bench.o `test -f 'bench.c' || echo '$(srcdir)/'`bench.c
check_gvc-bench.obj: bench.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_gvc_CFLAGS) $(CFLAGS) -MT check_gvc-bench.obj -MD -MP -MF $(DEPDIR)/check_gvc-bench.Tpo -c -o check_gvc-bench.obj `if test -f 'bench.c'; then $(CYGPATH_W) 'bench.c'; else $(CYGPATH_W) '$(srcdir)/bench.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/check_gvc-bench.Tpo $(DEPDIR)/check_gvc-bench.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bench.c' object='check_gvc-bench.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_gvc_CFLAGS) $(CFLAGS) -c -o check_gvc-bench.obj `if test -f 'bench.c'; then $(CYGPATH_W) 'bench.c'; else $(CYGPATH_W) '$(srcdir)/bench.c'; fi`
check_tree-check_tree.o: check_tree.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(check_tree_CFLAGS) $(CFLAGS) -MT check_tree-check_tree.o -MD -MP -MF $(DEPDIR)/check_tree-check_tree.Tpo -c -o check_tree-check_tree.o `test -f 'check_tree.c' || echo '$(srcdir)/'`check_tree.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/check_tree-check_tree.Tpo $(DEPDIR)/check_tree-check_tree.Po
@ -810,6 +855,13 @@ check_tree.log: check_tree$(EXEEXT)
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
check_gvc.log: check_gvc$(EXEEXT)
@p='check_gvc$(EXEEXT)'; \
b='check_gvc'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
.test.log:
@p='$<'; \
$(am__set_b); \

View file

@ -57,3 +57,24 @@
1400283485,10742869.09
1400283755,11545078.70
1400284307,11493777.72
1400370342,11414560.92
1400370407,10759059.85
1400370448,10686226.48
1400370672,10532221.14
1400370683,10874340.04
1400370920,11307031.13
1400371082,9136908.63
1400371092,11106355.37
1400371132,11313608.81
1400371165,10266146.59
1400371326,10644609.51
1400371371,10958943.43
1400371431,10145302.26
1400371504,11383090.96
1400371511,10023676.85
1400371561,10912042.58
1400371589,11439666.09
1400371602,11012616.42
1400371709,11058171.50
1400371751,11091926.38
1400371943,11103873.79

1 1400242718 5649455.80
57 1400283485 10742869.09
58 1400283755 11545078.70
59 1400284307 11493777.72
60 1400370342 11414560.92
61 1400370407 10759059.85
62 1400370448 10686226.48
63 1400370672 10532221.14
64 1400370683 10874340.04
65 1400370920 11307031.13
66 1400371082 9136908.63
67 1400371092 11106355.37
68 1400371132 11313608.81
69 1400371165 10266146.59
70 1400371326 10644609.51
71 1400371371 10958943.43
72 1400371431 10145302.26
73 1400371504 11383090.96
74 1400371511 10023676.85
75 1400371561 10912042.58
76 1400371589 11439666.09
77 1400371602 11012616.42
78 1400371709 11058171.50
79 1400371751 11091926.38
80 1400371943 11103873.79

75
tests/check_gvc.c Normal file
View file

@ -0,0 +1,75 @@
/*
* check_gvc.c
* Copyright (C) 2014 c9s <c9s@c9smba.local>
*
* Distributed under terms of the MIT license.
*/
#include "config.h"
#include <stdio.h>
#include <check.h>
#include <stdlib.h>
#include "r3.h"
#include "r3_str.h"
#include "str_array.h"
#include "bench.h"
START_TEST (test_gvc_render_dot)
{
node * n = r3_tree_create(1);
r3_tree_insert_path(n, "/foo/bar/baz", NULL);
r3_tree_insert_path(n, "/foo/bar/qux", NULL);
r3_tree_insert_path(n, "/foo/bar/quux", NULL);
r3_tree_insert_path(n, "/foo/bar/corge", NULL);
r3_tree_insert_path(n, "/foo/bar/grault", NULL);
r3_tree_insert_path(n, "/garply/grault/foo", NULL);
r3_tree_insert_path(n, "/garply/grault/bar", NULL);
r3_tree_compile(n);
r3_tree_render_dot(n);
r3_tree_free(n);
}
END_TEST
START_TEST (test_gvc_render_file)
{
node * n = r3_tree_create(1);
r3_tree_insert_path(n, "/foo/bar/baz", NULL);
r3_tree_insert_path(n, "/foo/bar/qux", NULL);
r3_tree_insert_path(n, "/foo/bar/quux", NULL);
r3_tree_insert_path(n, "/foo/bar/corge", NULL);
r3_tree_insert_path(n, "/foo/bar/grault", NULL);
r3_tree_insert_path(n, "/garply/grault/foo", NULL);
r3_tree_insert_path(n, "/garply/grault/bar", NULL);
r3_tree_compile(n);
r3_tree_render_file(n, "png", "check_gvc.png");
r3_tree_free(n);
}
END_TEST
Suite* r3_suite (void) {
Suite *suite = suite_create("gvc test");
TCase *tcase = tcase_create("test_gvc");
tcase_add_test(tcase, test_gvc_render_file);
tcase_add_test(tcase, test_gvc_render_dot);
suite_add_tcase(suite, tcase);
return suite;
}
int main (int argc, char *argv[]) {
int number_failed;
Suite *suite = r3_suite();
SRunner *runner = srunner_create(suite);
srunner_run_all(runner, CK_NORMAL);
number_failed = srunner_ntests_failed(runner);
srunner_free(runner);
return number_failed;
}