1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 // Separate test for Metadata C API called from C, as gtest doesn't support that
18 
19 #include <stdlib.h>
20 #include <audio_utils/Metadata.h>
21 
main(int argc,char ** argv)22 int main(int argc, char **argv)
23 {
24     (void) argc;
25     (void) argv;
26 
27     audio_metadata_t *metadata = audio_metadata_create();
28     audio_metadata_put(metadata, "i32", (int32_t)1);
29     audio_metadata_put(metadata, "i64", (int64_t)2);
30     audio_metadata_put(metadata, "float", (float)3.1f);
31     audio_metadata_put(metadata, "double", (double)4.11);
32     audio_metadata_t *data = audio_metadata_create();
33     audio_metadata_put(data, "string", "hello");
34     audio_metadata_put(metadata, "data", data);
35 #if 0   // change to 1 for compile error: use of undeclared identifier 'audio_metadata_put_unknown'
36     {
37         static const struct complex {
38             float re;
39             float im;
40         } prime = { -5.0, -4.0 };
41         audio_metadata_put(metadata, "complex", prime);
42     }
43 #endif
44     audio_metadata_destroy(data);
45 
46     // TODO Test audio_metadata_get()
47 
48     audio_metadata_destroy(metadata);
49     return EXIT_SUCCESS;
50 }
51