~ubuntu-branches/ubuntu/raring/flac/raring

« back to all changes in this revision

Viewing changes to src/test_libFLAC/format.c

  • Committer: Bazaar Package Importer
  • Author(s): Joshua Kwan
  • Date: 2007-05-29 22:56:36 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529225636-ljeff8xxip09qaap
Tags: 1.1.4-1
* New upstream release. closes: #405167, #411311
  - libOggFLAC and libOggFLAC++ have been merged into libFLAC, so
    remove their corresponding packages.
  - Because of the API changes required to effect the above, there has
    been yet another soname bump. libflac7 -> libflac8 and
    libflac++5 -> libflac++6. Emails have been dispatched to the
    maintainers of dependent packages.
* Some notes on patches that were removed:
  - 02_stdin_stdout, 06_manpage_mention_utf8_convert: merged upstream
  - 08_manpage_warnings: Upstream has changed the manpage so it defintely
    can't fit in in 80 cols, so just forget about it. We'll live.
  - 05_eof_warnings_are_errors: Upstream decided to add a -w option to
    flac to treat all warnings as errors. I am going to defer to that
    for now, but if people think it's stupid let me know and I'll port
    the patch forward.
  - 04_stack_smasher: was a backport from 1.1.3, so it's obsolete.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* test_libFLAC - Unit tester for libFLAC
2
 
 * Copyright (C) 2004,2005  Josh Coalson
 
2
 * Copyright (C) 2004,2005,2006,2007  Josh Coalson
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or
5
5
 * modify it under the terms of the GNU General Public License
16
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17
17
 */
18
18
 
 
19
#if HAVE_CONFIG_H
 
20
#  include <config.h>
 
21
#endif
 
22
 
19
23
#include "FLAC/assert.h"
20
24
#include "FLAC/format.h"
21
25
#include <stdio.h>
26
30
        unsigned rate;
27
31
        FLAC__bool valid;
28
32
} SAMPLE_RATES[] = {
29
 
        { 0, false },
30
 
        { 1, true },
31
 
        { 9, true },
32
 
        { 10, true },
33
 
        { 4000, true },
34
 
        { 8000, true },
35
 
        { 11025, true },
36
 
        { 12000, true },
37
 
        { 16000, true },
38
 
        { 22050, true },
39
 
        { 24000, true },
40
 
        { 32000, true },
41
 
        { 32768, true },
42
 
        { 44100, true },
43
 
        { 48000, true },
44
 
        { 65000, true },
45
 
        { 65535, true },
46
 
        { 65536, false },
47
 
        { 65540, true },
48
 
        { 65550, true },
49
 
        { 65555, false },
50
 
        { 66000, true },
51
 
        { 66001, false },
52
 
        { 96000, true },
53
 
        { 100000, true },
54
 
        { 100001, false },
55
 
        { 192000, true },
56
 
        { 500000, true },
57
 
        { 500001, false },
58
 
        { 500010, true },
59
 
        { 700000, false },
60
 
        { 700010, false },
 
33
        { 0      , false },
 
34
        { 1      , true  },
 
35
        { 9      , true  },
 
36
        { 10     , true  },
 
37
        { 4000   , true  },
 
38
        { 8000   , true  },
 
39
        { 11025  , true  },
 
40
        { 12000  , true  },
 
41
        { 16000  , true  },
 
42
        { 22050  , true  },
 
43
        { 24000  , true  },
 
44
        { 32000  , true  },
 
45
        { 32768  , true  },
 
46
        { 44100  , true  },
 
47
        { 48000  , true  },
 
48
        { 65000  , true  },
 
49
        { 65535  , true  },
 
50
        { 65536  , false },
 
51
        { 65540  , true  },
 
52
        { 65550  , true  },
 
53
        { 65555  , false },
 
54
        { 66000  , true  },
 
55
        { 66001  , false },
 
56
        { 96000  , true  },
 
57
        { 100000 , true  },
 
58
        { 100001 , false },
 
59
        { 192000 , true  },
 
60
        { 500000 , true  },
 
61
        { 500001 , false },
 
62
        { 500010 , true  },
 
63
        { 700000 , false },
 
64
        { 700010 , false },
61
65
        { 1000000, false },
62
66
        { 1100000, false }
63
67
};
66
70
        const char *string;
67
71
        FLAC__bool valid;
