From 376aeb2124d02cdf1fb1ed5cda0325cc0cc5871c Mon Sep 17 00:00:00 2001 From: Nick Chambers Date: Sat, 2 Jul 2022 23:09:52 -0500 Subject: [PATCH] Add test suite for the rope type in `gargoyle_from_rope` --- test/scribe.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/scribe.c b/test/scribe.c index 1767b89..31bb994 100644 --- a/test/scribe.c +++ b/test/scribe.c @@ -549,11 +549,13 @@ void scribe_test_from_rope(void) { uint64_t uint_val = 0; int64_t sint_val = 0; double dble_val = 0; + char rope_val[10]; struct gargoyle_opt opts[] = { { GARGOYLE_EZ_OPT("uint", uint_val), GARGOYLE_TYPE_UINT }, { GARGOYLE_EZ_OPT("sint", sint_val), GARGOYLE_TYPE_SINT }, - { GARGOYLE_EZ_OPT("dble", dble_val), GARGOYLE_TYPE_DBLE } + { GARGOYLE_EZ_OPT("dble", dble_val), GARGOYLE_TYPE_DBLE }, + { GARGOYLE_CS_OPT("rope", rope_val), GARGOYLE_TYPE_ROPE } }; uint8_t res = gargoyle_from_rope(&opts[0], "42", 0); @@ -650,4 +652,16 @@ void scribe_test_from_rope(void) { res = gargoyle_from_rope(&opts[2], "-8.19", 0); CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS); CU_ASSERT_DOUBLE_EQUAL(dble_val, -8.19, 0.0); + + res = gargoyle_from_rope(&opts[3], "Hello, world!", 0); + CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS); + CU_ASSERT_NSTRING_EQUAL(rope_val, "Hello, wo", 9); + + res = gargoyle_from_rope(&opts[3], "Hello!", 0); + CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS); + CU_ASSERT_NSTRING_EQUAL(rope_val, "Hello!", 9); + + res = gargoyle_from_rope(&opts[3], "Thunderfury, Blessed Blade of the Windseeker", 0); + CU_ASSERT_EQUAL(res, GARGOYLE_ERR_SUCCESS); + CU_ASSERT_NSTRING_EQUAL(rope_val, "Thunderfu", 9); }