summaryrefslogtreecommitdiff
path: root/tests/noop.c
blob: 8c1ba2f7fc73f59c5575e825344d329df838f2d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/********************************************************************
 *                                                                  *
 * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
 *                                                                  *
 * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009                *
 * by the Xiph.Org Foundation http://www.xiph.org/                  *
 *                                                                  *
 ********************************************************************

  function: routines for validating codec initialization
  last mod: $Id: noop.c 16503 2009-08-22 18:14:02Z giles $

 ********************************************************************/

#include <theora/theoraenc.h>
#include <theora/theoradec.h>

#include "tests.h"

static int
noop_test_info ()
{
  th_info ti;

  INFO ("+ Initializing th_info struct");
  th_info_init (&ti);

  INFO ("+ Clearing empty th_info struct");
  th_info_clear (&ti);

  return 0;
}

static int
noop_test_comments ()
{
  th_comment tc;

  INFO ("+ Initializing th_comment struct");
  th_comment_init (&tc);

  INFO ("+ Clearing empty th_comment struct")
  th_comment_clear (&tc);

  return 0;
}

static int
noop_test_encode ()
{
  th_info ti;
  th_enc_ctx *te;

  INFO ("+ Initializing th_info struct");
  th_info_init (&ti);

  INFO ("+ Testing encoder context with empty th_info");
  te = th_encode_alloc(&ti);
  if (te != NULL)
    FAIL("td_encode_alloc accepted an unconfigured th_info");

  INFO ("+ Setting 16x16 image size");
  ti.frame_width = 16;
  ti.frame_height = 16;

  INFO ("+ Allocating encoder context");
  te = th_encode_alloc(&ti);
  if (te == NULL)
    FAIL("td_encode_alloc returned a null pointer");

  INFO ("+ Clearing th_info struct");
  th_info_clear (&ti);

  INFO ("+ Freeing encoder context");
  th_encode_free(te);

  return 0;
}

static int
noop_test_decode ()
{
  th_info ti;
  th_dec_ctx *td;

  INFO ("+ Testing decoder context with null info and setup");
  td = th_decode_alloc(NULL, NULL);
  if (td != NULL)
    FAIL("td_decode_alloc accepted null info pointers");

  INFO ("+ Initializing th_info struct");
  th_info_init (&ti);

  INFO ("+ Testing decoder context with empty info and null setup");
  td = th_decode_alloc(&ti, NULL);
  if (td != NULL)
    FAIL("td_decode_alloc accepted null info pointers");

  INFO ("+ Clearing th_info struct");
  th_info_clear (&ti);

  return 0;
}

int main(int argc, char *argv[])
{
  noop_test_info ();

  noop_test_comments ();

  noop_test_encode ();

  noop_test_decode ();

  exit (0);
}