Debian Codegraph @

ags/test/audio/fx/ags_fx_eq10_channel_test.c

raw symbols SCIP
1 /* GSequencer - Advanced GTK Sequencer
2 * Copyright (C) 2005-2025 Joël Krähemann
3 *
4 * This file is part of GSequencer.
5 *
6 * GSequencer is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * GSequencer is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GSequencer. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <glib.h>
21 #include <glib-object.h>
22
23 #include <CUnit/CUnit.h>
24 #include <CUnit/Automated.h>
25 #include <CUnit/Basic.h>
26
27 #include <ags/libags.h>
28 #include <ags/libags-audio.h>
29
30 #include <math.h>
31
32 int ags_fx_eq10_channel_test_init_suite();
33 int ags_fx_eq10_channel_test_clean_suite();
34
35 void ags_fx_eq10_channel_stub_finalize(GObject *gobject);
36
37 void ags_fx_eq10_channel_test_new();
38 void ags_fx_eq10_channel_test_dispose();
39 void ags_fx_eq10_channel_test_finalize();
40
41 gboolean finalized;
42
43 void
44 ags_fx_eq10_channel_stub_finalize(GObject *gobject)
45 {
46 finalized = TRUE;
47 }
48
49 /* The suite initialization function.
50 * Opens the temporary file used by the tests.
51 * Returns zero on success, non-zero otherwise.
52 */
53 int
54 ags_fx_eq10_channel_test_init_suite()
55 {
56 return(0);
57 }
58
59 /* The suite cleanup function.
60 * Closes the temporary file used by the tests.
61 * Returns zero on success, non-zero otherwise.
62 */
63 int
64 ags_fx_eq10_channel_test_clean_suite()
65 {
66 return(0);
67 }
68
69 void
70 ags_fx_eq10_channel_test_new()
71 {
72 AgsChannel *channel;
73 AgsFxEq10Channel *fx_eq10_channel;
74
75 channel = g_object_new(AGS_TYPE_CHANNEL,
76 NULL);
77
78 fx_eq10_channel = ags_fx_eq10_channel_new(channel);
79
80 CU_ASSERT(fx_eq10_channel != NULL);
81 CU_ASSERT(AGS_RECALL_CHANNEL(fx_eq10_channel)->source == channel);
82
83 CU_ASSERT(fx_eq10_channel->peak_28hz != NULL);
84 CU_ASSERT(fx_eq10_channel->peak_56hz != NULL);
85 CU_ASSERT(fx_eq10_channel->peak_112hz != NULL);
86 CU_ASSERT(fx_eq10_channel->peak_224hz != NULL);
87 CU_ASSERT(fx_eq10_channel->peak_448hz != NULL);
88 CU_ASSERT(fx_eq10_channel->peak_896hz != NULL);
89 CU_ASSERT(fx_eq10_channel->peak_1792hz != NULL);
90 CU_ASSERT(fx_eq10_channel->peak_3584hz != NULL);
91 CU_ASSERT(fx_eq10_channel->peak_7168hz != NULL);
92 CU_ASSERT(fx_eq10_channel->peak_14336hz != NULL);
93 CU_ASSERT(fx_eq10_channel->pressure != NULL);
94 }
95
96 void
97 ags_fx_eq10_channel_test_dispose()
98 {
99 AgsChannel *channel;
100 AgsFxEq10Channel *fx_eq10_channel;
101
102 channel = g_object_new(AGS_TYPE_CHANNEL,
103 NULL);
104
105 fx_eq10_channel = ags_fx_eq10_channel_new(channel);
106
107 g_object_run_dispose(fx_eq10_channel);
108
109 CU_ASSERT(fx_eq10_channel->peak_28hz == NULL);
110 CU_ASSERT(fx_eq10_channel->peak_56hz == NULL);
111 CU_ASSERT(fx_eq10_channel->peak_112hz == NULL);
112 CU_ASSERT(fx_eq10_channel->peak_224hz == NULL);
113 CU_ASSERT(fx_eq10_channel->peak_448hz == NULL);
114 CU_ASSERT(fx_eq10_channel->peak_896hz == NULL);
115 CU_ASSERT(fx_eq10_channel->peak_1792hz == NULL);
116 CU_ASSERT(fx_eq10_channel->peak_3584hz == NULL);
117 CU_ASSERT(fx_eq10_channel->peak_7168hz == NULL);
118 CU_ASSERT(fx_eq10_channel->peak_14336hz == NULL);
119 CU_ASSERT(fx_eq10_channel->pressure == NULL);
120
121 g_object_unref(fx_eq10_channel);
122 }
123
124 void
125 ags_fx_eq10_channel_test_finalize()
126 {
127 AgsChannel *channel;
128 AgsFxEq10Channel *fx_eq10_channel;
129
130 GObjectClass *gobject_class;
131
132 gpointer stub;
133
134 /* attempt #0 */
135 channel = g_object_new(AGS_TYPE_CHANNEL,
136 NULL);
137
138 fx_eq10_channel = ags_fx_eq10_channel_new(channel);
139
140 gobject_class = (GObjectClass *) g_type_class_ref(AGS_TYPE_FX_EQ10_CHANNEL);
141
142 finalized = FALSE;
143
144 stub = gobject_class->finalize;
145 gobject_class->finalize = ags_fx_eq10_channel_stub_finalize;
146
147 g_object_unref(fx_eq10_channel);
148
149 CU_ASSERT(finalized == TRUE);
150
151 gobject_class->finalize = stub;
152
153 /* attempt #1 */
154 channel = g_object_new(AGS_TYPE_CHANNEL,
155 NULL);
156
157 fx_eq10_channel = ags_fx_eq10_channel_new(channel);
158
159 g_object_unref(fx_eq10_channel);
160 }
161
162 int
163 main(int argc, char **argv)
164 {
165 CU_pSuite pSuite = NULL;
166
167 putenv("LC_ALL=C");
168 putenv("LANG=C");
169
170 putenv("LADSPA_PATH=\"\"");
171 putenv("DSSI_PATH=\"\"");
172 putenv("LV2_PATH=\"\"");
173
174 /* initialize the CUnit test registry */
175 if(CUE_SUCCESS != CU_initialize_registry()){
176 return CU_get_error();
177 }
178
179 /* add a suite to the registry */
180 pSuite = CU_add_suite("AgsFxEq10ChannelTest", ags_fx_eq10_channel_test_init_suite, ags_fx_eq10_channel_test_clean_suite);
181
182 if(pSuite == NULL){
183 CU_cleanup_registry();
184
185 return CU_get_error();
186 }
187
188 /* add the tests to the suite */
189 if((CU_add_test(pSuite, "test of AgsFxEq10Channel new", ags_fx_eq10_channel_test_new) == NULL) ||
190 (CU_add_test(pSuite, "test of AgsFxEq10Channel dispose", ags_fx_eq10_channel_test_dispose) == NULL) ||
191 (CU_add_test(pSuite, "test of AgsFxEq10Channel finalize", ags_fx_eq10_channel_test_finalize) == NULL)){
192 CU_cleanup_registry();
193
194 return CU_get_error();
195 }
196
197 /* Run all tests using the CUnit Basic interface */
198 CU_basic_set_mode(CU_BRM_VERBOSE);
199 CU_basic_run_tests();
200
201 CU_cleanup_registry();
202
203 return(CU_get_error());
204 }