diff options
author | Murray Cumming <murrayc@murrayc.com> | 2015-07-31 11:54:29 +0200 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2015-07-31 11:56:33 +0200 |
commit | 8dfbf6c19e0187e7cc5010e617cf4f4b3e227867 (patch) | |
tree | fe45cbd742d9f05826c934c460fbaf288ad48602 /tests | |
parent | 89e0d60963fffb66cbc7ef34dbfd5fbdf26f81c2 (diff) |
C++11: Use auto.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-context.cc | 40 | ||||
-rw-r--r-- | tests/test-font-face.cc | 12 | ||||
-rw-r--r-- | tests/test-font-options.cc | 8 | ||||
-rw-r--r-- | tests/test-matrix.cc | 10 | ||||
-rw-r--r-- | tests/test-scaled-font.cc | 28 | ||||
-rw-r--r-- | tests/test-surface.cc | 18 | ||||
-rw-r--r-- | tests/test-user-font.cc | 12 |
7 files changed, 64 insertions, 64 deletions
diff --git a/tests/test-context.cc b/tests/test-context.cc index a52bab1..6104640 100644 --- a/tests/test-context.cc +++ b/tests/test-context.cc @@ -15,8 +15,8 @@ using namespace boost::unit_test; #include <cairomm/scaledfont.h> #define CREATE_CONTEXT(varname) \ - Cairo::RefPtr<Cairo::Surface> surf = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 10, 10); \ - Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surf); + auto surf = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 10, 10); \ + auto cr = Cairo::Context::create(surf); void test_dashes () @@ -83,14 +83,14 @@ void test_source () { CREATE_CONTEXT(cr); - Cairo::RefPtr<Cairo::Pattern> solid_pattern = + auto solid_pattern = Cairo::SolidPattern::create_rgb (1.0, 0.5, 0.25); - Cairo::RefPtr<Cairo::Pattern> gradient_pattern = + auto gradient_pattern = Cairo::LinearGradient::create (0.0, 0.0, 1.0, 1.0); cr->set_source (solid_pattern); { - Cairo::RefPtr<Cairo::SolidPattern> retrieved_solid = + auto retrieved_solid = Cairo::RefPtr<Cairo::SolidPattern>::cast_dynamic(cr->get_source ()); BOOST_REQUIRE (retrieved_solid); double r, g, b, a; @@ -100,15 +100,15 @@ test_source () BOOST_CHECK_EQUAL (0.25, b); // now try for const objects.. - Cairo::RefPtr<const Cairo::Context> cr2 = cr; - Cairo::RefPtr<const Cairo::SolidPattern> retrieved_solid2 = + auto cr2 = cr; + auto retrieved_solid2 = Cairo::RefPtr<const Cairo::SolidPattern>::cast_dynamic(cr2->get_source ()); BOOST_REQUIRE (retrieved_solid2); } cr->set_source (gradient_pattern); { - Cairo::RefPtr<Cairo::LinearGradient> retrieved_linear = + auto retrieved_linear = Cairo::RefPtr<Cairo::LinearGradient>::cast_dynamic(cr->get_source ()); BOOST_REQUIRE (retrieved_linear); double x0, x1, y0, y1; @@ -121,7 +121,7 @@ test_source () cr->set_source_rgb (1.0, 0.5, 0.25); { - Cairo::RefPtr<Cairo::SolidPattern> solid = + auto solid = Cairo::RefPtr<Cairo::SolidPattern>::cast_dynamic(cr->get_source ()); BOOST_REQUIRE (solid); double rx, gx, bx, ax; @@ -132,7 +132,7 @@ test_source () } cr->set_source_rgba (0.1, 0.3, 0.5, 0.7); { - Cairo::RefPtr<Cairo::SolidPattern> solid = + auto solid = Cairo::RefPtr<Cairo::SolidPattern>::cast_dynamic(cr->get_source ()); BOOST_REQUIRE (solid); double rx, gx, bx, ax; @@ -225,7 +225,7 @@ test_matrix () cr->set_matrix(matrix); cr->set_identity_matrix (); cr->get_matrix (matrix); - Cairo::Matrix m2 = cr->get_matrix (); + auto m2 = cr->get_matrix (); } void @@ -299,22 +299,22 @@ test_current_point () void test_target () { - Cairo::RefPtr<Cairo::Surface> surf = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 10, 10); \ - Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surf); + auto surf = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 10, 10); \ + auto cr = Cairo::Context::create(surf); - Cairo::RefPtr<Cairo::ImageSurface> target_surface = + auto target_surface = Cairo::RefPtr<Cairo::ImageSurface>::cast_dynamic(cr->get_target ()); - Cairo::RefPtr<Cairo::PdfSurface> bad_surface = + auto bad_surface = Cairo::RefPtr<Cairo::PdfSurface>::cast_dynamic(cr->get_target ()); BOOST_CHECK (target_surface); BOOST_CHECK (!bad_surface); // now check for const objects... - Cairo::RefPtr<const Cairo::Context> cr2 = Cairo::Context::create(surf); + auto cr2 = Cairo::Context::create(surf); - Cairo::RefPtr<const Cairo::ImageSurface> target_surface2 = + auto target_surface2 = Cairo::RefPtr<const Cairo::ImageSurface>::cast_dynamic(cr2->get_target ()); - Cairo::RefPtr<const Cairo::PdfSurface> bad_surface2 = + auto bad_surface2 = Cairo::RefPtr<const Cairo::PdfSurface>::cast_dynamic(cr2->get_target ()); BOOST_CHECK (target_surface2); BOOST_CHECK (!bad_surface2); @@ -323,12 +323,12 @@ test_target () void test_scaled_font() { CREATE_CONTEXT (cr); - Cairo::RefPtr<Cairo::ToyFontFace> face = Cairo::ToyFontFace::create("sans", + auto face = Cairo::ToyFontFace::create("sans", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL); Cairo::Matrix identity; cairo_matrix_init_identity(&identity); - Cairo::RefPtr<Cairo::ScaledFont> font = Cairo::ScaledFont::create(face, + auto font = Cairo::ScaledFont::create(face, identity, identity, Cairo::FontOptions()); diff --git a/tests/test-font-face.cc b/tests/test-font-face.cc index 466f408..280f1a1 100644 --- a/tests/test-font-face.cc +++ b/tests/test-font-face.cc @@ -26,7 +26,7 @@ using namespace boost::unit_test; void test_create_toy () { - Cairo::RefPtr<Cairo::ToyFontFace> toy = + auto toy = Cairo::ToyFontFace::create("sans", Cairo::FONT_SLANT_ITALIC, Cairo::FONT_WEIGHT_NORMAL); @@ -36,7 +36,7 @@ test_create_toy () void test_toy_getters () { - Cairo::RefPtr<Cairo::ToyFontFace> toy = + auto toy = Cairo::ToyFontFace::create("sans", Cairo::FONT_SLANT_ITALIC, Cairo::FONT_WEIGHT_NORMAL); @@ -49,19 +49,19 @@ void test_toy_getters () #ifdef CAIRO_HAS_FT_FONT void test_ft_font_face() { - FcPattern* invalid = FcPatternCreate(); + auto invalid = FcPatternCreate(); Cairo::RefPtr<Cairo::FtFontFace> invalid_face; BOOST_CHECK_THROW(invalid_face = Cairo::FtFontFace::create(invalid), std::bad_alloc); // basically taken from the cairo test case -- we don't care what font we're // using so just create an empty pattern and do the minimal substitution to // get a valid pattern - FcPattern* pattern = FcPatternCreate(); + auto pattern = FcPatternCreate(); FcConfigSubstitute (NULL, pattern, FcMatchPattern); FcDefaultSubstitute (pattern); FcResult result; - FcPattern* resolved = FcFontMatch (NULL, pattern, &result); - Cairo::RefPtr<Cairo::FtFontFace> face = Cairo::FtFontFace::create(resolved); + auto resolved = FcFontMatch (NULL, pattern, &result); + auto face = Cairo::FtFontFace::create(resolved); BOOST_CHECK(face); // FIXME: test creating from a FT_Face diff --git a/tests/test-font-options.cc b/tests/test-font-options.cc index a6690f8..7b42398 100644 --- a/tests/test-font-options.cc +++ b/tests/test-font-options.cc @@ -18,19 +18,19 @@ void test_excercise() options.hash(); options.set_antialias(Cairo::ANTIALIAS_SUBPIXEL); - Cairo::Antialias antialias = options.get_antialias(); + auto antialias = options.get_antialias(); BOOST_CHECK_EQUAL(Cairo::ANTIALIAS_SUBPIXEL, antialias); options.set_subpixel_order(Cairo::SUBPIXEL_ORDER_DEFAULT); - Cairo::SubpixelOrder order = options.get_subpixel_order(); + auto order = options.get_subpixel_order(); BOOST_CHECK_EQUAL(Cairo::SUBPIXEL_ORDER_DEFAULT, order); options.set_hint_style(Cairo::HINT_STYLE_SLIGHT); - Cairo::HintStyle hint_style = options.get_hint_style(); + auto hint_style = options.get_hint_style(); BOOST_CHECK_EQUAL(Cairo::HINT_STYLE_SLIGHT, hint_style); options.set_hint_metrics(Cairo::HINT_METRICS_OFF); - Cairo::HintMetrics metrics = options.get_hint_metrics(); + auto metrics = options.get_hint_metrics(); BOOST_CHECK_EQUAL(Cairo::HINT_METRICS_OFF, metrics); } diff --git a/tests/test-matrix.cc b/tests/test-matrix.cc index 02ed4a2..722f8e7 100644 --- a/tests/test-matrix.cc +++ b/tests/test-matrix.cc @@ -74,8 +74,8 @@ static void foo(cairo_matrix_t* matrix) void test_cast() { // make sure that we can cast between C++ and C types without ill effect - Cairo::Matrix matrix = Cairo::identity_matrix(); - cairo_matrix_t casted = (cairo_matrix_t) Cairo::identity_matrix(); + auto matrix = Cairo::identity_matrix(); + auto casted = (cairo_matrix_t) Cairo::identity_matrix(); // check that it's equal to the identity matrix cairo_matrix_t identity; cairo_matrix_init_identity(&identity); @@ -99,9 +99,9 @@ void test_cast() void test_multiply() { - Cairo::Matrix A = Cairo::scaling_matrix(2, 4); - Cairo::Matrix B = Cairo::translation_matrix(5.3, 1.2); - Cairo::Matrix C = A * B; + auto A = Cairo::scaling_matrix(2, 4); + auto B = Cairo::translation_matrix(5.3, 1.2); + auto C = A * B; Cairo::Matrix D; D.multiply(A, B); BOOST_CHECK_EQUAL(C, D); diff --git a/tests/test-scaled-font.cc b/tests/test-scaled-font.cc index e1798b6..8a60725 100644 --- a/tests/test-scaled-font.cc +++ b/tests/test-scaled-font.cc @@ -9,10 +9,10 @@ using namespace Cairo; void test_construction() { - RefPtr<ToyFontFace> face = ToyFontFace::create("sans", FONT_SLANT_NORMAL, FONT_WEIGHT_NORMAL); + auto face = ToyFontFace::create("sans", FONT_SLANT_NORMAL, FONT_WEIGHT_NORMAL); Matrix identity; cairo_matrix_init_identity(&identity); - RefPtr<ScaledFont> font = ScaledFont::create(face, identity, identity, FontOptions()); + auto font = ScaledFont::create(face, identity, identity, FontOptions()); BOOST_REQUIRE(font); // now use the default argument for font_options @@ -22,10 +22,10 @@ void test_construction() void test_text_to_glyphs() { - RefPtr<ToyFontFace> face = ToyFontFace::create("sans", FONT_SLANT_NORMAL, FONT_WEIGHT_NORMAL); + auto face = ToyFontFace::create("sans", FONT_SLANT_NORMAL, FONT_WEIGHT_NORMAL); Matrix identity; cairo_matrix_init_identity(&identity); - RefPtr<ScaledFont> font = ScaledFont::create(face, identity, identity, FontOptions()); + auto font = ScaledFont::create(face, identity, identity, FontOptions()); BOOST_REQUIRE(font); std::vector<Glyph> glyphs; @@ -39,10 +39,10 @@ void test_text_to_glyphs() void test_scale_matrix() { - RefPtr<ToyFontFace> face = ToyFontFace::create("sans", FONT_SLANT_NORMAL, FONT_WEIGHT_NORMAL); + auto face = ToyFontFace::create("sans", FONT_SLANT_NORMAL, FONT_WEIGHT_NORMAL); Matrix m; cairo_matrix_init_scale(&m, 2.0, 4.0); - RefPtr<ScaledFont> font = ScaledFont::create(face, m, m, FontOptions()); + auto font = ScaledFont::create(face, m, m, FontOptions()); BOOST_REQUIRE(font); Matrix result; @@ -55,14 +55,14 @@ void test_get_font_face() // this is to test for a bug where we were accidentally freeing the resulting // font face from a call to ScaledFont::get_font_face() when we didn't hold a // reference to it - RefPtr<ToyFontFace> face = ToyFontFace::create("sans", FONT_SLANT_NORMAL, FONT_WEIGHT_NORMAL); + auto face = ToyFontFace::create("sans", FONT_SLANT_NORMAL, FONT_WEIGHT_NORMAL); Matrix identity; cairo_matrix_init_identity(&identity); - RefPtr<ScaledFont> font = ScaledFont::create(face, identity, identity, FontOptions()); + auto font = ScaledFont::create(face, identity, identity, FontOptions()); BOOST_REQUIRE(font); const int refcount = cairo_font_face_get_reference_count(face->cobj()); { - RefPtr<FontFace> got_face = font->get_font_face(); + auto got_face = font->get_font_face(); } // scope ensure that the font face is destroyed // after creating and destroying the FontFace in get_font_face, our reference // count should be the same @@ -72,25 +72,25 @@ void test_get_font_face() #ifdef CAIRO_HAS_FT_FONT void test_ft_scaled_font() { - FcPattern* invalid = FcPatternCreate(); + auto invalid = FcPatternCreate(); Cairo::RefPtr<Cairo::FtFontFace> invalid_face; BOOST_CHECK_THROW(invalid_face = Cairo::FtFontFace::create(invalid), std::bad_alloc); // basically taken from the cairo test case -- we don't care what font we're // using so just create an empty pattern and do the minimal substitution to // get a valid pattern - FcPattern* pattern = FcPatternCreate(); + auto pattern = FcPatternCreate(); FcConfigSubstitute (NULL, pattern, FcMatchPattern); FcDefaultSubstitute (pattern); FcResult result; - FcPattern* resolved = FcFontMatch (NULL, pattern, &result); - Cairo::RefPtr<Cairo::FtFontFace> face = Cairo::FtFontFace::create(resolved); + auto resolved = FcFontMatch (NULL, pattern, &result); + auto face = Cairo::FtFontFace::create(resolved); BOOST_CHECK(face); cairo_scaled_font_t* c_scaled_font = 0; int refcount = 0; { - Cairo::RefPtr<Cairo::FtScaledFont> scaled_font = + auto scaled_font = FtScaledFont::create(face, Cairo::identity_matrix(), Cairo::identity_matrix(), diff --git a/tests/test-surface.cc b/tests/test-surface.cc index c1654ca..b0d48b4 100644 --- a/tests/test-surface.cc +++ b/tests/test-surface.cc @@ -15,7 +15,7 @@ ErrorStatus test_slot(const unsigned char* /*data*/, unsigned int /*len*/) void test_write_to_png_stream() { - RefPtr<ImageSurface> surface = ImageSurface::create(FORMAT_ARGB32, 1, 1); + auto surface = ImageSurface::create(FORMAT_ARGB32, 1, 1); surface->write_to_png_stream(sigc::ptr_fun(test_slot)); BOOST_CHECK(test_slot_called > 0); } @@ -23,7 +23,7 @@ void test_write_to_png_stream() void test_pdf_constructor_slot() { test_slot_called = 0; - RefPtr<PdfSurface> pdf = PdfSurface::create_for_stream(sigc::ptr_fun(&test_slot), 1, 1); + auto pdf = PdfSurface::create_for_stream(sigc::ptr_fun(&test_slot), 1, 1); pdf->show_page(); pdf->finish(); BOOST_CHECK(test_slot_called > 0); @@ -32,7 +32,7 @@ void test_pdf_constructor_slot() void test_ps_constructor_slot() { test_slot_called = 0; - RefPtr<PsSurface> ps = PsSurface::create_for_stream(sigc::ptr_fun(&test_slot), 1, 1); + auto ps = PsSurface::create_for_stream(sigc::ptr_fun(&test_slot), 1, 1); ps->show_page(); ps->finish(); BOOST_CHECK(test_slot_called > 0); @@ -41,7 +41,7 @@ void test_ps_constructor_slot() void test_svg_constructor_slot() { test_slot_called = 0; - RefPtr<SvgSurface> svg = SvgSurface::create_for_stream(sigc::ptr_fun(&test_slot), 1, 1); + auto svg = SvgSurface::create_for_stream(sigc::ptr_fun(&test_slot), 1, 1); svg->show_page(); svg->finish(); BOOST_CHECK(test_slot_called > 0); @@ -84,7 +84,7 @@ void test_create_from_png() void test_ps_eps() { - RefPtr<PsSurface> ps = PsSurface::create("test.ps", 1, 1); + auto ps = PsSurface::create("test.ps", 1, 1); // check the initial value bool result = ps->get_eps(); // set it to the opposite value @@ -95,16 +95,16 @@ void test_ps_eps() void test_content() { - RefPtr<ImageSurface> surface = ImageSurface::create(FORMAT_ARGB32, 1, 1); + auto surface = ImageSurface::create(FORMAT_ARGB32, 1, 1); BOOST_CHECK_EQUAL(surface->get_content(), CONTENT_COLOR_ALPHA); - RefPtr<Surface> similar = Surface::create(surface, CONTENT_ALPHA, 1, 1); + auto similar = Surface::create(surface, CONTENT_ALPHA, 1, 1); BOOST_REQUIRE(similar); BOOST_CHECK_EQUAL(similar->get_content(), CONTENT_ALPHA); } void test_fallback_resolution() { - RefPtr<ImageSurface> surface = ImageSurface::create(FORMAT_ARGB32, 1, 1); + auto surface = ImageSurface::create(FORMAT_ARGB32, 1, 1); double x, y; surface->get_fallback_resolution(x, y); const double new_x = 94, new_y = 123; @@ -117,7 +117,7 @@ void test_fallback_resolution() void test_show_text_glyphs() { // image surface doesn't support show_text_glyphs - Cairo::RefPtr<Cairo::Surface> surf = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, 10, 10); \ + auto 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); diff --git a/tests/test-user-font.cc b/tests/test-user-font.cc index 656bcfc..b0cd7b4 100644 --- a/tests/test-user-font.cc +++ b/tests/test-user-font.cc @@ -77,7 +77,7 @@ protected: void test_implement_text() { TestSetup setup; - RefPtr<ImplTextUserFont> font = ImplTextUserFont::create(); + auto font = ImplTextUserFont::create(); setup.cr->set_font_face(font); setup.cr->show_text("hello"); BOOST_REQUIRE(font->count_text_to_glyphs > 0); @@ -104,7 +104,7 @@ protected: void test_implement_unicode() { TestSetup setup; - RefPtr<ImplTextUserFont> font = ImplTextUserFont::create(); + auto font = ImplTextUserFont::create(); setup.cr->set_font_face(font); setup.cr->show_text("hello"); BOOST_REQUIRE(font->count_text_to_glyphs > 0); @@ -146,7 +146,7 @@ protected: void test_implement_both() { TestSetup setup; - RefPtr<ImplBothUserFont> font = ImplBothUserFont::create(); + auto font = ImplBothUserFont::create(); setup.cr->set_font_face(font); setup.cr->show_text("hello"); // text_to_glyphs should take precedence @@ -170,7 +170,7 @@ protected: void test_implement_neither() { TestSetup setup; - RefPtr<ImplNeitherUserFont> font = ImplNeitherUserFont::create(); + auto font = ImplNeitherUserFont::create(); setup.cr->set_font_face(font); setup.cr->show_text("hello"); BOOST_REQUIRE(font->count_render_glyph > 0); @@ -197,7 +197,7 @@ protected: void test_implement_init() { TestSetup setup; - RefPtr<ImplInitUserFont> font = ImplInitUserFont::create(); + auto font = ImplInitUserFont::create(); setup.cr->set_font_face(font); setup.cr->show_text("hello"); BOOST_REQUIRE(font->count_init > 0); @@ -263,7 +263,7 @@ protected: void test_user_font_exception() { - Cairo::RefPtr<ExceptionUserFont> font = + auto font = ExceptionUserFont::create(ExceptionUserFont::FLAG_INIT); BOOST_CHECK(font); |