68
72
} VCENTRY_NAMES[] = {
69
 
        { "", true },
70
 
        { "a", true },
71
 
        { "=", false },
72
 
        { "a=", false },
 
73
        { ""    , true  },
 
74
        { "a"   , true  },
 
75
        { "="   , false },
 
76
        { "a="  , false },
73
77
        { "\x01", false },
74
78
        { "\x1f", false },
75
 
        { "\x7d", true },
 
79
        { "\x7d", true  },
76
80
        { "\x7e", false },
77
81
        { "\xff", false }
78
82
};
82
86
        const FLAC__byte *string;
83
87
        FLAC__bool valid;
84
88
} VCENTRY_VALUES[] = {
85
 
        { 0, (const FLAC__byte*)"", true },
86
 
        { 1, (const FLAC__byte*)"", true },
87
 
        { 1, (const FLAC__byte*)"\x01", true },
88
 
        { 1, (const FLAC__byte*)"\x7f", true },
89
 
        { 1, (const FLAC__byte*)"\x80", false },
90
 
        { 1, (const FLAC__byte*)"\x81", false },
91
 
        { 1, (const FLAC__byte*)"\xc0", false },
92
 
        { 1, (const FLAC__byte*)"\xe0", false },
93
 
        { 1, (const FLAC__byte*)"\xf0", false },
94
 
        { 2, (const FLAC__byte*)"\xc0\x41", false },
95
 
        { 2, (const FLAC__byte*)"\xc1\x41", false },
96
 
        { 2, (const FLAC__byte*)"\xc0\x85", true },
97
 
        { 2, (const FLAC__byte*)"\xc1\x85", true },
98
 
        { 2, (const FLAC__byte*)"\xe0\x41", false },
99
 
        { 2, (const FLAC__byte*)"\xe1\x41", false },
100
 
        { 2, (const FLAC__byte*)"\xe0\x85", false },
101
 
        { 2, (const FLAC__byte*)"\xe1\x85", false },
 
89
        { 0, (const FLAC__byte*)""            , true  },
 
90
        { 1, (const FLAC__byte*)""            , true  },
 
91
        { 1, (const FLAC__byte*)"\x01"        , true  },
 
92
        { 1, (const FLAC__byte*)"\x7f"        , true  },
 
93
        { 1, (const FLAC__byte*)"\x80"        , false },
 
94
        { 1, (const FLAC__byte*)"\x81"        , false },
 
95
        { 1, (const FLAC__byte*)"\xc0"        , false },
 
96
        { 1, (const FLAC__byte*)"\xe0"        , false },
 
97
        { 1, (const FLAC__byte*)"\xf0"        , false },
 
98
        { 2, (const FLAC__byte*)"\xc0\x41"    , false },
 
99
        { 2, (const FLAC__byte*)"\xc1\x41"    , false },
 
100
        { 2, (const FLAC__byte*)"\xc0\x85"    , false }, /* non-shortest form */
 
101
        { 2, (const FLAC__byte*)"\xc1\x85"    , false }, /* non-shortest form */
 
102
        { 2, (const FLAC__byte*)"\xc2\x85"    , true  },
 
103
        { 2, (const FLAC__byte*)"\xe0\x41"    , false },
 
104
        { 2, (const FLAC__byte*)"\xe1\x41"    , false },
 
105
        { 2, (const FLAC__byte*)"\xe0\x85"    , false },
 
106
        { 2, (const FLAC__byte*)"\xe1\x85"    , false },
102
107
        { 3, (const FLAC__byte*)"\xe0\x85\x41", false },
103
108
        { 3, (const FLAC__byte*)"\xe1\x85\x41", false },
104
 
        { 3, (const FLAC__byte*)"\xe0\x85\x80", true },
105
 
        { 3, (const FLAC__byte*)"\xe1\x85\x80", true }
 
109
        { 3, (const FLAC__byte*)"\xe0\x85\x80", false }, /* non-shortest form */
 
110
        { 3, (const FLAC__byte*)"\xe0\x95\x80", false }, /* non-shortest form */
 
111
        { 3, (const FLAC__byte*)"\xe0\xa5\x80", true  },
 
112
        { 3, (const FLAC__byte*)"\xe1\x85\x80", true  },
 
113
        { 3, (const FLAC__byte*)"\xe1\x95\x80", true  },
 
114
        { 3, (const FLAC__byte*)"\xe1\xa5\x80", true  }
106
115
};
107
116
 
