spec: Use %license macro to copy license
[platform/upstream/libtheora.git] / tests / comment_theora.c
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
13   function: routines for validating comment header code
14   last mod: $Id: comment_theora.c 16503 2009-08-22 18:14:02Z giles $
15
16  ********************************************************************/
17
18 #include <theora/theora.h>
19
20 #include <string.h>
21 #include "tests.h"
22
23 #define ARTIST1 "Bug-eyed Fish"
24 #define ARTIST2 "VJ Fugu"
25 #define COPYRIGHT "Copyright (C) 2005. Some Rights Reserved."
26 #define LICENSE "Creative Commons Attribution-ShareAlike 2.5"
27
28 static int
29 test_comments ()
30 {
31   theora_comment tc;
32   int n;
33   char * value;
34
35   INFO ("+ Initializing theora_comment");
36   theora_comment_init (&tc);
37
38   INFO ("+ Adding ARTIST1");
39   theora_comment_add (&tc, "ARTIST=" ARTIST1);
40
41   INFO ("+ Adding LICENSE by tag");
42   theora_comment_add_tag (&tc, "LICENSE", LICENSE);
43
44   INFO ("+ Adding ARTIST2 by tag");
45   theora_comment_add_tag (&tc, "ARTIST", ARTIST2);
46
47   INFO ("+ Querying value of LICENSE");
48   value = theora_comment_query (&tc, "LICENSE", 0);
49   printf("foo %s\n", value);
50
51   if (strcmp (value, LICENSE))
52     FAIL ("Incorrect value for LICENSE");
53
54   INFO ("+ Querying count of ARTIST comments");
55   n = theora_comment_query_count (&tc, "ARTIST");
56
57   if (n != 2)
58     FAIL ("Incorrect count of ARTIST comments");
59
60   INFO ("+ Querying value of ARTIST index 0");
61   value = theora_comment_query (&tc, "ARTIST", 0);
62   if (strcmp (value, ARTIST1))
63     FAIL ("Incorrect value for ARTIST index 0");
64
65   INFO ("+ Querying value of ARTIST index 1");
66   value = theora_comment_query (&tc, "ARTIST", 1);
67   if (strcmp (value, ARTIST2))
68     FAIL ("Incorrect value for ARTIST index 1");
69
70   INFO ("+ Querying value of ARTIST index 2 (out of bounds)");
71   value = theora_comment_query (&tc, "ARTIST", 2);
72   if (value != NULL)
73     FAIL ("Non-NULL value for ARTIST index 2 (out of bounds)");
74
75   INFO ("+ Querying value of UNDEF index 7 (tag not defined)");
76   value = theora_comment_query (&tc, "UNDEF", 7);
77   if (value != NULL)
78     FAIL ("Non-NULL value for UNDEF index 7 (tag not defined)");
79
80   INFO ("+ Clearing theora_comment");
81   theora_comment_clear (&tc);
82
83   return 0;
84 }
85
86 int main(int argc, char *argv[])
87 {
88   test_comments ();
89
90   exit (0);
91 }