Wrap TTF_Font with a few calls
[sdlgit/SDL_perl.git] / t / core_ttf.t
diff --git a/t/core_ttf.t b/t/core_ttf.t
new file mode 100644 (file)
index 0000000..9b8a22f
--- /dev/null
@@ -0,0 +1,32 @@
+#!perl
+use strict;
+use warnings;
+use SDL::Config;
+use Test::More;
+
+if ( SDL::Config->has('SDL_ttf') ) {
+    plan( tests => 10 );
+} else {
+    plan( skip_all => 'SDL_ttf support not compiled' );
+}
+
+use_ok('SDL');
+use_ok('SDL::Color');
+use_ok('SDL::Surface');
+use_ok('SDL::TTF_Font');
+
+SDL::TTF_Init();
+
+my $ttf_font = SDL::TTF_OpenFont( 'test/data/aircut3.ttf', 12 );
+isa_ok( $ttf_font, 'SDL::TTF_Font' );
+my ( $w, $h ) = @{ SDL::TTF_SizeText( $ttf_font, 'Hello!' ) };
+is( $w, 27, '"Hello!" has width 27' );
+is( $h, 14, '"Hello!" has width 14' );
+
+my $surface = SDL::TTF_RenderText_Blended( $ttf_font, 'Hello!',
+    SDL::Color->new( 255, 0, 0 ) );
+isa_ok( $surface, 'SDL::Surface' );
+is( $surface->w, 27, 'Surface has width 27' );
+is( $surface->h, 14, 'Surface has width 14' );
+
+SDL::TTF_Quit();