1 /* Copyright (C) 2010-2020 The RetroArch team
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (config_file_test.c).
5 * ---------------------------------------------------------------------------------------
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 #include <file/config_file.h>
31 static void test_config_file_parse_contains(
33 const char *key, const char *val)
35 char *cfgtext_copy = strdup(cfgtext);
36 config_file_t *cfg = config_file_new_from_string(cfgtext_copy, NULL);
45 ok = config_get_string(cfg, key, &out);
53 if (strcmp(out, val) != 0)
55 printf("[FAILED] Key [%s] Doesn't contain val [%s]\n", key, val);
58 printf("[SUCCESS] Key [%s] contains val [%s]\n", key, val);
64 test_config_file_parse_contains("foo = \"bar\"\n", "foo", "bar");
65 test_config_file_parse_contains("foo = \"bar\"", "foo", "bar");
66 test_config_file_parse_contains("foo = \"bar\"\r\n", "foo", "bar");
67 test_config_file_parse_contains("foo = \"bar\"", "foo", "bar");
69 test_config_file_parse_contains("foo = \"\"\n", "foo", "");
70 test_config_file_parse_contains("foo = \"\"", "foo", "");
71 test_config_file_parse_contains("foo = \"\"\r\n", "foo", "");
72 test_config_file_parse_contains("foo = \"\"", "foo", "");
74 test_config_file_parse_contains("foo = \"\"\n", "bar", NULL);
75 test_config_file_parse_contains("foo = \"\"", "bar", NULL);
76 test_config_file_parse_contains("foo = \"\"\r\n", "bar", NULL);
77 test_config_file_parse_contains("foo = \"\"", "bar", NULL);