Commit ce82026f authored by Paul Asmuth's avatar Paul Asmuth
Browse files

separate test suite into unit tests and spec tests

parent 7233d309
Loading
Loading
Loading
Loading
+17 −8
Original line number Diff line number Diff line
@@ -60,15 +60,24 @@ set(SIGNALTK_LDFLAGS signaltk ${CAIRO_LIBRARIES} ${FREETYPE_LIBRARIES} ${HARFBUZ
add_executable(plotfx platform/signaltk_cli.cc)
target_link_libraries(plotfx ${SIGNALTK_LDFLAGS})

file(GLOB test_files "testing/unit/test_*.cc")
foreach(test_path ${test_files})
  get_filename_component(test_name ${test_path} NAME_WE)
  get_filename_component(test_srcdir ${test_path} DIRECTORY)
file(GLOB unit_test_files "testing/**/test_*.cc")
foreach(unit_test_path ${unit_test_files})
  get_filename_component(unit_test_name ${unit_test_path} NAME_WE)
  get_filename_component(unit_test_srcdir ${unit_test_path} DIRECTORY)

  add_executable(${test_name} ${test_path})
  target_link_libraries(${test_name} ${SIGNALTK_LDFLAGS})
  add_executable(${unit_test_name} ${unit_test_path})
  target_link_libraries(${unit_test_name} ${SIGNALTK_LDFLAGS})

  add_test(
      NAME ${test_name}
      COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/testing/test_runner.sh ${CMAKE_CURRENT_BINARY_DIR}/${test_name} ${test_srcdir}/${test_name}.png)
      NAME ${unit_test_name}
      COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${unit_test_name})
endforeach()

file(GLOB spec_test_files "testing/**/test_*.spec")
foreach(spec_test_path ${spec_test_files})
  get_filename_component(spec_test_name ${spec_test_path} NAME_WE)
  get_filename_component(spec_test_srcdir ${spec_test_path} DIRECTORY)
  add_test(
      NAME ${spec_test_name}
      COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/testing/test_runner.sh ${CMAKE_CURRENT_BINARY_DIR}/plotfx ${spec_test_path} ${CMAKE_CURRENT_BINARY_DIR}/${spec_test_name}.png ${spec_test_srcdir}/${spec_test_name}.png)
endforeach()
+5.6 KiB
Loading image diff...
+4 −0
Original line number Diff line number Diff line
plot {
  axis-top: off;
  axis-right: off;
}

testing/plot/test_axes_simple.cc

deleted100644 → 0
+0 −81
Original line number Diff line number Diff line
/**
 * This file is part of the "signaltk" project
 *   Copyright (c) 2018 Paul Asmuth
 *
 * libstx is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License v3.0. You should have received a
 * copy of the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */
#include "elements/plot/plot_element.h"
#include "elements/context.h"
#include "../unittest.h"

using namespace signaltk;
using namespace signaltk::chart;

int main(int argc, char** argv) {
  auto ctx = context_create_image(1200, 800);
  context_frame(ctx)->clear(Colour{1, 1, 1, 1});

  CHECK_RC(plot_add(ctx));

  CHECK_RC(plot_axis_add(ctx, AxisPosition::LEFT));
  CHECK_RC(plot_axis_addtick(ctx, 0.0f));
  CHECK_RC(plot_axis_addtick(ctx, 0.2f));
  CHECK_RC(plot_axis_addtick(ctx, 0.4f));
  CHECK_RC(plot_axis_addtick(ctx, 0.6f));
  CHECK_RC(plot_axis_addtick(ctx, 0.8f));
  CHECK_RC(plot_axis_addtick(ctx, 1.0f));
  CHECK_RC(plot_axis_addlabel(ctx, 0.0f, "1"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.2f, "2"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.4f, "3"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.6f, "4"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.8f, "5"));
  CHECK_RC(plot_axis_addlabel(ctx, 1.0f, "6"));

  CHECK_RC(plot_axis_add(ctx, AxisPosition::RIGHT));
  CHECK_RC(plot_axis_addtick(ctx, 0.0f));
  CHECK_RC(plot_axis_addtick(ctx, 0.2f));
  CHECK_RC(plot_axis_addtick(ctx, 0.4f));
  CHECK_RC(plot_axis_addtick(ctx, 0.6f));
  CHECK_RC(plot_axis_addtick(ctx, 0.8f));
  CHECK_RC(plot_axis_addtick(ctx, 1.0f));
  CHECK_RC(plot_axis_addlabel(ctx, 0.1f, "A"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.3f, "B"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.5f, "C"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.7f, "D"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.9f, "E"));

  CHECK_RC(plot_axis_add(ctx, AxisPosition::TOP));
  CHECK_RC(plot_axis_addtick(ctx, 0.0f));
  CHECK_RC(plot_axis_addtick(ctx, 0.2f));
  CHECK_RC(plot_axis_addtick(ctx, 0.4f));
  CHECK_RC(plot_axis_addtick(ctx, 0.6f));
  CHECK_RC(plot_axis_addtick(ctx, 0.8f));
  CHECK_RC(plot_axis_addtick(ctx, 1.0f));
  CHECK_RC(plot_axis_addlabel(ctx, 0.1f, "A"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.3f, "B"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.5f, "C"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.7f, "D"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.9f, "E"));

  CHECK_RC(plot_axis_add(ctx, AxisPosition::BOTTOM));
  CHECK_RC(plot_axis_addtick(ctx, 0.0f));
  CHECK_RC(plot_axis_addtick(ctx, 0.2f));
  CHECK_RC(plot_axis_addtick(ctx, 0.4f));
  CHECK_RC(plot_axis_addtick(ctx, 0.6f));
  CHECK_RC(plot_axis_addtick(ctx, 0.8f));
  CHECK_RC(plot_axis_addtick(ctx, 1.0f));
  CHECK_RC(plot_axis_addlabel(ctx, 0.0f, "1"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.2f, "2"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.4f, "3"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.6f, "4"));
  CHECK_RC(plot_axis_addlabel(ctx, 0.8f, "5"));
  CHECK_RC(plot_axis_addlabel(ctx, 1.0f, "6"));

  CHECK_RC(plot_render(ctx));

  CHECK_RC(context_frame(ctx)->writeToFile(std::string(argv[0]) + ".png"));
}

testing/plot/test_axes_simple.png

deleted100644 → 0
−10.6 KiB
Loading image diff...
Loading