diff --git a/doc/man/man7/elektra-libs.7 b/doc/man/man7/elektra-libs.7 index 6c8a3fe681f..69e1b5ba697 100644 --- a/doc/man/man7/elektra-libs.7 +++ b/doc/man/man7/elektra-libs.7 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ELEKTRA\-LIBS" "7" "August 2019" "" "" +.TH "ELEKTRA\-LIBS" "7" "November 2019" "" "" . .SH "NAME" \fBelektra\-libs\fR \- libs overview @@ -98,17 +98,6 @@ libelektra\-plugin\.so .P \fBlibplugin \fIplugin/\fR\fR contains \fBelektraPlugin*\fR symbols to be used by plugins\. . -.SS "Libproposal" -. -.nf - -libelektra\-proposal\.so -. -.fi -. -.P -\fBlibproposal \fIproposal/\fR\fR contains functions that are proposed for libcore\. Depends on internals of libcore and as such must always fit to the exact same version\. -. .SS "Libmeta" . .nf diff --git a/doc/news/_preparation_next_release.md b/doc/news/_preparation_next_release.md index c1d5cda5c6b..022f8ef24cf 100644 --- a/doc/news/_preparation_next_release.md +++ b/doc/news/_preparation_next_release.md @@ -87,10 +87,10 @@ The text below summarizes updates to the [C (and C++)-based libraries](https://w - <> - <> -### <> +### Proposal -- <> -- <> +- Removed `elektraKeyGetMetaKeySet` and moved `keySetStringF` to the hosts plugin. _(Philipp Gackstatter)_ +- Removed `ksPopAtCursor`. _(Philipp Gackstatter)_ - <> ## Bindings diff --git a/src/include/kdbinternal.h b/src/include/kdbinternal.h index b2305c38352..87017200e6e 100644 --- a/src/include/kdbinternal.h +++ b/src/include/kdbinternal.h @@ -20,19 +20,4 @@ #include #include -#ifdef __cplusplus -namespace ckdb -{ -extern "C" { -#endif - -// can be made simply without Elektra's internals, so better keep it as -// extension. -ssize_t keySetStringF (Key * key, const char * format, ...); - -#ifdef __cplusplus -} -} -#endif - #endif diff --git a/src/include/kdbproposal.h b/src/include/kdbproposal.h index 53d63c6739f..a6e658394b0 100644 --- a/src/include/kdbproposal.h +++ b/src/include/kdbproposal.h @@ -22,9 +22,6 @@ extern "C" { // this might become the new keySetName ssize_t elektraKeySetName (Key * key, const char * newName, elektraKeyFlags options); -KeySet * elektraKeyGetMetaKeySet (const Key * key); - -Key * ksPopAtCursor (KeySet * ks, elektraCursor c); #ifdef __cplusplus } diff --git a/src/libs/CMakeLists.txt b/src/libs/CMakeLists.txt index c24f98c50cb..60fdd695740 100644 --- a/src/libs/CMakeLists.txt +++ b/src/libs/CMakeLists.txt @@ -5,7 +5,6 @@ set ( loader ease globbing - proposal meta plugin pluginprocess diff --git a/src/libs/README.md b/src/libs/README.md index 3df98d28ab1..d0a4c2ff672 100644 --- a/src/libs/README.md +++ b/src/libs/README.md @@ -76,15 +76,6 @@ libelektra-plugin.so **[libplugin](plugin/)** contains `elektraPlugin*` symbols to be used by plugins. -### Libproposal - -``` -libelektra-proposal.so -``` - -**[libproposal](proposal/)** contains functions that are proposed for libcore. Depends on internals of libcore and as -such must always fit to the exact same version. - ### Libmeta ``` diff --git a/src/libs/ease/symbols.map b/src/libs/ease/symbols.map index 97b29d39f82..888598e3286 100644 --- a/src/libs/ease/symbols.map +++ b/src/libs/ease/symbols.map @@ -41,6 +41,8 @@ libelektra_0.9 { elektraKeyToUnsignedLong; elektraKeyToUnsignedLongLong; elektraKeyToUnsignedShort; + + elektraKsToMemArray; }; libelektraprivate_1.0 { diff --git a/src/libs/elektra/proposal.c b/src/libs/elektra/proposal.c index 1f99a1206ed..339a772f386 100644 --- a/src/libs/elektra/proposal.c +++ b/src/libs/elektra/proposal.c @@ -12,7 +12,25 @@ #include /** - * @copydoc ksPopAtCursor + * @brief Pop key at given cursor position + * + * @param ks the keyset to pop key from + * @param c where to pop + * + * The internal cursor will be rewinded using ksRewind(). You can use + * ksGetCursor() and ksSetCursor() jump back to the previous position. + * e.g. to pop at current position within ksNext() loop: + * @code + * cursor_t c = ksGetCursor(ks); + * keyDel (elektraKsPopAtCursor(ks, c)); + * ksSetCursor(ks, c); + * ksPrev(ks); // to have correct key after next ksNext() + * @endcode + * + * @warning do not use, will be superseded by external iterator API + * + * @return the popped key + * @retval 0 if ks is 0 */ Key * elektraKsPopAtCursor (KeySet * ks, elektraCursor pos) { diff --git a/src/libs/meta/CMakeLists.txt b/src/libs/meta/CMakeLists.txt index 3dc761d8f46..80c1cac1830 100644 --- a/src/libs/meta/CMakeLists.txt +++ b/src/libs/meta/CMakeLists.txt @@ -1,2 +1,2 @@ file (GLOB SOURCES *.c) -add_lib (meta SOURCES ${SOURCES} LINK_ELEKTRA elektra-ease elektra-proposal) +add_lib (meta SOURCES ${SOURCES} LINK_ELEKTRA elektra-ease) diff --git a/src/libs/proposal/CMakeLists.txt b/src/libs/proposal/CMakeLists.txt deleted file mode 100644 index daf3808a922..00000000000 --- a/src/libs/proposal/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -file (GLOB SOURCES *.c) -add_lib (proposal SOURCES ${SOURCES}) diff --git a/src/libs/proposal/proposal.c b/src/libs/proposal/proposal.c deleted file mode 100644 index 5f0476d1fbd..00000000000 --- a/src/libs/proposal/proposal.c +++ /dev/null @@ -1,119 +0,0 @@ -/** - * @file - * - * @brief Implementation of proposed API enhancements. - * - * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) - * - */ - -#include -#include - -#include -#include -#include - -/** - * @defgroup proposal Proposals for Elektra - * @brief Might be added to, changed or removed from future Elektra releases. - */ - -/** - * @defgroup api API Proposals for Elektra - * @brief for kdb.h. - * @ingroup proposal - * - * @warning Do not use these methods if you do not want to depend on - * exactly the Elektra version your binary was built for. - * - * These methods are a technical preview of what might be added in - * future Elektra releases. It is a requirement that methods are first - * added here, before they are added to the public API. - * - * Usually, names in proposal stage should be prefixed with elektra to - * clearly mark that the signature is likely to be changed and not yet - * ABI compatible. - * - * @{ - */ - - -/** - * @brief Set a formatted string - * - * @param key the key to set the string value - * @param format NULL-terminated text format string - * @param ... more arguments - * - * @return the size of the string as set (with including 0) - */ -ssize_t keySetStringF (Key * key, const char * format, ...) -{ - va_list arg_list; - - keySetMeta (key, "binary", 0); - - va_start (arg_list, format); - char * p = elektraVFormat (format, arg_list); - va_end (arg_list); - - if (!p) - { - return -1; - } - - if (key->data.c && !test_bit (key->flags, KEY_FLAG_MMAP_DATA)) - { - elektraFree (key->data.c); - } - - key->data.c = p; - key->dataSize = elektraStrLen (key->data.c); - set_bit (key->flags, KEY_FLAG_SYNC); - - return key->dataSize; -} - - -/** - * @brief Return metadata as keyset - * - * @param key the key object to work with - * - * @return a duplication of the keyset representing the metadata - */ -KeySet * elektraKeyGetMetaKeySet (const Key * key) -{ - if (!key) return 0; - if (!key->meta) return 0; - - return ksDup (key->meta); -} - - -/** - * @brief Pop key at given cursor position - * - * @param ks the keyset to pop key from - * @param c where to pop - * - * The internal cursor will be rewinded using ksRewind(). You can use - * ksGetCursor() and ksSetCursor() jump back to the previous position. - * e.g. to pop at current position within ksNext() loop: - * @code - * elektraCursor c = ksGetCursor(ks); - * keyDel (ksPopAtCursor(ks, c)); - * ksSetCursor(ks, c); - * ksPrev(ks); // to have correct key after next ksNext() - * @endcode - * - * @warning do not use, will be superseded by external iterator API - * - * @return the popped key - * @retval 0 if ks is 0 - */ -Key * ksPopAtCursor (KeySet * ks, elektraCursor pos) -{ - return elektraKsPopAtCursor (ks, pos); -} diff --git a/src/libs/proposal/symbols.map b/src/libs/proposal/symbols.map deleted file mode 100644 index fb1449558ed..00000000000 --- a/src/libs/proposal/symbols.map +++ /dev/null @@ -1,10 +0,0 @@ -libelektra_0.8 { - # kdbproposal.h - elektraKeyGetMetaKeySet; - elektraKsToMemArray; - keyAsCascading; - keyGetLevelsBelow; - keyRel2; - keySetStringF; - ksPopAtCursor; -}; diff --git a/src/plugins/augeas/CMakeLists.txt b/src/plugins/augeas/CMakeLists.txt index d812c0ff40c..4003f37943b 100644 --- a/src/plugins/augeas/CMakeLists.txt +++ b/src/plugins/augeas/CMakeLists.txt @@ -43,6 +43,6 @@ add_plugin ( ADD_TEST INSTALL_TEST_DATA INCLUDE_DIRECTORIES ${AUGEAS_PLUGIN_INCLUDE_DIRS} COMPILE_DEFINITIONS "${LIBAUGEAS_COMPILE_DEFINITIONS}" - LINK_ELEKTRA elektra-meta elektra-proposal + LINK_ELEKTRA elektra-meta LINK_LIBRARIES ${AUGEAS_PLUGIN_LIBRARIES} TEST_ENVIRONMENT "ASAN_OPTIONS=detect_container_overflow=0") diff --git a/src/plugins/augeas/testmod_augeas.c b/src/plugins/augeas/testmod_augeas.c index 2e0d39df680..af97da27fc7 100644 --- a/src/plugins/augeas/testmod_augeas.c +++ b/src/plugins/augeas/testmod_augeas.c @@ -19,7 +19,7 @@ #include #endif -#include +#include #include @@ -128,22 +128,22 @@ static void test_hostLensDelete (char * sourceFile, char * compFile) Key * key = ksLookupByName (ks, "user/tests/augeas-hosts/1", 0); exit_if_fail (key, "localhost not found"); - ksPopAtCursor (ks, ksGetCursor (ks)); + elektraKsPopAtCursor (ks, ksGetCursor (ks)); keyDel (key); key = ksLookupByName (ks, "user/tests/augeas-hosts/1/ipaddr", 0); exit_if_fail (key, "ip address of localhost not found"); - ksPopAtCursor (ks, ksGetCursor (ks)); + elektraKsPopAtCursor (ks, ksGetCursor (ks)); keyDel (key); key = ksLookupByName (ks, "user/tests/augeas-hosts/1/canonical", 0); exit_if_fail (key, "canonical of localhost not found"); - ksPopAtCursor (ks, ksGetCursor (ks)); + elektraKsPopAtCursor (ks, ksGetCursor (ks)); keyDel (key); key = ksLookupByName (ks, "user/tests/augeas-hosts/1/#comment", 0); exit_if_fail (key, "comment of localhost not found"); - ksPopAtCursor (ks, ksGetCursor (ks)); + elektraKsPopAtCursor (ks, ksGetCursor (ks)); keyDel (key); keySetString (parentKey, elektraFilename ()); diff --git a/src/plugins/hosts/CMakeLists.txt b/src/plugins/hosts/CMakeLists.txt index 3dc62812d22..86b4ab94201 100644 --- a/src/plugins/hosts/CMakeLists.txt +++ b/src/plugins/hosts/CMakeLists.txt @@ -3,7 +3,7 @@ include (LibAddMacros) add_plugin ( hosts SOURCES hosts.h hosts-get.c hosts-set.c keymetaformatting.h keymetaformatting.c - LINK_ELEKTRA elektra-ease elektra-proposal elektra-meta + LINK_ELEKTRA elektra-ease elektra-meta ADD_TEST TEST_README TEST_REQUIRED_PLUGINS network INSTALL_TEST_DATA) diff --git a/src/plugins/hosts/hosts-set.c b/src/plugins/hosts/hosts-set.c index 588076223b8..33ba3187683 100644 --- a/src/plugins/hosts/hosts-set.c +++ b/src/plugins/hosts/hosts-set.c @@ -60,7 +60,7 @@ static const char * getMetaValue (Key * key, const char * metaName) static void writeLineComments (Key * key, FILE * fp) { // TODO: this is really inefficient - KeySet * metaKeys = elektraKeyGetMetaKeySet (key); + KeySet * metaKeys = keyMeta (key); Key * commentParent = keyNew ("comment", KEY_META_NAME, KEY_END); KeySet * comments = elektraArrayGet (commentParent, metaKeys); keyDel (commentParent); @@ -85,7 +85,6 @@ static void writeLineComments (Key * key, FILE * fp) } } - ksDel (metaKeys); ksDel (comments); } diff --git a/src/plugins/hosts/keymetaformatting.c b/src/plugins/hosts/keymetaformatting.c index 5f4f071ac34..a63a718c295 100644 --- a/src/plugins/hosts/keymetaformatting.c +++ b/src/plugins/hosts/keymetaformatting.c @@ -15,6 +15,42 @@ #include #include +/** + * @brief Set a formatted string + * + * @param key the key to set the string value + * @param format NULL-terminated text format string + * @param ... more arguments + * + * @return the size of the string as set (with including 0) + */ +ssize_t keySetStringF (Key * key, const char * format, ...) +{ + va_list arg_list; + + keySetMeta (key, "binary", 0); + + va_start (arg_list, format); + char * p = elektraVFormat (format, arg_list); + va_end (arg_list); + + if (!p) + { + return -1; + } + + if (key->data.c && !test_bit (key->flags, KEY_FLAG_MMAP_DATA)) + { + elektraFree (key->data.c); + } + + key->data.c = p; + key->dataSize = elektraStrLen (key->data.c); + set_bit (key->flags, KEY_FLAG_SYNC); + + return key->dataSize; +} + static void elektraAddCommentInfo (KeySet * comments, Key * commentBase, size_t spaces, const char * commentStart, const char * comment) { keySetString (commentBase, comment); diff --git a/src/plugins/hosts/keymetaformatting.h b/src/plugins/hosts/keymetaformatting.h index dd4261fbc33..4b5a22fa77c 100644 --- a/src/plugins/hosts/keymetaformatting.h +++ b/src/plugins/hosts/keymetaformatting.h @@ -16,5 +16,6 @@ void elektraAddLineComment (KeySet * comments, size_t spaces, const char * commentStart, const char * comment); void elektraAddInlineComment (KeySet * comments, size_t spaces, const char * commentStart, const char * comment); size_t elektraCountStartSpaces (const char * line); +ssize_t keySetStringF (Key * key, const char * format, ...); #endif /* KEYMETAFORMATTING_H_ */ diff --git a/src/plugins/hosts/testmod_hosts.c b/src/plugins/hosts/testmod_hosts.c index 297d9617f01..82b5abd0f47 100644 --- a/src/plugins/hosts/testmod_hosts.c +++ b/src/plugins/hosts/testmod_hosts.c @@ -19,6 +19,7 @@ #include #endif +#include "keymetaformatting.h" #include void test_readHostsSimple (char * fileName) @@ -411,6 +412,78 @@ void test_writeHostsComments (char * fileName) PLUGIN_CLOSE (); } +static void test_format (void) +{ + printf ("Test key format\n"); + + Key * k = keyNew (0); + keySetString (k, "huhu"); + succeed_if_same_string (keyString (k), "huhu"); + + keySetStringF (k, "huhu"); + succeed_if_same_string (keyString (k), "huhu"); + + keySetStringF (k, "huhu %d", 20); + succeed_if_same_string (keyString (k), "huhu 20"); + + char c1[] = "huhu %d something"; + keySetStringF (k, c1, 20); + c1[5] = '2'; + c1[6] = '0'; + succeed_if_same_string (keyString (k), c1); + succeed_if (keyGetValueSize (k) == sizeof (c1), "size wrong"); + + + char c2[] = + "An extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something!"; + keySetStringF (k, c2); + succeed_if_same_string (keyString (k), c2); + succeed_if (keyGetValueSize (k) == sizeof (c2), "size wrong"); + + + char c3[] = + "%s extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something!"; + keySetStringF (k, c3, "AN"); + c3[0] = 'A'; + c3[1] = 'N'; + succeed_if_same_string (keyString (k), c3); + // printf ("%s\n\nXXX\n%s\n", keyString(k), c3); + // printf ("%d - %d\n", keyGetValueSize(k), sizeof(c3)); + succeed_if (keyGetValueSize (k) == sizeof (c3), "size wrong"); + + + char c4[] = + "%d extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something." + "an extremely long string that is way longer then default capture size of 512 or something!"; + keySetStringF (k, c4, 20); + c4[0] = '2'; + c4[1] = '0'; + succeed_if_same_string (keyString (k), c4); + succeed_if (keyGetValueSize (k) == sizeof (c4), "size wrong"); + + keyDel (k); +} + int main (int argc, char ** argv) { printf ("MOUNT TESTS\n"); @@ -427,6 +500,8 @@ int main (int argc, char ** argv) test_readHostsComments ("hosts/hosts-comments"); test_writeHostsComments ("hosts/hosts-comments"); + test_format (); + print_result ("test_hosts"); return nbError; diff --git a/src/plugins/keytometa/CMakeLists.txt b/src/plugins/keytometa/CMakeLists.txt index 68bdcca5261..9cfab19386d 100644 --- a/src/plugins/keytometa/CMakeLists.txt +++ b/src/plugins/keytometa/CMakeLists.txt @@ -3,5 +3,5 @@ include (LibAddMacros) add_plugin ( keytometa SOURCES keytometa.h keytometa.c - LINK_ELEKTRA elektra-proposal elektra-meta + LINK_ELEKTRA elektra-meta ADD_TEST) diff --git a/src/plugins/list/CMakeLists.txt b/src/plugins/list/CMakeLists.txt index b8734425bc9..1a8ed55aca7 100644 --- a/src/plugins/list/CMakeLists.txt +++ b/src/plugins/list/CMakeLists.txt @@ -3,5 +3,5 @@ include (LibAddMacros) add_plugin ( list SOURCES list.h list.c - LINK_ELEKTRA elektra-kdb elektra-invoke elektra-ease elektra-proposal + LINK_ELEKTRA elektra-kdb elektra-invoke elektra-ease ADD_TEST) diff --git a/src/plugins/specload/CMakeLists.txt b/src/plugins/specload/CMakeLists.txt index 141d2eb1bb2..b03b95b52a3 100644 --- a/src/plugins/specload/CMakeLists.txt +++ b/src/plugins/specload/CMakeLists.txt @@ -3,7 +3,7 @@ include (LibAddMacros) add_plugin ( specload SOURCES specload.h specload.c - LINK_ELEKTRA elektra-ease elektra-invoke elektra-proposal + LINK_ELEKTRA elektra-ease elektra-invoke TEST_README) if (DEPENDENCY_PHASE AND BUILD_SHARED) diff --git a/tests/ctest/CMakeLists.txt b/tests/ctest/CMakeLists.txt index 134f38fed8a..32ab7962e3d 100644 --- a/tests/ctest/CMakeLists.txt +++ b/tests/ctest/CMakeLists.txt @@ -22,15 +22,10 @@ target_link_elektra (test_splitget elektra-plugin) target_link_elektra (test_splitset elektra-plugin) target_link_elektra (test_meta elektra-meta) -target_link_elektra (test_meta elektra-proposal) target_link_elektra (test_ks elektra-ease) target_link_elektra (test_key elektra-meta) -target_link_elektra (test_key elektra-proposal) target_link_elektra (test_operation elektra-meta) -target_link_elektra (test_operation elektra-proposal) - -target_link_elektra (test_proposal elektra-proposal) target_link_elektra (test_utility elektra-utility) diff --git a/tests/ctest/test_meta.c b/tests/ctest/test_meta.c index a7fff6555d0..c4e50f5e302 100644 --- a/tests/ctest/test_meta.c +++ b/tests/ctest/test_meta.c @@ -223,49 +223,6 @@ static void test_mode (void) keyDel (key); } -static void test_metaKeySet (void) -{ - Key * key = keyNew ("user/test", KEY_END); - keySetMeta (key, "meta/test1", "value1"); - keySetMeta (key, "meta/test2", "value2"); - keySetMeta (key, "meta/test3", "value3"); - - KeySet * metaKeys = elektraKeyGetMetaKeySet (key); - - /* test whether the metakeyset contains all keys */ - Key * metaKey = ksLookupByName (metaKeys, "meta/test1", KDB_O_NONE); - exit_if_fail (metaKey, "the first metakey was not found in the metakeyset"); - succeed_if (!strcmp (keyString (metaKey), "value1"), "the first metakey in the metakeyset has a wrong value"); - - metaKey = ksLookupByName (metaKeys, "meta/test2", KDB_O_NONE); - exit_if_fail (metaKey, "the second metakey was not found in the metakeyset"); - succeed_if (!strcmp (keyString (metaKey), "value2"), "the second metakey in the metakeyset has a wrong value"); - - metaKey = ksLookupByName (metaKeys, "meta/test3", KDB_O_NONE); - exit_if_fail (metaKey, "the third metakey was not found in the metakeyset"); - succeed_if (!strcmp (keyString (metaKey), "value3"), "the third metakey in the metakeyset has a wrong value"); - - /* test whether the metakeyset is affected by deletions */ - ksPop (metaKeys); - - const Key * deletedKey = keyGetMeta (key, "meta/test3"); - exit_if_fail (deletedKey, "key deleted from the metakeyset is not present on the original key anymore"); - succeed_if (!strcmp (keyString (deletedKey), "value3"), "key deleted from the metakeyset has a wrong value afterwards"); - - ksDel (metaKeys); - metaKeys = elektraKeyGetMetaKeySet (key); - ksRewind (metaKeys); - metaKey = ksNext (metaKeys); - keySetString (metaKey, "newvalue"); - - const Key * modifiedKey = keyGetMeta (key, "meta/test1"); - succeed_if (!strcmp (keyString (modifiedKey), "value1"), - "metakey has incorrect value after a key from the metakeyset was modified"); - - ksDel (metaKeys); - keyDel (key); -} - static void test_metaArrayToKS (void) { Key * test = keyNew ("/a", KEY_META, "dep", "#1", KEY_META, "dep/#0", "/b", KEY_META, "dep/#1", "/c", KEY_END); @@ -520,7 +477,6 @@ int main (int argc, char ** argv) test_comment (); test_owner (); test_mode (); - test_metaKeySet (); test_metaArrayToKS (); test_top (); diff --git a/tests/ctest/test_operation.c b/tests/ctest/test_operation.c index 82c4ee95722..4f9f8534278 100644 --- a/tests/ctest/test_operation.c +++ b/tests/ctest/test_operation.c @@ -141,78 +141,6 @@ static void test_search (void) ksDel (a); } -static void test_format (void) -{ - printf ("Test key format\n"); - - Key * k = keyNew (0); - keySetString (k, "huhu"); - succeed_if_same_string (keyString (k), "huhu"); - - keySetStringF (k, "huhu"); - succeed_if_same_string (keyString (k), "huhu"); - - keySetStringF (k, "huhu %d", 20); - succeed_if_same_string (keyString (k), "huhu 20"); - - char c1[] = "huhu %d something"; - keySetStringF (k, c1, 20); - c1[5] = '2'; - c1[6] = '0'; - succeed_if_same_string (keyString (k), c1); - succeed_if (keyGetValueSize (k) == sizeof (c1), "size wrong"); - - - char c2[] = - "An extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something!"; - keySetStringF (k, c2); - succeed_if_same_string (keyString (k), c2); - succeed_if (keyGetValueSize (k) == sizeof (c2), "size wrong"); - - - char c3[] = - "%s extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something!"; - keySetStringF (k, c3, "AN"); - c3[0] = 'A'; - c3[1] = 'N'; - succeed_if_same_string (keyString (k), c3); - // printf ("%s\n\nXXX\n%s\n", keyString(k), c3); - // printf ("%d - %d\n", keyGetValueSize(k), sizeof(c3)); - succeed_if (keyGetValueSize (k) == sizeof (c3), "size wrong"); - - - char c4[] = - "%d extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something." - "an extremely long string that is way longer then default capture size of 512 or something!"; - keySetStringF (k, c4, 20); - c4[0] = '2'; - c4[1] = '0'; - succeed_if_same_string (keyString (k), c4); - succeed_if (keyGetValueSize (k) == sizeof (c4), "size wrong"); - - keyDel (k); -} - int main (int argc, char ** argv) { printf ("OPERATION TESTS\n"); @@ -222,7 +150,6 @@ int main (int argc, char ** argv) test_search (); test_cmpOrder (); - test_format (); printf ("\ntest_operation RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError); diff --git a/tests/ctest/test_proposal.c b/tests/ctest/test_proposal.c deleted file mode 100644 index bfbd67dfb40..00000000000 --- a/tests/ctest/test_proposal.c +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file - * - * @brief - * - * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) - */ - -#include - -static void test_ksPopAtCursor (void) -{ - KeySet * ks = ksNew (5, keyNew ("user/valid/key1", KEY_END), keyNew ("user/valid/key2", KEY_END), - keyNew ("system/valid/key1", KEY_END), keyNew ("system/valid/key2", KEY_END), KS_END); - KeySet * ks_c = ksNew (5, keyNew ("user/valid/key1", KEY_END), keyNew ("user/valid/key2", KEY_END), - keyNew ("system/valid/key1", KEY_END), KS_END); - ksRewind (ks); - ksNext (ks); - ksNext (ks); - elektraCursor c = ksGetCursor (ks); - keyDel (ksPopAtCursor (ks, c)); - succeed_if (ksCurrent (ks) == 0, "cursor position wrong"); - - compare_keyset (ks, ks_c); - ksDel (ks); - ksDel (ks_c); -} - -int main (int argc, char ** argv) -{ - printf ("KEY PROPOSAL TESTS\n"); - printf ("==================\n\n"); - - init (argc, argv); - - test_ksPopAtCursor (); - - printf ("\ntest_proposal RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError); -}