Add Russian translation provided by Валерий Крувялис <valkru@mail.ru>
[xiph-mirror.git] / theora-old / tests / comment-test.c
blob662e267d27d481b3a53821798cf8b628452cb698
1 #include <theora/theora.h>
3 #include <string.h>
4 #include "tests.h"
6 #define ARTIST1 "Bug-eyed Fish"
7 #define ARTIST2 "VJ Fugu"
8 #define COPYRIGHT "Copyright (C) 2005. Some Rights Reserved."
9 #define LICENSE "Creative Commons Attribution-ShareAlike 2.5"
11 static int
12 test_comments ()
14 theora_comment tc;
15 int i, n;
16 char * value;
18 INFO ("+ Initializing theora_comment");
19 theora_comment_init (&tc);
21 INFO ("+ Adding ARTIST1");
22 theora_comment_add (&tc, "ARTIST=" ARTIST1);
24 INFO ("+ Adding LICENSE by tag");
25 theora_comment_add_tag (&tc, "LICENSE", LICENSE);
27 INFO ("+ Adding ARTIST2 by tag");
28 theora_comment_add_tag (&tc, "ARTIST", ARTIST2);
30 INFO ("+ Querying value of LICENSE");
31 value = theora_comment_query (&tc, "LICENSE", 0);
32 if (strcmp (value, LICENSE))
33 FAIL ("Incorrect value for LICENSE");
35 INFO ("+ Querying count of ARTIST comments");
36 n = theora_comment_query_count (&tc, "ARTIST");
38 if (n != 2)
39 FAIL ("Incorrect count of ARTIST comments");
41 INFO ("+ Querying value of ARTIST index 0");
42 value = theora_comment_query (&tc, "ARTIST", 0);
43 if (strcmp (value, ARTIST1))
44 FAIL ("Incorrect value for ARTIST index 0");
46 INFO ("+ Querying value of ARTIST index 1");
47 value = theora_comment_query (&tc, "ARTIST", 1);
48 if (strcmp (value, ARTIST2))
49 FAIL ("Incorrect value for ARTIST index 1");
51 INFO ("+ Querying value of ARTIST index 2 (out of bounds)");
52 value = theora_comment_query (&tc, "ARTIST", 2);
53 if (value != NULL)
54 FAIL ("Non-NULL value for ARTIST index 2 (out of bounds)");
56 INFO ("+ Querying value of UNDEF index 7 (tag not defined)");
57 value = theora_comment_query (&tc, "UNDEF", 7);
58 if (value != NULL)
59 FAIL ("Non-NULL value for UNDEF index 7 (tag not defined)");
61 INFO ("+ Clearing theora_comment");
62 theora_comment_clear (&tc);
64 return 0;
67 int main(int argc, char *argv[])
69 test_comments ();
71 exit (0);