comment_theora.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 comment header code
  13. last mod: $Id$
  14. ********************************************************************/
  15. #include <theora/theora.h>
  16. #include <string.h>
  17. #include "tests.h"
  18. #define ARTIST1 "Bug-eyed Fish"
  19. #define ARTIST2 "VJ Fugu"
  20. #define COPYRIGHT "Copyright (C) 2005. Some Rights Reserved."
  21. #define LICENSE "Creative Commons Attribution-ShareAlike 2.5"
  22. static int
  23. test_comments ()
  24. {
  25. theora_comment tc;
  26. int n;
  27. char * value;
  28. INFO ("+ Initializing theora_comment");
  29. theora_comment_init (&tc);
  30. INFO ("+ Adding ARTIST1");
  31. theora_comment_add (&tc, "ARTIST=" ARTIST1);
  32. INFO ("+ Adding LICENSE by tag");
  33. theora_comment_add_tag (&tc, "LICENSE", LICENSE);
  34. INFO ("+ Adding ARTIST2 by tag");
  35. theora_comment_add_tag (&tc, "ARTIST", ARTIST2);
  36. INFO ("+ Querying value of LICENSE");
  37. value = theora_comment_query (&tc, "LICENSE", 0);
  38. printf("foo %s\n", value);
  39. if (strcmp (value, LICENSE))
  40. FAIL ("Incorrect value for LICENSE");
  41. INFO ("+ Querying count of ARTIST comments");
  42. n = theora_comment_query_count (&tc, "ARTIST");
  43. if (n != 2)
  44. FAIL ("Incorrect count of ARTIST comments");
  45. INFO ("+ Querying value of ARTIST index 0");
  46. value = theora_comment_query (&tc, "ARTIST", 0);
  47. if (strcmp (value, ARTIST1))
  48. FAIL ("Incorrect value for ARTIST index 0");
  49. INFO ("+ Querying value of ARTIST index 1");
  50. value = theora_comment_query (&tc, "ARTIST", 1);
  51. if (strcmp (value, ARTIST2))
  52. FAIL ("Incorrect value for ARTIST index 1");
  53. INFO ("+ Querying value of ARTIST index 2 (out of bounds)");
  54. value = theora_comment_query (&tc, "ARTIST", 2);
  55. if (value != NULL)
  56. FAIL ("Non-NULL value for ARTIST index 2 (out of bounds)");
  57. INFO ("+ Querying value of UNDEF index 7 (tag not defined)");
  58. value = theora_comment_query (&tc, "UNDEF", 7);
  59. if (value != NULL)
  60. FAIL ("Non-NULL value for UNDEF index 7 (tag not defined)");
  61. INFO ("+ Clearing theora_comment");
  62. theora_comment_clear (&tc);
  63. return 0;
  64. }
  65. int main(int argc, char *argv[])
  66. {
  67. test_comments ();
  68. exit (0);
  69. }