From be1cc9829dd685d24d225ae197b9d82a8ac71470 Mon Sep 17 00:00:00 2001 From: Eivind Jahren Date: Fri, 26 Jan 2024 12:44:31 +0100 Subject: [PATCH] Remove unused string_util code --- lib/include/ert/util/string_util.hpp | 12 -------- lib/util/string_util.cpp | 40 ++++++------------------- lib/util/tests/ert_util_string_util.cpp | 33 -------------------- 3 files changed, 9 insertions(+), 76 deletions(-) diff --git a/lib/include/ert/util/string_util.hpp b/lib/include/ert/util/string_util.hpp index 4d7099ddc..5164d12e6 100644 --- a/lib/include/ert/util/string_util.hpp +++ b/lib/include/ert/util/string_util.hpp @@ -8,22 +8,10 @@ extern "C" { #endif -bool string_util_init_active_list(const char *range_string, - int_vector_type *active_list); -bool string_util_update_active_list(const char *range_string, - int_vector_type *active_list); int_vector_type *string_util_alloc_active_list(const char *range_string); - -bool string_util_init_active_mask(const char *range_string, - bool_vector_type *active_mask); bool string_util_update_active_mask(const char *range_string, bool_vector_type *active_mask); bool_vector_type *string_util_alloc_active_mask(const char *range_string); - -bool string_util_update_value_list(const char *range_string, - int_vector_type *value_list); -bool string_util_init_value_list(const char *range_string, - int_vector_type *value_list); int_vector_type *string_util_alloc_value_list(const char *range_string); #ifdef __cplusplus diff --git a/lib/util/string_util.cpp b/lib/util/string_util.cpp index a0f3d8399..b5a2ad2e7 100644 --- a/lib/util/string_util.cpp +++ b/lib/util/string_util.cpp @@ -100,8 +100,9 @@ string_util_sscanf_alloc_active_list(const char *range_string) { return active_list; } -bool string_util_update_active_list(const char *range_string, - int_vector_type *active_list) { +static bool string_util_init_active_list(const char *range_string, + int_vector_type *active_list) { + int_vector_reset(active_list); int_vector_sort(active_list); { bool_vector_type *mask = int_vector_alloc_mask(active_list); @@ -124,12 +125,6 @@ bool string_util_update_active_list(const char *range_string, } } -bool string_util_init_active_list(const char *range_string, - int_vector_type *active_list) { - int_vector_reset(active_list); - return string_util_update_active_list(range_string, active_list); -} - int_vector_type *string_util_alloc_active_list(const char *range_string) { int_vector_type *active_list = int_vector_alloc(0, 0); string_util_init_active_list(range_string, active_list); @@ -157,38 +152,21 @@ bool string_util_update_active_mask(const char *range_string, return false; } -bool string_util_init_active_mask(const char *range_string, - bool_vector_type *active_mask) { - bool_vector_reset(active_mask); - return string_util_update_active_mask(range_string, active_mask); -} - bool_vector_type *string_util_alloc_active_mask(const char *range_string) { bool_vector_type *mask = bool_vector_alloc(0, false); - string_util_init_active_mask(range_string, mask); + bool_vector_reset(mask); + string_util_update_active_mask(range_string, mask); return mask; } -bool string_util_update_value_list(const char *range_string, - int_vector_type *value_list) { +int_vector_type *string_util_alloc_value_list(const char *range_string) { + int_vector_type *value_list = int_vector_alloc(0, 0); + int_vector_reset(value_list); int_vector_type *new_values = string_util_sscanf_alloc_active_list(range_string); if (new_values) { int_vector_append_vector(value_list, new_values); int_vector_free(new_values); - return true; - } else - return false; -} - -bool string_util_init_value_list(const char *range_string, - int_vector_type *value_list) { - int_vector_reset(value_list); - return string_util_update_value_list(range_string, value_list); -} - -int_vector_type *string_util_alloc_value_list(const char *range_string) { - int_vector_type *value_list = int_vector_alloc(0, 0); - string_util_init_value_list(range_string, value_list); + } return value_list; } diff --git a/lib/util/tests/ert_util_string_util.cpp b/lib/util/tests/ert_util_string_util.cpp index 64e8e27df..b778127e4 100644 --- a/lib/util/tests/ert_util_string_util.cpp +++ b/lib/util/tests/ert_util_string_util.cpp @@ -23,24 +23,7 @@ void test_int_vector(const int_vector_type *list, int length, ...) { void test_active_list() { int_vector_type *active_list = string_util_alloc_active_list("1,3- 10,15"); - test_assert_true(string_util_init_active_list("1,3- 10,15", active_list)); test_int_vector(active_list, 10, 1, 3, 4, 5, 6, 7, 8, 9, 10, 15); - - test_assert_true( - string_util_update_active_list("1,3- 10,15,8", active_list)); - test_int_vector(active_list, 10, 1, 3, 4, 5, 6, 7, 8, 9, 10, 15); - - test_assert_false(string_util_update_active_list("1,X", active_list)); - test_int_vector(active_list, 10, 1, 3, 4, 5, 6, 7, 8, 9, 10, 15); - - test_assert_true(string_util_update_active_list("14-16", active_list)); - test_int_vector(active_list, 12, 1, 3, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16); - - test_assert_true(string_util_update_active_list("0", active_list)); - test_int_vector(active_list, 13, 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16); - - test_assert_true(string_util_update_active_list("4-6", active_list)); - test_int_vector(active_list, 13, 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16); int_vector_free(active_list); } @@ -65,8 +48,6 @@ void test_active_mask() { string_util_alloc_active_mask("1,3 -6,6- 10, 15"); test2(active_mask); - test_assert_true(string_util_init_active_mask("1,3- 10,15", active_mask)); - test2(active_mask); test_assert_false(string_util_update_active_mask("11,X", active_mask)); test2(active_mask); @@ -90,26 +71,12 @@ void test_value_list() { { int_vector_type *int_vector = string_util_alloc_value_list("1,2,4-7"); test_int_vector(int_vector, 6, 1, 2, 4, 5, 6, 7); - test_assert_false(string_util_update_value_list("1,2,X", int_vector)); int_vector_free(int_vector); } { int_vector_type *int_vector = string_util_alloc_value_list("5,5,5,5"); test_int_vector(int_vector, 4, 5, 5, 5, 5); - test_assert_true(string_util_update_value_list("1-5", int_vector)); - test_int_vector(int_vector, 9, 5, 5, 5, 5, 1, 2, 3, 4, 5); - test_assert_true(string_util_update_value_list("1-5", int_vector)); - test_int_vector(int_vector, 14, 5, 5, 5, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, - 5); - int_vector_free(int_vector); - } - - { - int_vector_type *int_vector = int_vector_alloc(0, 77); - int_vector_append(int_vector, 125); - string_util_init_value_list("1-5", int_vector); - test_int_vector(int_vector, 5, 1, 2, 3, 4, 5); int_vector_free(int_vector); } }