|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Tests for Ah String Utils. More...
#include <gtest/gtest.h>#include <cmath>#include <cstdlib>#include <limits>#include <random>#include <sstream>#include <stdexcept>#include <vector>#include <ah-string-utils.H>Go to the source code of this file.
Functions | |
| static DynList< string > | reference_split_string (const string &s, const string &delim) |
| Splits a string into non-empty tokens using a set of delimiter characters. | |
| static void | expect_tokens_eq (const DynList< string > &expected, const DynList< string > &got) |
| Asserts that two DynList<string> contain the same tokens in the same order. | |
| static void | expect_tokens_eq (const DynList< string > &expected, const Array< string > &got) |
| Assert that a DynList of strings and an Array of strings contain the same tokens. | |
| TEST (util, concat) | |
| TEST (StringUtils, vector_to_string) | |
| TEST (StringUtils, array_to_string) | |
| TEST (StringUtils, trim_variants) | |
| TEST (StringUtils, contains_string_view) | |
| TEST (StringUtils, double_formatting) | |
| TEST (StringUtils, case_conversion_ascii) | |
| TEST (StringUtils, case_conversion_non_ascii_does_not_crash) | |
| TEST (StringUtils, only_alpha_and_removals) | |
| TEST (StringUtils, join_dynlist) | |
| TEST (StringUtils, numeric_parsers) | |
| TEST (StringUtils, prefix_and_remove_prefix) | |
| TEST (StringUtils, to_name) | |
| TEST (StringUtils, split_camel_case) | |
| TEST (StringUtils, split_and_split_string) | |
| TEST (StringUtilsCritical, split_string_edge_cases) | |
| TEST (StringUtils, pascal_case) | |
| TEST (StringUtils, split_pos) | |
| TEST (StringUtils, split_n) | |
| TEST (StringUtils, complete_rows) | |
| TEST (StringUtils, format_string_no_underflow) | |
| TEST (StringUtils, format_string_csv) | |
| TEST (StringUtils, text_wrapping_and_shift) | |
| TEST (StringUtils, build_pars_list_variadic) | |
| TEST (StringUtils, build_pars_list_container) | |
| TEST (StringUtils, fill_string) | |
| TEST (StringUtils, split_to_array) | |
| TEST (StringUtils, format_string_computed_lens) | |
| TEST (StringUtilsCritical, format_string_exact_alignment_and_stream_output) | |
| TEST (StringUtils, to_string_matrix_and_lines) | |
| TEST (StringUtilsCritical, justify_text_exact_wrapping_and_margins) | |
| TEST (StringUtilsCritical, numeric_parsing_strictness) | |
| TEST (StringUtils, split_text_into_words_and_lines) | |
| TEST (StringUtils, justify_and_align_except_first) | |
| TEST (StringUtils, numeric_boundaries) | |
| static int | stress_multiplier () |
| static string | random_string (std::mt19937 &rng, size_t len) |
| static string | random_ascii_token (std::mt19937 &rng, size_t len) |
| TEST (StringUtilsStress, split_pos_recomposes) | |
| TEST (StringUtilsStress, split_n_recomposes) | |
| TEST (StringUtilsStress, split_string_tokens_have_no_delims) | |
| TEST (StringUtilsStress, split_string_matches_reference_parser) | |
| TEST (StringUtilsStress, case_conversion_no_crash_and_preserves_length) | |
| TEST (StringUtilsStress, build_pars_list_round_trip_for_ints) | |
Tests for Ah String Utils.
Definition in file ah-string-utils.cc.
|
static |
Assert that a DynList of strings and an Array of strings contain the same tokens.
Compares sizes and each corresponding element; triggers test failures if the number of tokens differs or any element mismatches.
| expected | Expected tokens as a DynList<string>. |
| got | Actual tokens as an Array<string>. |
Definition at line 117 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp().
|
static |
Asserts that two DynList<string> contain the same tokens in the same order.
Compares the lists' sizes with ASSERT_EQ (which aborts the test on mismatch) and then compares each corresponding element with EXPECT_EQ.
| expected | The expected list of tokens. |
| got | The actual list of tokens to verify. |
Definition at line 100 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp().
|
static |
Definition at line 662 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), and rng.
|
static |
Definition at line 652 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), and rng.
|
static |
Splits a string into non-empty tokens using a set of delimiter characters.
| s | Input string to split. |
| delim | A string whose characters are treated as delimiter characters; each occurrence separates tokens. If delim is empty, the entire input is returned as a single token (unless s is empty). |
s that contains no characters from delim. Empty tokens are omitted. Definition at line 63 of file ah-string-utils.cc.
References Aleph::DynList< T >::append(), and Aleph::divide_and_conquer_partition_dp().
|
static |
Definition at line 632 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), and m.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
| TEST | ( | StringUtils | , |
| array_to_string | |||
| ) |
Definition at line 143 of file ah-string-utils.cc.
References Aleph::Array< T >::append(), Aleph::divide_and_conquer_partition_dp(), and Aleph::to_string().
| TEST | ( | StringUtils | , |
| build_pars_list_container | |||
| ) |
Definition at line 451 of file ah-string-utils.cc.
References Aleph::DynList< T >::append(), Aleph::build_pars_list(), Aleph::divide_and_conquer_partition_dp(), and l.
| TEST | ( | StringUtils | , |
| build_pars_list_variadic | |||
| ) |
Definition at line 445 of file ah-string-utils.cc.
References Aleph::build_pars_list(), and Aleph::divide_and_conquer_partition_dp().
| TEST | ( | StringUtils | , |
| case_conversion_ascii | |||
| ) |
Definition at line 190 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), Aleph::mutable_tolower(), Aleph::mutable_toupper(), Aleph::tolower(), and Aleph::toupper().
| TEST | ( | StringUtils | , |
| case_conversion_non_ascii_does_not_crash | |||
| ) |
Definition at line 202 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::to_lower().
| TEST | ( | StringUtils | , |
| complete_rows | |||
| ) |
Definition at line 390 of file ah-string-utils.cc.
References OhashCommon< HashTbl, Key >::append(), Aleph::DynList< T >::append(), Aleph::complete_rows(), Aleph::divide_and_conquer_partition_dp(), and m.
| TEST | ( | StringUtils | , |
| contains_string_view | |||
| ) |
Definition at line 175 of file ah-string-utils.cc.
References Aleph::contains(), and Aleph::divide_and_conquer_partition_dp().
| TEST | ( | StringUtils | , |
| double_formatting | |||
| ) |
Definition at line 182 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), Aleph::to_str(), and Aleph::to_string().
| TEST | ( | StringUtils | , |
| fill_string | |||
| ) |
Definition at line 462 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::fill_string().
| TEST | ( | StringUtils | , |
| format_string_computed_lens | |||
| ) |
Definition at line 483 of file ah-string-utils.cc.
References Aleph::DynList< T >::append(), Aleph::divide_and_conquer_partition_dp(), and Aleph::format_string().
| TEST | ( | StringUtils | , |
| format_string_csv | |||
| ) |
Definition at line 420 of file ah-string-utils.cc.
References Aleph::DynList< T >::append(), Aleph::divide_and_conquer_partition_dp(), and Aleph::format_string_csv().
| TEST | ( | StringUtils | , |
| format_string_no_underflow | |||
| ) |
Definition at line 406 of file ah-string-utils.cc.
References Aleph::DynList< T >::append(), Aleph::divide_and_conquer_partition_dp(), and Aleph::format_string().
| TEST | ( | StringUtils | , |
| join_dynlist | |||
| ) |
Definition at line 220 of file ah-string-utils.cc.
References Aleph::DynList< T >::append(), Aleph::divide_and_conquer_partition_dp(), Aleph::join(), and l.
| TEST | ( | StringUtils | , |
| justify_and_align_except_first | |||
| ) |
Definition at line 607 of file ah-string-utils.cc.
References Aleph::align_text_to_left_except_first(), Aleph::contains(), Aleph::divide_and_conquer_partition_dp(), and Aleph::justify_line_except_first().
| TEST | ( | StringUtils | , |
| numeric_boundaries | |||
| ) |
Definition at line 619 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), Aleph::is_long(), and Aleph::is_size_t().
| TEST | ( | StringUtils | , |
| numeric_parsers | |||
| ) |
Definition at line 231 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), Aleph::is_double(), Aleph::is_float(), Aleph::is_long(), and Aleph::is_size_t().
| TEST | ( | StringUtils | , |
| only_alpha_and_removals | |||
| ) |
Definition at line 212 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), Aleph::only_alpha(), Aleph::remove_spaces(), and Aleph::remove_symbols().
| TEST | ( | StringUtils | , |
| pascal_case | |||
| ) |
Definition at line 362 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::to_Pascalcase().
| TEST | ( | StringUtils | , |
| prefix_and_remove_prefix | |||
| ) |
Definition at line 257 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), Aleph::is_prefix(), and Aleph::remove_prefix().
| TEST | ( | StringUtils | , |
| split_and_split_string | |||
| ) |
Definition at line 290 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), l, LocateFunctions< Container, Type >::nth(), Aleph::HTList::size(), Aleph::split(), and Aleph::split_to_list().
| TEST | ( | StringUtils | , |
| split_camel_case | |||
| ) |
Definition at line 274 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::split_camel_case().
| TEST | ( | StringUtils | , |
| split_n | |||
| ) |
Definition at line 377 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), l, LocateFunctions< Container, Type >::nth(), Aleph::HTList::size(), and Aleph::split_n().
| TEST | ( | StringUtils | , |
| split_pos | |||
| ) |
Definition at line 368 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::split_pos().
| TEST | ( | StringUtils | , |
| split_text_into_words_and_lines | |||
| ) |
Definition at line 593 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), l, LocateFunctions< Container, Type >::nth(), Aleph::HTList::size(), Aleph::split_text_into_lines(), Aleph::split_text_into_words(), and w.
| TEST | ( | StringUtils | , |
| split_to_array | |||
| ) |
Definition at line 473 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::split_to_array().
| TEST | ( | StringUtils | , |
| text_wrapping_and_shift | |||
| ) |
Definition at line 432 of file ah-string-utils.cc.
References Aleph::align_text_to_left(), Aleph::contains(), Aleph::divide_and_conquer_partition_dp(), Aleph::justify_text(), and Aleph::shift_lines_to_left().
| TEST | ( | StringUtils | , |
| to_name | |||
| ) |
Definition at line 267 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::to_name().
| TEST | ( | StringUtils | , |
| to_string_matrix_and_lines | |||
| ) |
Definition at line 533 of file ah-string-utils.cc.
References Aleph::DynList< T >::append(), Aleph::contains(), Aleph::divide_and_conquer_partition_dp(), and Aleph::to_string().
| TEST | ( | StringUtils | , |
| trim_variants | |||
| ) |
Definition at line 154 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), Aleph::trim(), and Aleph::trim_in_place().
| TEST | ( | StringUtils | , |
| vector_to_string | |||
| ) |
Definition at line 135 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), and Aleph::to_string().
| TEST | ( | StringUtilsCritical | , |
| format_string_exact_alignment_and_stream_output | |||
| ) |
Definition at line 497 of file ah-string-utils.cc.
References Aleph::DynList< T >::append(), Aleph::divide_and_conquer_partition_dp(), and Aleph::format_string().
| TEST | ( | StringUtilsCritical | , |
| justify_text_exact_wrapping_and_margins | |||
| ) |
Definition at line 550 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), Aleph::justify_text(), and Aleph::split_text_into_lines().
| TEST | ( | StringUtilsCritical | , |
| numeric_parsing_strictness | |||
| ) |
Definition at line 564 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), Aleph::is_double(), and Aleph::safe_atof().
| TEST | ( | StringUtilsCritical | , |
| split_string_edge_cases | |||
| ) |
Definition at line 325 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), expect_tokens_eq(), reference_split_string(), Aleph::split_to_array(), and Aleph::split_to_list().
| TEST | ( | StringUtilsStress | , |
| build_pars_list_round_trip_for_ints | |||
| ) |
Definition at line 785 of file ah-string-utils.cc.
References Aleph::build_pars_list(), Aleph::divide_and_conquer_partition_dp(), rng, and stress_multiplier().
| TEST | ( | StringUtilsStress | , |
| case_conversion_no_crash_and_preserves_length | |||
| ) |
Definition at line 772 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), random_string(), rng, stress_multiplier(), Aleph::to_lower(), and Aleph::to_upper().
| TEST | ( | StringUtilsStress | , |
| split_n_recomposes | |||
| ) |
Definition at line 689 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), random_ascii_token(), rng, Aleph::split_n(), and stress_multiplier().
| TEST | ( | StringUtilsStress | , |
| split_pos_recomposes | |||
| ) |
Definition at line 674 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), random_ascii_token(), rng, Aleph::split_pos(), and stress_multiplier().
| TEST | ( | StringUtilsStress | , |
| split_string_matches_reference_parser | |||
| ) |
Definition at line 734 of file ah-string-utils.cc.
References Aleph::and, Aleph::divide_and_conquer_partition_dp(), expect_tokens_eq(), reference_split_string(), rng, Aleph::split_to_array(), Aleph::split_to_list(), and stress_multiplier().
| TEST | ( | StringUtilsStress | , |
| split_string_tokens_have_no_delims | |||
| ) |
Definition at line 708 of file ah-string-utils.cc.
References Aleph::divide_and_conquer_partition_dp(), random_ascii_token(), rng, Aleph::split_to_list(), and stress_multiplier().
| TEST | ( | util | , |
| concat | |||
| ) |
Definition at line 125 of file ah-string-utils.cc.
References Aleph::concat(), and Aleph::divide_and_conquer_partition_dp().