108
117
static struct {
109
118
        const FLAC__byte *string;
110
119
        FLAC__bool valid;
111
120
} VCENTRY_VALUES_NT[] = {
112
 
        { (FLAC__byte*)"", true },
113
 
        { (FLAC__byte*)"\x01", true },
114
 
        { (FLAC__byte*)"\x7f", true },
115
 
        { (FLAC__byte*)"\x80", false },
116
 
        { (FLAC__byte*)"\x81", false },
117
 
        { (FLAC__byte*)"\xc0", false },
118
 
        { (FLAC__byte*)"\xe0", false },
119
 
        { (FLAC__byte*)"\xf0", false },
120
 
        { (FLAC__byte*)"\xc0\x41", false },
121
 
        { (FLAC__byte*)"\xc1\x41", false },
122
 
        { (FLAC__byte*)"\xc0\x85", true },
123
 
        { (FLAC__byte*)"\xc1\x85", true },
124
 
        { (FLAC__byte*)"\xe0\x41", false },
125
 
        { (FLAC__byte*)"\xe1\x41", false },
126
 
        { (FLAC__byte*)"\xe0\x85", false },
127
 
        { (FLAC__byte*)"\xe1\x85", false },
128
 
        { (FLAC__byte*)"\xe0\x85\x41", false },
129
 
        { (FLAC__byte*)"\xe1\x85\x41", false },
130
 
        { (FLAC__byte*)"\xe0\x85\x80", true },
131
 
        { (FLAC__byte*)"\xe1\x85\x80", true }
 
121
        { (const FLAC__byte*)""            , true  },
 
122
        { (const FLAC__byte*)"\x01"        , true  },
 
123
        { (const FLAC__byte*)"\x7f"        , true  },
 
124
        { (const FLAC__byte*)"\x80"        , false },
 
125
        { (const FLAC__byte*)"\x81"        , false },
 
126
        { (const FLAC__byte*)"\xc0"        , false },
 
127
        { (const FLAC__byte*)"\xe0"        , false },
 
128
        { (const FLAC__byte*)"\xf0"        , false },
 
129
        { (const FLAC__byte*)"\xc0\x41"    , false },
 
130
        { (const FLAC__byte*)"\xc1\x41"    , false },
 
131
        { (const FLAC__byte*)"\xc0\x85"    , false }, /* non-shortest form */
 
132
        { (const FLAC__byte*)"\xc1\x85"    , false }, /* non-shortest form */
 
133
        { (const FLAC__byte*)"\xc2\x85"    , true  },
 
134
        { (const FLAC__byte*)"\xe0\x41"    , false },
 
135
        { (const FLAC__byte*)"\xe1\x41"    , false },
 
136
        { (const FLAC__byte*)"\xe0\x85"    , false },
 
137
        { (const FLAC__byte*)"\xe1\x85"    , false },
 
138
        { (const FLAC__byte*)"\xe0\x85\x41", false },
 
139
        { (const FLAC__byte*)"\xe1\x85\x41", false },
 
140
        { (const FLAC__byte*)"\xe0\x85\x80", false }, /* non-shortest form */
 
141
        { (const FLAC__byte*)"\xe0\x95\x80", false }, /* non-shortest form */
 
142
        { (const FLAC__byte*)"\xe0\xa5\x80", true  },
 
143
        { (const FLAC__byte*)"\xe1\x85\x80", true  },
 
144
        { (const FLAC__byte*)"\xe1\x95\x80", true  },
 
145
        { (const FLAC__byte*)"\xe1\xa5\x80", true  }
132
146
};
133
147
 
