Add 5 example Makefiles: primitives, dilation, erosion, open, close.
[Faustine.git] / interpretor / lib / src / libsndfile-1.0.25 / tests / external_libs_test.c
1 /*
2 ** Copyright (C) 2008-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
3 **
4 ** This program is free software ; you can redistribute it and/or modify
5 ** it under the terms of the GNU General Public License as published by
6 ** the Free Software Foundation ; either version 2 of the License, or
7 ** (at your option) any later version.
8 **
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY ; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ** GNU General Public License for more details.
13 **
14 ** You should have received a copy of the GNU General Public License
15 ** along with this program ; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #include "sfconfig.h"
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <errno.h>
25
26 #include <sndfile.h>
27
28 #include "utils.h"
29
30 static void major_format_test (void) ;
31 static void subtype_format_test (void) ;
32 static void simple_format_test (void) ;
33
34 int
35 main (void)
36 {
37 major_format_test () ;
38 subtype_format_test () ;
39 simple_format_test () ;
40
41 return 0 ;
42 } /* main */
43
44 static void
45 major_format_test (void)
46 { SF_FORMAT_INFO info ;
47 int have_ogg = 0, have_flac = 0 ;
48 int m, major_count ;
49
50 print_test_name (__func__, NULL) ;
51
52 sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ;
53
54 for (m = 0 ; m < major_count ; m++)
55 { info.format = m ;
56 sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ;
57
58 have_flac = info.format == SF_FORMAT_FLAC ? 1 : have_flac ;
59 have_ogg = info.format == SF_FORMAT_OGG ? 1 : have_ogg ;
60 } ;
61
62 if (HAVE_EXTERNAL_LIBS)
63 { exit_if_true (have_flac == 0, "\n\nLine %d : FLAC should be available.\n\n", __LINE__) ;
64 exit_if_true (have_ogg == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
65 }
66 else
67 { exit_if_true (have_flac, "\n\nLine %d : FLAC should not be available.\n\n", __LINE__) ;
68 exit_if_true (have_ogg, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
69 } ;
70
71 puts ("ok") ;
72 } /* major_format_test */
73
74 static void
75 subtype_format_test (void)
76 { SF_FORMAT_INFO info ;
77 int have_vorbis = 0 ;
78 int s, subtype_count ;
79
80 print_test_name (__func__, NULL) ;
81
82 sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof (int)) ;
83
84 for (s = 0 ; s < subtype_count ; s++)
85 { info.format = s ;
86 sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &info, sizeof (info)) ;
87
88 have_vorbis = info.format == SF_FORMAT_VORBIS ? 1 : have_vorbis ;
89 } ;
90
91 if (HAVE_EXTERNAL_LIBS)
92 exit_if_true (have_vorbis == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
93 else
94 exit_if_true (have_vorbis, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
95
96 puts ("ok") ;
97 } /* subtype_format_test */
98
99 static void
100 simple_format_test (void)
101 { SF_FORMAT_INFO info ;
102 int have_flac = 0, have_ogg = 0, have_vorbis = 0 ;
103 int s, simple_count ;
104
105 print_test_name (__func__, NULL) ;
106
107 sf_command (NULL, SFC_GET_SIMPLE_FORMAT_COUNT, &simple_count, sizeof (int)) ;
108
109 for (s = 0 ; s < simple_count ; s++)
110 { info.format = s ;
111 sf_command (NULL, SFC_GET_SIMPLE_FORMAT, &info, sizeof (info)) ;
112
113 switch (info.format & SF_FORMAT_TYPEMASK)
114 { case SF_FORMAT_FLAC :
115 have_flac = 1 ;
116 break ;
117
118 case SF_FORMAT_OGG :
119 have_ogg = 1 ;
120 break ;
121
122 default :
123 break ;
124 } ;
125
126 switch (info.format & SF_FORMAT_SUBMASK)
127 { case SF_FORMAT_VORBIS :
128 have_vorbis = 1 ;
129 break ;
130
131 default :
132 break ;
133 } ;
134
135 } ;
136
137 if (HAVE_EXTERNAL_LIBS)
138 { exit_if_true (have_flac == 0, "\n\nLine %d : FLAC should be available.\n\n", __LINE__) ;
139 exit_if_true (have_ogg == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
140 exit_if_true (have_vorbis == 0, "\n\nLine %d : Ogg/Vorbis should be available.\n\n", __LINE__) ;
141 }
142 else
143 { exit_if_true (have_flac, "\n\nLine %d : FLAC should not be available.\n\n", __LINE__) ;
144 exit_if_true (have_ogg, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
145 exit_if_true (have_vorbis, "\n\nLine %d : Ogg/Vorbis should not be available.\n\n", __LINE__) ;
146 } ;
147
148 puts ("ok") ;
149 } /* simple_format_test */