1f0240fd17169c4f0d869a48efbb487b982d12ce
[Faustine.git] / interpretor / lib / src / libsndfile-1.0.25 / src / test_broadcast_var.c
1 /*
2 ** Copyright (C) 2010-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 Lesser General Public License as published by
6 ** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Lesser 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
25 #include "common.h"
26
27 #include "test_main.h"
28
29 #define BCAST_MAX 512
30
31 typedef SF_BROADCAST_INFO_VAR (BCAST_MAX) SF_BROADCAST_INFO_512 ;
32
33 static void
34 fill_coding_history (SF_BROADCAST_INFO_512 * bi)
35 { static const char *lines [] =
36 { "Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit.",
37 "Donec dignissim erat\nvehicula libero condimentum\ndictum porta augue faucibus.",
38 "Maecenas nec turpis\nsit amet quam\nfaucibus adipiscing.",
39 "Mauris aliquam,\nlectus interdum\ntincidunt luctus.",
40 "\n\n\n\n\n\n\n\n\n\n\n\n",
41 "In auctor lorem\nvel est euismod\ncondimentum.",
42 "\n\n\n\n\n\n\n\n\n\n\n\n",
43 "Ut vitae magna\nid dui placerat vehicula\nin id lectus.",
44 "\n\n\n\n\n\n\n\n\n\n\n\n",
45 "Sed lacus leo,\nmolestie et luctus ac,\ntincidunt sit amet nisi.",
46 "\n\n\n\n\n\n\n\n\n\n\n\n",
47 "Sed ligula neque,\ngravida semper vulputate laoreet,\ngravida eu tellus.",
48 "Donec dolor dolor,\nscelerisque in consequat ornare,\ntempor nec nisl."
49 } ;
50 int k ;
51
52 bi->coding_history [0] = 0 ;
53
54 for (k = 0 ; strlen (bi->coding_history) < bi->coding_history_size - 1 ; k ++)
55 append_snprintf (bi->coding_history, bi->coding_history_size, "%s\n", lines [k % ARRAY_LEN (lines)]) ;
56
57 return ;
58 } /* fill_coding_listory */
59
60 void
61 test_broadcast_var (void)
62 { SF_PRIVATE sf_private, *psf ;
63 int k ;
64
65 psf = &sf_private ;
66 memset (psf, 0, sizeof (sf_private)) ;
67
68 print_test_name ("Testing broadcast_var_set ") ;
69
70 for (k = 64 ; k < BCAST_MAX ; k++)
71 {
72 SF_BROADCAST_INFO_512 bi ;
73
74 memset (&bi, 0, sizeof (bi)) ;
75
76 bi.coding_history_size = k ;
77 fill_coding_history (&bi) ;
78 bi.coding_history_size -- ;
79
80 broadcast_var_set (psf, (SF_BROADCAST_INFO*) &bi, sizeof (bi)) ;
81 } ;
82
83 if (psf->broadcast_16k != NULL)
84 free (psf->broadcast_16k) ;
85
86 puts ("ok") ;
87 } /* test_broadcast_var */