134
148
static struct {
136
150
        const FLAC__byte *string;
137
151
        FLAC__bool valid;
138
152
} VCENTRIES[] = {
139
 
        { 0, (const FLAC__byte*)"", false },
140
 
        { 1, (const FLAC__byte*)"a", false },
141
 
        { 1, (const FLAC__byte*)"=", true },
142
 
        { 2, (const FLAC__byte*)"a=", true },
143
 
        { 2, (const FLAC__byte*)"\x01=", false },
144
 
        { 2, (const FLAC__byte*)"\x1f=", false },
145
 
        { 2, (const FLAC__byte*)"\x7d=", true },
146
 
        { 2, (const FLAC__byte*)"\x7e=", false },
147
 
        { 2, (const FLAC__byte *)"\xff=", false },
148
 
        { 3, (const FLAC__byte*)"a=\x01", true },
149
 
        { 3, (const FLAC__byte*)"a=\x7f", true },
150
 
        { 3, (const FLAC__byte*)"a=\x80", false },
151
 
        { 3, (const FLAC__byte*)"a=\x81", false },
152
 
        { 3, (const FLAC__byte*)"a=\xc0", false },
153
 
        { 3, (const FLAC__byte*)"a=\xe0", false },
154
 
        { 3, (const FLAC__byte*)"a=\xf0", false },
155
 
        { 4, (const FLAC__byte*)"a=\xc0\x41", false },
156
 
        { 4, (const FLAC__byte*)"a=\xc1\x41", false },
157
 
        { 4, (const FLAC__byte*)"a=\xc0\x85", true },
158
 
        { 4, (const FLAC__byte*)"a=\xc1\x85", true },
159
 
        { 4, (const FLAC__byte*)"a=\xe0\x41", false },
160
 
        { 4, (const FLAC__byte*)"a=\xe1\x41", false },
161
 
        { 4, (const FLAC__byte*)"a=\xe0\x85", false },
162
 
        { 4, (const FLAC__byte*)"a=\xe1\x85", false },
 
153
        { 0, (const FLAC__byte*)""              , false },
 
154
        { 1, (const FLAC__byte*)"a"             , false },
 
155
        { 1, (const FLAC__byte*)"="             , true  },
 
156
        { 2, (const FLAC__byte*)"a="            , true  },
 
157
        { 2, (const FLAC__byte*)"\x01="         , false },
 
158
        { 2, (const FLAC__byte*)"\x1f="         , false },
 
159
        { 2, (const FLAC__byte*)"\x7d="         , true  },
 
160
        { 2, (const FLAC__byte*)"\x7e="         , false },
 
161
        { 2, (const FLAC__byte*)"\xff="         , false },
 
162
        { 3, (const FLAC__byte*)"a=\x01"        , true  },
 
163
        { 3, (const FLAC__byte*)"a=\x7f"        , true  },
 
164
        { 3, (const FLAC__byte*)"a=\x80"        , false },
 
165
        { 3, (const FLAC__byte*)"a=\x81"        , false },
 
166
        { 3, (const FLAC__byte*)"a=\xc0"        , false },
 
167
        { 3, (const FLAC__byte*)"a=\xe0"        , false },
 
168
        { 3, (const FLAC__byte*)"a=\xf0"        , false },
 
169
        { 4, (const FLAC__byte*)"a=\xc0\x41"    , false },
 
170
        { 4, (const FLAC__byte*)"a=\xc1\x41"    , false },
 
171
        { 4, (const FLAC__byte*)"a=\xc0\x85"    , false }, /* non-shortest form */
 
172
        { 4, (const FLAC__byte*)"a=\xc1\x85"    , false }, /* non-shortest form */
 
173
        { 4, (const FLAC__byte*)"a=\xc2\x85"    , true  },
 
174
        { 4, (const FLAC__byte*)"a=\xe0\x41"    , false },
 
175
        { 4, (const FLAC__byte*)"a=\xe1\x41"    , false },
 
176
        { 4, (const FLAC__byte*)"a=\xe0\x85"    , false },
 
177
        { 4, (const FLAC__byte*)"a=\xe1\x85"    , false },
163
178
        { 5, (const FLAC__byte*)"a=\xe0\x85\x41", false },
164
179
        { 5, (const FLAC__byte*)"a=\xe1\x85\x41", false },
165
 
        { 5, (const FLAC__byte*)"a=\xe0\x85\x80", true },
166
 
        { 5, (const FLAC__byte*)"a=\xe1\x85\x80", true }
 
180
        { 5, (const FLAC__byte*)"a=\xe0\x85\x80", false }, /* non-shortest form */
 
181
        { 5, (const FLAC__byte*)"a=\xe0\x95\x80", false }, /* non-shortest form */
 
182
        { 5, (const FLAC__byte*)"a=\xe0\xa5\x80", true  },
 
183
        { 5, (const FLAC__byte*)"a=\xe1\x85\x80", true  },
 
184
        { 5, (const FLAC__byte*)"a=\xe1\x95\x80", true  },
 
185
        { 5, (const FLAC__byte*)"a=\xe1\xa5\x80", true  }
167
186
};
168
187
 
169
 
FLAC__bool test_format()
 
188
FLAC__bool test_format(void)
170
189
{
171
190
        unsigned i;
172
191