/t/ttf_font.t

http://github.com/PerlGameDev/SDL · Perl · 56 lines · 45 code · 10 blank · 1 comment · 1 complexity · 73ad0092af5ab271896af52f4959490c MD5 · raw file

  1. #!/usr/bin/perl -w
  2. use strict;
  3. use warnings;
  4. use SDL;
  5. use SDL::Config;
  6. BEGIN {
  7. use FindBin;
  8. use File::Spec;
  9. use Test::More;
  10. use lib 't/lib';
  11. use SDL::TestTool;
  12. if ( !SDL::Config->has('SDL_ttf') ) {
  13. plan( skip_all => 'SDL_ttf support not compiled' );
  14. }
  15. }
  16. use SDL::TTF;
  17. use SDL::TTF::Font;
  18. use SDL::Version;
  19. my $font_filename = File::Spec->catfile(
  20. $FindBin::Bin, '..', 'share', 'GenBasR.ttf'
  21. );
  22. my $lv = SDL::TTF::linked_version();
  23. my $cv = SDL::TTF::compile_time_version();
  24. isa_ok( $lv, 'SDL::Version', '[linked_version] returns a SDL::Version object' );
  25. isa_ok(
  26. $cv, 'SDL::Version',
  27. '[compile_time_version] returns a SDL::Version object'
  28. );
  29. printf(
  30. "got version: %d.%d.%d/%d.%d.%d\n",
  31. $lv->major, $lv->minor, $lv->patch, $cv->major, $cv->minor, $cv->patch
  32. );
  33. is( SDL::TTF::init(), 0, "[init] succeeded" );
  34. isa_ok(
  35. SDL::TTF::Font->new( $font_filename, 24 ),
  36. 'SDL::TTF::Font',
  37. "[new] with font and size"
  38. );
  39. isa_ok(
  40. SDL::TTF::Font->new( $font_filename, 24, 0 ),
  41. 'SDL::TTF::Font',
  42. "[new] with font, size and index"
  43. );
  44. is( SDL::TTF::quit(), undef, "[quit] ran" );
  45. done_testing;
  46. sleep(1);