From: James Prestwood <prestwoj at gmail.com>
To: ell at lists.01.org
Subject: [PATCH 2/5] unit: add settings test for clone APIs
Date: Fri, 04 Feb 2022 09:05:59 -0800 [thread overview]
Message-ID: <20220204170603.216439-2-prestwoj@gmail.com> (raw)
In-Reply-To: 20220204170603.216439-1-prestwoj@gmail.com
[-- Attachment #1: Type: text/plain, Size: 1886 bytes --]
---
unit/test-settings.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/unit/test-settings.c b/unit/test-settings.c
index a25197a..d9f25f9 100644
--- a/unit/test-settings.c
+++ b/unit/test-settings.c
@@ -559,6 +559,44 @@ static void test_invalid_data(const void *test_data)
l_settings_free(settings);
}
+static void check_clone_data(struct l_settings *settings)
+{
+ const char *value;
+ const char *type = NULL;
+
+ assert(l_settings_has_group(settings, "normal"));
+ assert(l_settings_has_key(settings, "normal", "key"));
+ value = l_settings_get_value(settings, "normal", "key");
+ assert(value);
+ assert(!strcmp(value, "value"));
+
+ assert(l_settings_has_embedded_group(settings, "single_cert"));
+ value = l_settings_get_embedded_value(settings, "single_cert",
+ &type);
+ assert(value && type);
+ assert(!strcmp(type, "pem"));
+ assert(!strcmp(value, TEST_CERTIFICATE));
+}
+
+static void test_clone(const void *data)
+{
+ const char *raw_data =
+ "[normal]\n"
+ "key=value\n"
+ "[@pem(a)single_cert]\n"
+ TEST_CERTIFICATE;
+
+ struct l_settings *settings = l_settings_new();
+ struct l_settings *copy;
+
+ assert(l_settings_load_from_data(settings, raw_data, strlen(raw_data)));
+ check_clone_data(settings);
+
+ copy = l_settings_clone(settings);
+ check_clone_data(copy);
+ l_settings_free(copy);
+}
+
int main(int argc, char *argv[])
{
l_test_init(&argc, &argv);
@@ -571,7 +609,7 @@ int main(int argc, char *argv[])
l_test_add("Invalid Data 2", test_invalid_data, key_before_group_data);
l_test_add("Test valid ext group", test_valid_extended_group, NULL);
l_test_add("Test invalid ext group", test_invalid_extended_group, NULL);
-
+ l_test_add("Test clone", test_clone, NULL);
return l_test_run();
}
--
2.31.1
next reply other threads:[~2022-02-04 17:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-04 17:05 James Prestwood [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-02-04 17:29 [PATCH 2/5] unit: add settings test for clone APIs Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220204170603.216439-2-prestwoj@gmail.com \
--to=unknown@example.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.