mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Removing dependecy on CRT.
This commit is contained in:
@@ -28,13 +28,13 @@ int main()
|
||||
for (uint32_t jj = 0; jj < numElements; ++jj)
|
||||
{
|
||||
tinystl::pair<TinyStlUnorderedMap::iterator, bool> ok = map.insert(tinystl::make_pair(uint64_t(jj), uint16_t(jj) ) );
|
||||
assert(ok.second);
|
||||
assert(ok.second); BX_UNUSED(ok);
|
||||
}
|
||||
|
||||
for (uint32_t jj = 0; jj < numElements; ++jj)
|
||||
{
|
||||
bool ok = bx::mapRemove(map, uint64_t(jj) );
|
||||
assert(ok);
|
||||
assert(ok); BX_UNUSED(ok);
|
||||
}
|
||||
|
||||
assert(map.size() == 0);
|
||||
@@ -56,13 +56,13 @@ int main()
|
||||
for (uint32_t jj = 0; jj < numElements; ++jj)
|
||||
{
|
||||
std::pair<StdUnorderedMap::iterator, bool> ok = map.insert(std::make_pair(uint64_t(jj), uint16_t(jj) ) );
|
||||
assert(ok.second);
|
||||
assert(ok.second); BX_UNUSED(ok);
|
||||
}
|
||||
|
||||
for (uint32_t jj = 0; jj < numElements; ++jj)
|
||||
{
|
||||
bool ok = bx::mapRemove(map, uint64_t(jj) );
|
||||
assert(ok);
|
||||
assert(ok); BX_UNUSED(ok);
|
||||
}
|
||||
|
||||
assert(map.size() == 0);
|
||||
@@ -83,13 +83,13 @@ int main()
|
||||
for (uint32_t jj = 0; jj < numElements; ++jj)
|
||||
{
|
||||
bool ok = map.insert(jj, uint16_t(jj) );
|
||||
assert(ok);
|
||||
assert(ok); BX_UNUSED(ok);
|
||||
}
|
||||
|
||||
for (uint32_t jj = 0; jj < numElements; ++jj)
|
||||
{
|
||||
bool ok = map.removeByKey(uint64_t(jj) );
|
||||
assert(ok);
|
||||
assert(ok); BX_UNUSED(ok);
|
||||
}
|
||||
|
||||
assert(map.getNumElements() == 0);
|
||||
|
||||
@@ -40,6 +40,29 @@ TEST_CASE("strlncpy", "")
|
||||
REQUIRE(num == 4);
|
||||
}
|
||||
|
||||
TEST_CASE("strincmp", "")
|
||||
{
|
||||
REQUIRE(0 == bx::strincmp("test", "test") );
|
||||
REQUIRE(0 == bx::strincmp("test", "testestes", 4) );
|
||||
REQUIRE(0 == bx::strincmp("testestes", "test", 4) );
|
||||
}
|
||||
|
||||
TEST_CASE("strnchr", "")
|
||||
{
|
||||
const char* test = "test";
|
||||
REQUIRE(NULL == bx::strnchr(test, 's', 0) );
|
||||
REQUIRE(NULL == bx::strnchr(test, 's', 2) );
|
||||
REQUIRE(&test[2] == bx::strnchr(test, 's') );
|
||||
}
|
||||
|
||||
TEST_CASE("strnrchr", "")
|
||||
{
|
||||
const char* test = "test";
|
||||
REQUIRE(NULL == bx::strnrchr(test, 's', 0) );
|
||||
REQUIRE(NULL == bx::strnrchr(test, 's', 1) );
|
||||
REQUIRE(&test[2] == bx::strnrchr(test, 's') );
|
||||
}
|
||||
|
||||
TEST_CASE("StringView", "")
|
||||
{
|
||||
bx::StringView sv("test");
|
||||
|
||||
@@ -20,3 +20,35 @@ TEST_CASE("vsnprintf truncated", "Truncated output buffer.")
|
||||
REQUIRE(10 == bx::snprintf(buffer, BX_COUNTOF(buffer), "Ten chars!") );
|
||||
REQUIRE(0 == strcmp(buffer, "Ten ch") );
|
||||
}
|
||||
|
||||
static bool test(const char* _expected, const char* _format, ...)
|
||||
{
|
||||
int32_t max = (int32_t)strlen(_expected) + 1;
|
||||
char* temp = (char*)alloca(max);
|
||||
|
||||
va_list argList;
|
||||
va_start(argList, _format);
|
||||
int32_t len = bx::vsnprintf(temp, max, _format, argList);
|
||||
va_end(argList);
|
||||
|
||||
bool result = true
|
||||
&& len == max-1
|
||||
&& 0 == strcmp(_expected, temp)
|
||||
;
|
||||
|
||||
if (!result)
|
||||
{
|
||||
printf("result (%d) %s, expected (%d) %s\n", len, temp, max-1, _expected);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
TEST_CASE("vsnprintf f", "")
|
||||
{
|
||||
REQUIRE(test("1.337", "%0.3f", 1.337) );
|
||||
REQUIRE(test(" 13.370", "%8.3f", 13.37) );
|
||||
REQUIRE(test(" 13.370", "%*.*f", 8, 3, 13.37) );
|
||||
REQUIRE(test("13.370 ", "%-8.3f", 13.37) );
|
||||
REQUIRE(test("13.370 ", "%*.*f", -8, 3, 13.37) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user