diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2020-04-30 14:45:23 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2020-04-30 14:45:23 +0200 |
commit | 9381fa7219cbd4bbd436d1a815b542250961827b (patch) | |
tree | a1370eaf0380b3be747525a2b710de1ff53f27ff /tests/test-surface.cc | |
parent | 1392cfda4b5ba97bf2a0560e56638ec78304b2d1 (diff) |
tests: Update the source code
These updates have been copied from the master branch, where
the BOOST_AUTO_TEST_*() macros were introduced by Chun-wei Fan.
Diffstat (limited to 'tests/test-surface.cc')
-rw-r--r-- | tests/test-surface.cc | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/tests/test-surface.cc b/tests/test-surface.cc index 3f5bf1a..0525cbf 100644 --- a/tests/test-surface.cc +++ b/tests/test-surface.cc @@ -13,23 +13,25 @@ ErrorStatus test_slot(const unsigned char* /*data*/, unsigned int /*len*/) return CAIRO_STATUS_SUCCESS; } -void test_write_to_png_stream() +BOOST_AUTO_TEST_SUITE( Cairo_Surface ) + +BOOST_AUTO_TEST_CASE(test_write_to_png_stream) { auto surface = ImageSurface::create(FORMAT_ARGB32, 1, 1); surface->write_to_png_stream(sigc::ptr_fun(test_slot)); BOOST_CHECK(test_slot_called > 0); } -void test_pdf_constructor_slot() +BOOST_AUTO_TEST_CASE(test_pdf_constructor_slot) { - test_slot_called = nullptr; + test_slot_called = 0; auto pdf = PdfSurface::create_for_stream(sigc::ptr_fun(&test_slot), 1, 1); pdf->show_page(); pdf->finish(); BOOST_CHECK(test_slot_called > 0); } -void test_ps_constructor_slot() +BOOST_AUTO_TEST_CASE(test_ps_constructor_slot) { test_slot_called = 0; auto ps = PsSurface::create_for_stream(sigc::ptr_fun(&test_slot), 1, 1); @@ -38,7 +40,7 @@ void test_ps_constructor_slot() BOOST_CHECK(test_slot_called > 0); } -void test_svg_constructor_slot() +BOOST_AUTO_TEST_CASE(test_svg_constructor_slot) { test_slot_called = 0; auto svg = SvgSurface::create_for_stream(sigc::ptr_fun(&test_slot), 1, 1); @@ -66,7 +68,7 @@ static cairo_status_t c_test_read_func(void* /*closure*/, unsigned char* data, u return CAIRO_STATUS_READ_ERROR; } -void test_create_from_png() +BOOST_AUTO_TEST_CASE(test_create_from_png) { RefPtr<ImageSurface> surface; // try the sigc::slot version @@ -82,7 +84,7 @@ void test_create_from_png() BOOST_CHECK(c_test_read_func_called > 0); } -void test_ps_eps() +BOOST_AUTO_TEST_CASE(test_ps_eps) { auto ps = PsSurface::create("test.ps", 1, 1); // check the initial value @@ -93,7 +95,7 @@ void test_ps_eps() BOOST_CHECK_EQUAL(ps->get_eps(), !result); } -void test_content() +BOOST_AUTO_TEST_CASE(test_content) { auto surface = ImageSurface::create(FORMAT_ARGB32, 1, 1); BOOST_CHECK_EQUAL(surface->get_content(), CONTENT_COLOR_ALPHA); @@ -102,7 +104,7 @@ void test_content() BOOST_CHECK_EQUAL(similar->get_content(), CONTENT_ALPHA); } -void test_fallback_resolution() +BOOST_AUTO_TEST_CASE(test_fallback_resolution) { auto surface = ImageSurface::create(FORMAT_ARGB32, 1, 1); double x, y; @@ -114,33 +116,14 @@ void test_fallback_resolution() BOOST_CHECK_EQUAL(y, new_y); } -void test_show_text_glyphs() +BOOST_AUTO_TEST_CASE(test_show_text_glyphs) { // image surface doesn't support show_text_glyphs - auto surf = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 10, 10); \ + Cairo::RefPtr<Cairo::Surface> surf = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 10, 10); BOOST_CHECK(!surf->has_show_text_glyphs()); // but pdf surface should surf = Cairo::PdfSurface::create("test.pdf", 10.0, 10.0); BOOST_CHECK(surf->has_show_text_glyphs()); } - -test_suite* -init_unit_test_suite(int argc, char* argv[]) -{ - // compile even with -Werror - if (argc && argv) {} - - test_suite* test= BOOST_TEST_SUITE( "Cairo::Surface Tests" ); - - test->add (BOOST_TEST_CASE (&test_write_to_png_stream)); - test->add (BOOST_TEST_CASE (&test_pdf_constructor_slot)); - test->add (BOOST_TEST_CASE (&test_ps_constructor_slot)); - test->add (BOOST_TEST_CASE (&test_svg_constructor_slot)); - test->add (BOOST_TEST_CASE (&test_create_from_png)); - test->add (BOOST_TEST_CASE (&test_ps_eps)); - test->add (BOOST_TEST_CASE (&test_content)); - test->add (BOOST_TEST_CASE (&test_show_text_glyphs)); - - return test; -} +BOOST_AUTO_TEST_SUITE_END() |