noop.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /********************************************************************
  2. * *
  3. * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
  4. * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
  5. * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  6. * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
  7. * *
  8. * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
  9. * by the Xiph.Org Foundation http://www.xiph.org/ *
  10. * *
  11. ********************************************************************
  12. function: routines for validating codec initialization
  13. last mod: $Id: noop.c 16503 2009-08-22 18:14:02Z giles $
  14. ********************************************************************/
  15. #include <theora/theoraenc.h>
  16. #include <theora/theoradec.h>
  17. #include "tests.h"
  18. static int
  19. noop_test_info ()
  20. {
  21. th_info ti;
  22. INFO ("+ Initializing th_info struct");
  23. th_info_init (&ti);
  24. INFO ("+ Clearing empty th_info struct");
  25. th_info_clear (&ti);
  26. return 0;
  27. }
  28. static int
  29. noop_test_comments ()
  30. {
  31. th_comment tc;
  32. INFO ("+ Initializing th_comment struct");
  33. th_comment_init (&tc);
  34. INFO ("+ Clearing empty th_comment struct")
  35. th_comment_clear (&tc);
  36. return 0;
  37. }
  38. static int
  39. noop_test_encode ()
  40. {
  41. th_info ti;
  42. th_enc_ctx *te;
  43. INFO ("+ Initializing th_info struct");
  44. th_info_init (&ti);
  45. INFO ("+ Testing encoder context with empty th_info");
  46. te = th_encode_alloc(&ti);
  47. if (te != NULL)
  48. FAIL("td_encode_alloc accepted an unconfigured th_info");
  49. INFO ("+ Setting 16x16 image size");
  50. ti.frame_width = 16;
  51. ti.frame_height = 16;
  52. INFO ("+ Allocating encoder context");
  53. te = th_encode_alloc(&ti);
  54. if (te == NULL)
  55. FAIL("td_encode_alloc returned a null pointer");
  56. INFO ("+ Clearing th_info struct");
  57. th_info_clear (&ti);
  58. INFO ("+ Freeing encoder context");
  59. th_encode_free(te);
  60. return 0;
  61. }
  62. static int
  63. noop_test_decode ()
  64. {
  65. th_info ti;
  66. th_dec_ctx *td;
  67. INFO ("+ Testing decoder context with null info and setup");
  68. td = th_decode_alloc(NULL, NULL);
  69. if (td != NULL)
  70. FAIL("td_decode_alloc accepted null info pointers");
  71. INFO ("+ Initializing th_info struct");
  72. th_info_init (&ti);
  73. INFO ("+ Testing decoder context with empty info and null setup");
  74. td = th_decode_alloc(&ti, NULL);
  75. if (td != NULL)
  76. FAIL("td_decode_alloc accepted null info pointers");
  77. INFO ("+ Clearing th_info struct");
  78. th_info_clear (&ti);
  79. return 0;
  80. }
  81. int main(int argc, char *argv[])
  82. {
  83. noop_test_info ();
  84. noop_test_comments ();
  85. noop_test_encode ();
  86. noop_test_decode ();
  87. exit (0);
  88. }