Skip to content

Commit

Permalink
Added a test for plotting in layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Giovanni [dacav] Simoni committed Jun 22, 2010
1 parent 76c3906 commit 42b772c
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/gnupplus/gnuplot.hpp
Expand Up @@ -46,8 +46,8 @@ namespace gnup {
throw (LayoutError);

private:

Layout *layout;

};

}
Expand Down
1 change: 1 addition & 0 deletions src/plots.cpp
Expand Up @@ -100,6 +100,7 @@ namespace gnup {

void Plot::reset (Comm *c)
{
c->command("e\n");
}

void Plot::setTrigger (Trigger *t)
Expand Down
3 changes: 2 additions & 1 deletion src/tests/Makefile.am
Expand Up @@ -19,12 +19,13 @@

AM_CPPFLAGS = -I$(top_srcdir)/src/ -I./ -Wall -Werror -D_GNU_SOURCE

check_PROGRAMS = example simpleplot
check_PROGRAMS = example simpleplot layout0

TESTS = $(check_PROGRAMS)
AM_LDFLAGS = -L$(top_srcdir)/src/ -L./ -L../
LDADD = -lgnupplus

example_SOURCES = example.cpp test_environ.c test_environ.h
simpleplot_SOURCES = simpleplot.cpp test_environ.c test_environ.h
layout0_SOURCES = layout0.cpp test_environ.c test_environ.h

67 changes: 67 additions & 0 deletions src/tests/layout0.cpp
@@ -0,0 +1,67 @@
#include <gnupplus.hpp>
#include <cstdio>
#include <assert.h>
#include "test_environ.h"

static const char* tale[] = {
"set multiplot",
"set size 0.500000,0.500000",
"set origin 0.000000,0.000000",
"plot \"-\" with linespoints",
"1.000000",
"2.000000",
"3.000000",
"2.000000",
"1.000000",
"e",
"set origin 0.500000,0.500000",
"plot \"-\" with linespoints",
"1.000000",
"2.000000",
"3.000000",
"2.000000",
"1.000000",
"e",
"set size 1,1",
"unset multiplot",
NULL
};

int main (int argc, char **argv)
{
inloop_t io;

build_environment();
assert(inloop_create(&io, "testecho", argv[0]) == 0);

gnup::Layout layout (2, 2);

/* VERY IMPORTANT NOTE! In order to ensure determinism, the object
* must be deallocated before the check, since you may accidentally
* check the file before it gets written!
*
* This operation must be achieved explicitly in the library test, but
* it's not necessary while using the library.
*/
gnup::GnuPlot *gp = new gnup::GnuPlot("testecho", io.params);
gnup::Plot2D plot ("Test plot", gnup::AUTO, gnup::DATA);

gp->setLayout(layout);
gp->addPlot(plot, 0, 0);
gp->addPlot(plot, 1, 1);

plot.setStyle(gnup::Plot::LINESPOINTS);
plot.addVector(0, 1);
plot.addVector(0, 2);
plot.addVector(0, 3);
plot.addVector(0, 2);
plot.addVector(0, 1);
gp->trig();

delete gp;

assert(inloop_compare(&io, tale));
inloop_destroy(&io);

return 0;
}
2 changes: 2 additions & 0 deletions src/tests/simpleplot.cpp
Expand Up @@ -11,6 +11,7 @@ static const char* tale[] = {
"3.000000",
"2.000000",
"1.000000",
"e",
"plot \"-\" with linespoints",
"1.000000",
"2.000000",
Expand All @@ -20,6 +21,7 @@ static const char* tale[] = {
"40.000000",
"41.000000",
"50.000000",
"e",
NULL
};

Expand Down

0 comments on commit 42b772c

Please sign in to comment.