Skip to content

Commit

Permalink
Remove unused string_util code
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Jan 26, 2024
1 parent edf23ee commit be1cc98
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 76 deletions.
12 changes: 0 additions & 12 deletions lib/include/ert/util/string_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 9 additions & 31 deletions lib/util/string_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
33 changes: 0 additions & 33 deletions lib/util/tests/ert_util_string_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
Expand All @@ -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);
}
}
Expand Down

0 comments on commit be1cc98

Please sign in to comment.