MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / test_comparisons

Function test_comparisons

scripts/test_stringzilla.cpp:2246–2257  ·  view source on GitHub ↗

* @brief Tests the correctness of the string class comparison methods, such as `compare` and `operator==`. */

Source from the content-addressed store, hash-verified

2244 * @brief Tests the correctness of the string class comparison methods, such as `compare` and `operator==`.
2245 */
2246void test_comparisons() {
2247 // Comparing relative order of the strings
2248 assert("a"_sv.compare("a") == 0);
2249 assert("a"_sv.compare("ab") == -1);
2250 assert("ab"_sv.compare("a") == 1);
2251 assert("a"_sv.compare("a\0"_sv) == -1);
2252 assert("a\0"_sv.compare("a") == 1);
2253 assert("a\0"_sv.compare("a\0"_sv) == 0);
2254 assert("a"_sv == "a"_sv);
2255 assert("a"_sv != "a\0"_sv);
2256 assert("a\0"_sv == "a\0"_sv);
2257}
2258
2259/**
2260 * @brief Tests the correctness of the string class search methods, such as `find` and `find_first_of`.

Callers 1

mainFunction · 0.85

Calls 1

compareMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…