mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 10:32:29 +00:00
feat(string): add SStrLen
This commit is contained in:
parent
7aa414f95a
commit
d3f3c10aa5
3 changed files with 18 additions and 0 deletions
|
|
@ -201,3 +201,12 @@ uint32_t SStrHashHT(const char* string) {
|
||||||
|
|
||||||
return bjhash((uint8_t*)&normalized, length, 0);
|
return bjhash((uint8_t*)&normalized, length, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t SStrLen(const char* string) {
|
||||||
|
STORM_ASSERT(string);
|
||||||
|
|
||||||
|
const char* c;
|
||||||
|
for (c = string; *c; ++c)
|
||||||
|
;
|
||||||
|
return c - string;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,6 @@ size_t SStrCopy(char* dest, const char* source, size_t destsize);
|
||||||
|
|
||||||
uint32_t SStrHashHT(const char* string);
|
uint32_t SStrHashHT(const char* string);
|
||||||
|
|
||||||
|
size_t SStrLen(const char* string);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -54,3 +54,10 @@ TEST_CASE("SStrHashHT", "[string]") {
|
||||||
REQUIRE(hashForwardSlash == hashBackSlash);
|
REQUIRE(hashForwardSlash == hashBackSlash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("SStrLen", "[string]") {
|
||||||
|
SECTION("calculates string length correctly") {
|
||||||
|
auto length = SStrLen("foo");
|
||||||
|
REQUIRE(length == 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue