mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Added test tags. Broken up libm tests.
This commit is contained in:
@@ -88,7 +88,7 @@ static const FilePathSplit s_filePathSplit[] =
|
||||
{ "/tmp/abv/gd/", true, "/tmp/abv/gd/", "", "", "" },
|
||||
};
|
||||
|
||||
TEST_CASE("FilePath", "")
|
||||
TEST_CASE("FilePath", "[filepath][string]")
|
||||
{
|
||||
bx::FilePath fp;
|
||||
for (uint32_t ii = 0; ii < BX_COUNTOF(s_filePathTest); ++ii)
|
||||
@@ -118,7 +118,7 @@ TEST_CASE("FilePath", "")
|
||||
};
|
||||
}
|
||||
|
||||
TEST_CASE("FilePath temp", "")
|
||||
TEST_CASE("FilePath temp", "[filepath]")
|
||||
{
|
||||
bx::FilePath tmp(bx::Dir::Temp);
|
||||
REQUIRE(0 != bx::strCmp(".", tmp.getPath().getPtr() ) );
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <stdint.h> // intXX_t
|
||||
#include <limits.h> // UCHAR_*
|
||||
|
||||
TEST_CASE("isFinite, isInfinite, isNan", "")
|
||||
TEST_CASE("isFinite, isInfinite, isNan", "[math]")
|
||||
{
|
||||
for (uint64_t ii = 0; ii < UINT32_MAX; ii += rand()%(1<<13)+1)
|
||||
{
|
||||
@@ -39,7 +39,7 @@ bool log2_test(float _a)
|
||||
return bx::log2(_a) == bx::log(_a) * (1.0f / bx::log(2.0f) );
|
||||
}
|
||||
|
||||
TEST_CASE("log2", "")
|
||||
TEST_CASE("log2", "[math][libm]")
|
||||
{
|
||||
log2_test(0.0f);
|
||||
log2_test(256.0f);
|
||||
@@ -75,7 +75,7 @@ TEST_CASE("log2", "")
|
||||
BX_PRAGMA_DIAGNOSTIC_PUSH();
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4723) // potential divide by 0
|
||||
|
||||
TEST_CASE("libm sqrt", "")
|
||||
TEST_CASE("rsqrt", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
@@ -110,6 +110,12 @@ TEST_CASE("libm sqrt", "")
|
||||
REQUIRE(err.isOk());
|
||||
REQUIRE(bx::isEqual(bx::rsqrt(xx), 1.0f / ::sqrtf(xx), 0.00001f));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("sqrt", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
|
||||
// sqrtRef
|
||||
REQUIRE(bx::isNan(bx::sqrtRef(-1.0f)));
|
||||
@@ -165,27 +171,47 @@ TEST_CASE("libm sqrt", "")
|
||||
|
||||
BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
|
||||
TEST_CASE("libm", "")
|
||||
TEST_CASE("abs", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
|
||||
REQUIRE(1389.0f == bx::abs(-1389.0f) );
|
||||
REQUIRE(1389.0f == bx::abs( 1389.0f) );
|
||||
REQUIRE( 0.0f == bx::abs(-0.0f) );
|
||||
REQUIRE( 0.0f == bx::abs( 0.0f) );
|
||||
}
|
||||
|
||||
TEST_CASE("mod", "[math][libm]")
|
||||
{
|
||||
REQUIRE(389.0f == bx::mod(1389.0f, 1000.0f) );
|
||||
}
|
||||
|
||||
TEST_CASE("floor", "[math][libm]")
|
||||
{
|
||||
REQUIRE( 13.0f == bx::floor( 13.89f) );
|
||||
REQUIRE(-14.0f == bx::floor(-13.89f) );
|
||||
}
|
||||
|
||||
TEST_CASE("ceil", "[math][libm]")
|
||||
{
|
||||
REQUIRE( 14.0f == bx::ceil( 13.89f) );
|
||||
REQUIRE(-13.0f == bx::ceil( -13.89f) );
|
||||
}
|
||||
|
||||
TEST_CASE("trunc", "[math][libm]")
|
||||
{
|
||||
REQUIRE( 13.0f == bx::trunc( 13.89f) );
|
||||
REQUIRE(-13.0f == bx::trunc(-13.89f) );
|
||||
}
|
||||
|
||||
TEST_CASE("fract", "[math][libm]")
|
||||
{
|
||||
REQUIRE(bx::isEqual( 0.89f, bx::fract( 13.89f), 0.000001f) );
|
||||
REQUIRE(bx::isEqual(-0.89f, bx::fract(-13.89f), 0.000001f) );
|
||||
}
|
||||
|
||||
TEST_CASE("ldexp", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
|
||||
for (int32_t yy = -10; yy < 10; ++yy)
|
||||
{
|
||||
@@ -195,6 +221,12 @@ TEST_CASE("libm", "")
|
||||
REQUIRE(bx::isEqual(bx::ldexp(xx, yy), ::ldexpf(xx, yy), 0.00001f) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("exp", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
|
||||
for (float xx = -80.0f; xx < 80.0f; xx += 0.1f)
|
||||
{
|
||||
@@ -202,6 +234,12 @@ TEST_CASE("libm", "")
|
||||
REQUIRE(err.isOk() );
|
||||
REQUIRE(bx::isEqual(bx::exp(xx), ::expf(xx), 0.00001f) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("pow", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
|
||||
for (float xx = -100.0f; xx < 100.0f; xx += 0.1f)
|
||||
{
|
||||
@@ -209,6 +247,12 @@ TEST_CASE("libm", "")
|
||||
REQUIRE(err.isOk() );
|
||||
REQUIRE(bx::isEqual(bx::pow(1.389f, xx), ::powf(1.389f, xx), 0.00001f) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("asin", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
|
||||
for (float xx = -1.0f; xx < 1.0f; xx += 0.001f)
|
||||
{
|
||||
@@ -216,6 +260,12 @@ TEST_CASE("libm", "")
|
||||
REQUIRE(err.isOk() );
|
||||
REQUIRE(bx::isEqual(bx::asin(xx), ::asinf(xx), 0.0001f) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("sin", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
|
||||
for (float xx = -100.0f; xx < 100.0f; xx += 0.1f)
|
||||
{
|
||||
@@ -230,6 +280,12 @@ TEST_CASE("libm", "")
|
||||
REQUIRE(err.isOk() );
|
||||
REQUIRE(bx::isEqual(bx::sin(xx), ::sinf(xx), 0.00001f) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("sinh", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
|
||||
for (float xx = -1.0f; xx < 1.0f; xx += 0.1f)
|
||||
{
|
||||
@@ -237,6 +293,12 @@ TEST_CASE("libm", "")
|
||||
REQUIRE(err.isOk() );
|
||||
REQUIRE(bx::isEqual(bx::sinh(xx), ::sinhf(xx), 0.00001f) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("acos", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
|
||||
for (float xx = -1.0f; xx < 1.0f; xx += 0.001f)
|
||||
{
|
||||
@@ -244,6 +306,12 @@ TEST_CASE("libm", "")
|
||||
REQUIRE(err.isOk() );
|
||||
REQUIRE(bx::isEqual(bx::acos(xx), ::acosf(xx), 0.0001f) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("cos", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
|
||||
for (float xx = -100.0f; xx < 100.0f; xx += 0.1f)
|
||||
{
|
||||
@@ -258,6 +326,12 @@ TEST_CASE("libm", "")
|
||||
REQUIRE(err.isOk() );
|
||||
REQUIRE(bx::isEqual(bx::cos(xx), ::cosf(xx), 0.00001f) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("tan", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
|
||||
for (float xx = -100.0f; xx < 100.0f; xx += 0.1f)
|
||||
{
|
||||
@@ -265,6 +339,12 @@ TEST_CASE("libm", "")
|
||||
REQUIRE(err.isOk() );
|
||||
REQUIRE(bx::isEqual(bx::tan(xx), ::tanf(xx), 0.001f) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("tanh", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
|
||||
for (float xx = -1.0f; xx < 1.0f; xx += 0.1f)
|
||||
{
|
||||
@@ -272,6 +352,12 @@ TEST_CASE("libm", "")
|
||||
REQUIRE(err.isOk() );
|
||||
REQUIRE(bx::isEqual(bx::tanh(xx), ::tanhf(xx), 0.00001f) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("atan", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
|
||||
for (float xx = -100.0f; xx < 100.0f; xx += 0.1f)
|
||||
{
|
||||
@@ -281,7 +367,7 @@ TEST_CASE("libm", "")
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("atan2", "")
|
||||
TEST_CASE("atan2", "[math][libm]")
|
||||
{
|
||||
bx::WriterI* writer = bx::getNullOut();
|
||||
bx::Error err;
|
||||
@@ -301,7 +387,7 @@ TEST_CASE("atan2", "")
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("sign", "")
|
||||
TEST_CASE("sign", "[math][libm]")
|
||||
{
|
||||
STATIC_REQUIRE(-1 == bx::sign(-0.1389f) );
|
||||
STATIC_REQUIRE( 0 == bx::sign( 0.0000f) );
|
||||
@@ -311,7 +397,7 @@ TEST_CASE("sign", "")
|
||||
REQUIRE( 1 == bx::sign( bx::kFloatInfinity) );
|
||||
}
|
||||
|
||||
TEST_CASE("signbit", "")
|
||||
TEST_CASE("signbit", "[math][libm]")
|
||||
{
|
||||
STATIC_REQUIRE( bx::signbit(-0.1389f) );
|
||||
STATIC_REQUIRE(!bx::signbit( 0.0000f) );
|
||||
@@ -321,7 +407,7 @@ TEST_CASE("signbit", "")
|
||||
REQUIRE(!bx::signbit( bx::kFloatInfinity) );
|
||||
}
|
||||
|
||||
TEST_CASE("copysign", "")
|
||||
TEST_CASE("copysign", "[math][libm]")
|
||||
{
|
||||
STATIC_REQUIRE( 0.1389f == bx::copysign(-0.1389f, +1389) );
|
||||
STATIC_REQUIRE(-0.0000f == bx::copysign( 0.0000f, -1389) );
|
||||
@@ -330,17 +416,18 @@ TEST_CASE("copysign", "")
|
||||
REQUIRE(-bx::kFloatInfinity == bx::copysign(bx::kFloatInfinity, -1389) );
|
||||
}
|
||||
|
||||
TEST_CASE("ToBits", "")
|
||||
TEST_CASE("bitsToFloat, floatToBits, bitsToDouble, doubleToBits", "[math]")
|
||||
{
|
||||
REQUIRE(UINT32_C(0x12345678) == bx::floatToBits( bx::bitsToFloat( UINT32_C(0x12345678) ) ) );
|
||||
REQUIRE(UINT64_C(0x123456789abcdef0) == bx::doubleToBits(bx::bitsToDouble(UINT32_C(0x123456789abcdef0) ) ) );
|
||||
}
|
||||
|
||||
TEST_CASE("lerp", "")
|
||||
TEST_CASE("lerp", "[math]")
|
||||
{
|
||||
REQUIRE(1389.0f == bx::lerp(1389.0f, 1453.0f, 0.0f) );
|
||||
REQUIRE(1453.0f == bx::lerp(1389.0f, 1453.0f, 1.0f) );
|
||||
REQUIRE(0.5f == bx::lerp(0.0f, 1.0f, 0.5f) );
|
||||
REQUIRE( 0.5f == bx::lerp( 0.0f, 1.0f, 0.5f) );
|
||||
REQUIRE( 0.0f == bx::lerp( 0.0f, 0.0f, 0.5f) );
|
||||
}
|
||||
|
||||
void mtxCheck(const float* _a, const float* _b)
|
||||
@@ -372,7 +459,7 @@ void mtxCheck(const float* _a, const float* _b)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("vec3", "")
|
||||
TEST_CASE("vec3", "[math][vec3]")
|
||||
{
|
||||
bx::Vec3 normalized = bx::normalize({0.0f, 1.0f, 0.0f});
|
||||
REQUIRE(bx::isEqual(normalized, {0.0f, 1.0f, 0.0f}, 0.0f) );
|
||||
@@ -381,7 +468,7 @@ TEST_CASE("vec3", "")
|
||||
REQUIRE(bx::isEqual(length, 1.0f, 0.0f) );
|
||||
}
|
||||
|
||||
TEST_CASE("quaternion", "")
|
||||
TEST_CASE("quaternion", "[math][quaternion]")
|
||||
{
|
||||
float mtxQ[16];
|
||||
float mtx[16];
|
||||
@@ -450,7 +537,7 @@ TEST_CASE("quaternion", "")
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("limits", "")
|
||||
TEST_CASE("limits", "[math]")
|
||||
{
|
||||
STATIC_REQUIRE(bx::LimitsT<int8_t>::min == INT8_MIN);
|
||||
STATIC_REQUIRE(bx::LimitsT<int8_t>::max == INT8_MAX);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <bx/string.h>
|
||||
#include <bx/rng.h>
|
||||
|
||||
TEST_CASE("sort-quickSort", "")
|
||||
TEST_CASE("quickSort", "[sort]")
|
||||
{
|
||||
const char* str[] =
|
||||
{
|
||||
@@ -30,6 +30,40 @@ TEST_CASE("sort-quickSort", "")
|
||||
|
||||
REQUIRE(bx::isSorted(str, BX_COUNTOF(str) ) );
|
||||
|
||||
int8_t byte[128];
|
||||
bx::RngMwc rng;
|
||||
for (uint32_t ii = 0; ii < BX_COUNTOF(byte); ++ii)
|
||||
{
|
||||
byte[ii] = rng.gen()&0xff;
|
||||
}
|
||||
|
||||
REQUIRE(!bx::isSorted(byte, BX_COUNTOF(byte) ) );
|
||||
|
||||
bx::quickSort(byte, BX_COUNTOF(byte) );
|
||||
|
||||
for (uint32_t ii = 1; ii < BX_COUNTOF(byte); ++ii)
|
||||
{
|
||||
REQUIRE(byte[ii-1] <= byte[ii]);
|
||||
}
|
||||
|
||||
REQUIRE(bx::isSorted(byte, BX_COUNTOF(byte) ) );
|
||||
}
|
||||
|
||||
TEST_CASE("binarySearch", "[sort]")
|
||||
{
|
||||
const char* str[] =
|
||||
{
|
||||
"jabuka",
|
||||
"kruska",
|
||||
"malina",
|
||||
"jagoda",
|
||||
};
|
||||
|
||||
REQUIRE(!bx::isSorted(str, BX_COUNTOF(str) ) );
|
||||
|
||||
bx::quickSort(str, BX_COUNTOF(str) );
|
||||
REQUIRE(bx::isSorted(str, BX_COUNTOF(str) ) );
|
||||
|
||||
auto bsearchStrCmpFn = [](const void* _lhs, const void* _rhs)
|
||||
{
|
||||
const char* lhs = (const char*)_lhs;
|
||||
@@ -55,27 +89,9 @@ TEST_CASE("sort-quickSort", "")
|
||||
|
||||
REQUIRE( 3 == bx::lowerBound("malina", str, BX_COUNTOF(str), sizeof(str[0]), bsearchStrCmpFn) );
|
||||
REQUIRE( 4 == bx::upperBound("malina", str, BX_COUNTOF(str), sizeof(str[0]), bsearchStrCmpFn) );
|
||||
|
||||
int8_t byte[128];
|
||||
bx::RngMwc rng;
|
||||
for (uint32_t ii = 0; ii < BX_COUNTOF(byte); ++ii)
|
||||
{
|
||||
byte[ii] = rng.gen()&0xff;
|
||||
}
|
||||
|
||||
REQUIRE(!bx::isSorted(byte, BX_COUNTOF(byte) ) );
|
||||
|
||||
bx::quickSort(byte, BX_COUNTOF(byte) );
|
||||
|
||||
for (uint32_t ii = 1; ii < BX_COUNTOF(byte); ++ii)
|
||||
{
|
||||
REQUIRE(byte[ii-1] <= byte[ii]);
|
||||
}
|
||||
|
||||
REQUIRE(bx::isSorted(byte, BX_COUNTOF(byte) ) );
|
||||
}
|
||||
|
||||
TEST_CASE("sort-unique", "")
|
||||
TEST_CASE("unique", "[sort]")
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 | 14
|
||||
int32_t test[] = { 100, 101, 101, 101, 103, 104, 105, 105, 105, 106, 106, 107, 108, 109 };
|
||||
@@ -96,7 +112,7 @@ TEST_CASE("sort-unique", "")
|
||||
REQUIRE(9 == bx::unique(test, last) );
|
||||
}
|
||||
|
||||
TEST_CASE("sort-lower/upperBound int32_t", "")
|
||||
TEST_CASE("lowerBound, upperBound int32_t", "[sort]")
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 | 14
|
||||
const int32_t test[] = { 100, 101, 101, 101, 103, 104, 105, 105, 105, 106, 106, 107, 108, 109 };
|
||||
@@ -150,7 +166,7 @@ void compareTest(const Ty& _min, const Ty& _max)
|
||||
REQUIRE(-1 == compareDescendingTest<Ty>(_max, _min) );
|
||||
}
|
||||
|
||||
TEST_CASE("sort-ComparisonFn", "")
|
||||
TEST_CASE("ComparisonFn", "[sort]")
|
||||
{
|
||||
compareTest< int8_t>( -13, 89);
|
||||
compareTest<int16_t>(-1389, 1389);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
bx::AllocatorI* g_allocator;
|
||||
|
||||
TEST_CASE("StringLiteral", "")
|
||||
TEST_CASE("StringLiteral", "[string]")
|
||||
{
|
||||
constexpr bx::StringLiteral tmp[] = { "1389", "abvgd", "mac", "pod" };
|
||||
|
||||
@@ -47,14 +47,14 @@ TEST_CASE("StringLiteral", "")
|
||||
REQUIRE(0 == bx::strCmp("abvgd", sv) );
|
||||
}
|
||||
|
||||
TEST_CASE("stringPrintfTy", "")
|
||||
TEST_CASE("stringPrintfTy", "[string]")
|
||||
{
|
||||
std::string test;
|
||||
bx::stringPrintf(test, "printf into std::string.");
|
||||
REQUIRE(0 == bx::strCmp(bx::StringView(test.data(), int32_t(test.length() ) ), "printf into std::string.") );
|
||||
}
|
||||
|
||||
TEST_CASE("prettify", "")
|
||||
TEST_CASE("prettify", "[string]")
|
||||
{
|
||||
char tmp[1024];
|
||||
prettify(tmp, BX_COUNTOF(tmp), 4000, bx::Units::Kilo);
|
||||
@@ -64,7 +64,7 @@ TEST_CASE("prettify", "")
|
||||
REQUIRE(0 == bx::strCmp(tmp, "4.00 KiB") );
|
||||
}
|
||||
|
||||
TEST_CASE("chars", "")
|
||||
TEST_CASE("chars", "[string]")
|
||||
{
|
||||
for (char ch = 'A'; ch <= 'Z'; ++ch)
|
||||
{
|
||||
@@ -77,7 +77,7 @@ TEST_CASE("chars", "")
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("strLen", "")
|
||||
TEST_CASE("strLen", "[string]")
|
||||
{
|
||||
const char* test = "test";
|
||||
|
||||
@@ -86,7 +86,7 @@ TEST_CASE("strLen", "")
|
||||
REQUIRE(4 == bx::strLen(test, INT32_MAX) );
|
||||
}
|
||||
|
||||
TEST_CASE("strCopy", "")
|
||||
TEST_CASE("strCopy", "[string]")
|
||||
{
|
||||
char dst[128];
|
||||
size_t num;
|
||||
@@ -108,7 +108,7 @@ TEST_CASE("strCopy", "")
|
||||
REQUIRE(num == 4);
|
||||
}
|
||||
|
||||
TEST_CASE("strCat", "")
|
||||
TEST_CASE("strCat", "[string]")
|
||||
{
|
||||
char dst[128] = { '\0' };
|
||||
|
||||
@@ -124,7 +124,7 @@ TEST_CASE("strCat", "")
|
||||
REQUIRE(0 == bx::strCmp(dst, "copycat-cat") );
|
||||
}
|
||||
|
||||
TEST_CASE("strCmp", "")
|
||||
TEST_CASE("strCmp", "[string]")
|
||||
{
|
||||
REQUIRE(0 < bx::strCmp("abvgd", "abv") );
|
||||
REQUIRE(0 < bx::strCmp("abvgd", "") );
|
||||
@@ -133,7 +133,7 @@ TEST_CASE("strCmp", "")
|
||||
REQUIRE(0 != bx::strCmp("meh", "meh/") );
|
||||
}
|
||||
|
||||
TEST_CASE("strCmpI", "")
|
||||
TEST_CASE("strCmpI", "[string]")
|
||||
{
|
||||
REQUIRE(0 == bx::strCmpI("test", "test") );
|
||||
REQUIRE(0 == bx::strCmpI("test", "testestes", 4) );
|
||||
@@ -154,7 +154,7 @@ TEST_CASE("strCmpI", "")
|
||||
REQUIRE(0 < bx::strCmpI(abvgd, empty) );
|
||||
}
|
||||
|
||||
TEST_CASE("strCmpV", "")
|
||||
TEST_CASE("strCmpV", "[string]")
|
||||
{
|
||||
REQUIRE(0 == bx::strCmpV("test", "test") );
|
||||
REQUIRE(0 == bx::strCmpV("test", "testestes", 4) );
|
||||
@@ -183,7 +183,7 @@ static int32_t strCmpV(const void* _lhs, const void* _rhs)
|
||||
return result;
|
||||
}
|
||||
|
||||
TEST_CASE("strCmpV sort", "")
|
||||
TEST_CASE("strCmpV sort", "[string][sort]")
|
||||
{
|
||||
const char* test[] =
|
||||
{
|
||||
@@ -217,7 +217,7 @@ TEST_CASE("strCmpV sort", "")
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("strRFind", "")
|
||||
TEST_CASE("strRFind", "[string]")
|
||||
{
|
||||
const char* test = "test";
|
||||
REQUIRE(bx::strRFind(bx::StringView(test, 0), 's').isEmpty() );
|
||||
@@ -226,7 +226,7 @@ TEST_CASE("strRFind", "")
|
||||
REQUIRE(&test[3] == bx::strRFind(test, 't').getPtr() );
|
||||
}
|
||||
|
||||
TEST_CASE("strFindI", "")
|
||||
TEST_CASE("strFindI", "[string]")
|
||||
{
|
||||
const char* test = "The Quick Brown Fox Jumps Over The Lazy Dog.";
|
||||
|
||||
@@ -236,7 +236,7 @@ TEST_CASE("strFindI", "")
|
||||
REQUIRE(&test[4] == bx::strFindI(test, "quick").getPtr() );
|
||||
}
|
||||
|
||||
TEST_CASE("strFind", "")
|
||||
TEST_CASE("strFind", "[string]")
|
||||
{
|
||||
{
|
||||
const char* test = "test";
|
||||
@@ -275,7 +275,7 @@ TEST_CASE("strFind", "")
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("strSkip", "")
|
||||
TEST_CASE("strSkip", "[string]")
|
||||
{
|
||||
const bx::StringView t0(" test X");
|
||||
|
||||
@@ -307,7 +307,7 @@ static bool testToStringS(Ty _value, const char* _expected, char _separator = '\
|
||||
return false;
|
||||
}
|
||||
|
||||
TEST_CASE("toString intXX_t/uintXX_t", "")
|
||||
TEST_CASE("toString intXX_t/uintXX_t", "[string]")
|
||||
{
|
||||
REQUIRE(testToStringS(0, "0") );
|
||||
REQUIRE(testToStringS(-256, "-256") );
|
||||
@@ -340,7 +340,7 @@ static bool testToString(Ty _value, const char* _expected)
|
||||
return false;
|
||||
}
|
||||
|
||||
TEST_CASE("toString double", "")
|
||||
TEST_CASE("toString double", "[string]")
|
||||
{
|
||||
REQUIRE(testToString(0.0, "0.0") );
|
||||
REQUIRE(testToString(-0.0, "-0.0") );
|
||||
@@ -392,14 +392,14 @@ static bool testFromString(Ty _value, const char* _input)
|
||||
return false;
|
||||
}
|
||||
|
||||
TEST_CASE("fromString float", "")
|
||||
TEST_CASE("fromString float", "[string]")
|
||||
{
|
||||
REQUIRE(testFromString<float>(std::numeric_limits<float>::min(), "1.175494351e-38") );
|
||||
REQUIRE(testFromString<float>(std::numeric_limits<float>::lowest(), "-3.402823466e+38") );
|
||||
REQUIRE(testFromString<float>(std::numeric_limits<float>::max(), "3.402823466e+38") );
|
||||
}
|
||||
|
||||
TEST_CASE("fromString double", "")
|
||||
TEST_CASE("fromString double", "[string]")
|
||||
{
|
||||
REQUIRE(testFromString<double>(0.0, "0.0") );
|
||||
REQUIRE(testFromString<double>(-0.0, "-0.0") );
|
||||
@@ -465,7 +465,7 @@ static bool testFromString(int32_t _value, const char* _input)
|
||||
return false;
|
||||
}
|
||||
|
||||
TEST_CASE("fromString int32_t", "")
|
||||
TEST_CASE("fromString int32_t", "[string]")
|
||||
{
|
||||
REQUIRE(testFromString(1389, "1389") );
|
||||
REQUIRE(testFromString(1389, " 1389") );
|
||||
@@ -476,7 +476,7 @@ TEST_CASE("fromString int32_t", "")
|
||||
REQUIRE(testFromString(-21, "-021") );
|
||||
}
|
||||
|
||||
TEST_CASE("StringView", "")
|
||||
TEST_CASE("StringView", "[string]")
|
||||
{
|
||||
bx::StringView sv("test");
|
||||
REQUIRE(4 == sv.getLength() );
|
||||
@@ -508,7 +508,7 @@ TEST_CASE("StringView", "")
|
||||
REQUIRE(0 == sv.getLength() );
|
||||
}
|
||||
|
||||
TEST_CASE("Trim", "")
|
||||
TEST_CASE("Trim", "[string]")
|
||||
{
|
||||
REQUIRE(bx::strLTrim("a", "a").isEmpty() );
|
||||
REQUIRE(0 == bx::strCmp(bx::strLTrim("aba", "a"), "ba") );
|
||||
@@ -544,7 +544,7 @@ TEST_CASE("Trim", "")
|
||||
REQUIRE(0 == bx::strCmp(bx::strTrim(uri.getPath(), "/"), "555333/podmac") );
|
||||
}
|
||||
|
||||
TEST_CASE("TrimSpace", "")
|
||||
TEST_CASE("TrimSpace", "[string]")
|
||||
{
|
||||
REQUIRE(bx::strLTrimSpace("").isEmpty() );
|
||||
REQUIRE(bx::strRTrimSpace("").isEmpty() );
|
||||
@@ -575,13 +575,13 @@ TEST_CASE("TrimSpace", "")
|
||||
REQUIRE(0 == bx::strCmp(bx::strTrimSpace(t3), t0) );
|
||||
}
|
||||
|
||||
TEST_CASE("strWord", "")
|
||||
TEST_CASE("strWord", "[string]")
|
||||
{
|
||||
REQUIRE(bx::strWord(" abvgd-1389.0").isEmpty() );
|
||||
REQUIRE(0 == bx::strCmp(bx::strWord("abvgd-1389.0"), "abvgd") );
|
||||
}
|
||||
|
||||
TEST_CASE("strFindBlock", "")
|
||||
TEST_CASE("strFindBlock", "[string]")
|
||||
{
|
||||
const bx::StringView test0("{ { {} {} abvgd; {} } }");
|
||||
const bx::StringView test1(test0, 1, INT32_MAX);
|
||||
@@ -590,7 +590,7 @@ TEST_CASE("strFindBlock", "")
|
||||
REQUIRE(19 == result.getLength() );
|
||||
}
|
||||
|
||||
TEST_CASE("prefix", "")
|
||||
TEST_CASE("prefix", "[string]")
|
||||
{
|
||||
REQUIRE( bx::hasPrefix("abvgd-1389.0", "abv") );
|
||||
REQUIRE(!bx::hasPrefix("abvgd-1389.0", "bvg") );
|
||||
@@ -600,7 +600,7 @@ TEST_CASE("prefix", "")
|
||||
REQUIRE(0 == bx::strCmp(bx::strTrimPrefix("abvgd-1389.0", "xyz"), "abvgd-1389.0") );
|
||||
}
|
||||
|
||||
TEST_CASE("suffix", "")
|
||||
TEST_CASE("suffix", "[string]")
|
||||
{
|
||||
REQUIRE( bx::hasSuffix("abvgd-1389.0", "389.0") );
|
||||
REQUIRE(!bx::hasSuffix("abvgd-1389.0", "1389") );
|
||||
@@ -610,7 +610,7 @@ TEST_CASE("suffix", "")
|
||||
REQUIRE(0 == bx::strCmp(bx::strTrimSuffix("abvgd-1389.0", "xyz"), "abvgd-1389.0") );
|
||||
}
|
||||
|
||||
TEST_CASE("0terminated", "")
|
||||
TEST_CASE("0terminated", "[string]")
|
||||
{
|
||||
const bx::StringView t0("1389");
|
||||
REQUIRE(t0.is0Terminated() );
|
||||
|
||||
@@ -43,7 +43,7 @@ static const UrlTest s_urlTest[] =
|
||||
},
|
||||
};
|
||||
|
||||
TEST_CASE("tokenizeUrl", "")
|
||||
TEST_CASE("tokenizeUrl", "[url][string]")
|
||||
{
|
||||
bx::UrlView url;
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
#include <limits>
|
||||
#include <inttypes.h>
|
||||
|
||||
TEST_CASE("vsnprintf NULL buffer", "No output buffer provided.")
|
||||
TEST_CASE("No output buffer provided.", "[string][printf]")
|
||||
{
|
||||
REQUIRE(4 == bx::snprintf(NULL, 0, "test") );
|
||||
|
||||
REQUIRE(1 == bx::snprintf(NULL, 0, "%d", 1) );
|
||||
}
|
||||
|
||||
TEST_CASE("vsnprintf truncated", "Truncated output buffer.")
|
||||
TEST_CASE("Truncated output buffer.", "[string][printf]")
|
||||
{
|
||||
REQUIRE(4 == bx::snprintf(NULL, 0, "abvg") );
|
||||
|
||||
@@ -70,7 +70,7 @@ static bool test(const char* _expected, const char* _format, ...)
|
||||
return result;
|
||||
}
|
||||
|
||||
TEST_CASE("vsnprintf f")
|
||||
TEST_CASE("Format %f", "[string][printf]")
|
||||
{
|
||||
REQUIRE(test("1.337", "%0.3f", 1.337) );
|
||||
REQUIRE(test(" 13.370", "%8.3f", 13.37) );
|
||||
@@ -157,7 +157,7 @@ TEST_CASE("vsnprintf f")
|
||||
REQUIRE(test("1.50000000000000000", "%.17f", 1.5) );
|
||||
}
|
||||
|
||||
TEST_CASE("vsnprintf d/i/o/u/x")
|
||||
TEST_CASE("Format %d, %i, %o, %u, %x", "[string][printf]")
|
||||
{
|
||||
REQUIRE(test("1337", "%d", 1337) );
|
||||
REQUIRE(test("1337 ", "%-20d", 1337) );
|
||||
@@ -230,7 +230,7 @@ TEST_CASE("vsnprintf d/i/o/u/x")
|
||||
REQUIRE(test("ffffffffffffffff", "%016" PRIx64, UINT64_MAX) );
|
||||
}
|
||||
|
||||
TEST_CASE("vsnprintf modifiers")
|
||||
TEST_CASE("Format modifiers", "[string][printf]")
|
||||
{
|
||||
REQUIRE(test("| 1.000000|", "|%10f|", 1.0f) );
|
||||
REQUIRE(test("|1.000000 |", "|%-10f|", 1.0f) );
|
||||
@@ -245,18 +245,18 @@ TEST_CASE("vsnprintf modifiers")
|
||||
REQUIRE(test("|+1. |", "|%+#-10.0f|", 1.0f) );
|
||||
}
|
||||
|
||||
TEST_CASE("vsnprintf p")
|
||||
TEST_CASE("Format %p", "[string][printf]")
|
||||
{
|
||||
REQUIRE(test("0xbadc0de", "%p", (void*)0xbadc0de) );
|
||||
REQUIRE(test("0xbadc0de ", "%-20p", (void*)0xbadc0de) );
|
||||
}
|
||||
|
||||
TEST_CASE("vsnprintf s")
|
||||
TEST_CASE("Format %s", "[string][printf]")
|
||||
{
|
||||
REQUIRE(test("(null)", "%s", NULL) );
|
||||
}
|
||||
|
||||
TEST_CASE("vsnprintf t")
|
||||
TEST_CASE("Format %td", "[string][printf]")
|
||||
{
|
||||
size_t size = size_t(-1);
|
||||
|
||||
@@ -265,7 +265,7 @@ TEST_CASE("vsnprintf t")
|
||||
REQUIRE(test("3221225472", "%td", size_t(3221225472) ) );
|
||||
}
|
||||
|
||||
TEST_CASE("vsnprintf n")
|
||||
TEST_CASE("Format %n", "[string][printf]")
|
||||
{
|
||||
char temp[64];
|
||||
|
||||
@@ -279,7 +279,7 @@ TEST_CASE("vsnprintf n")
|
||||
REQUIRE(6 == p2);
|
||||
}
|
||||
|
||||
TEST_CASE("vsnprintf g")
|
||||
TEST_CASE("Format %g", "[string][printf]")
|
||||
{
|
||||
REQUIRE(test(" 0.01", "%7.2g", .01) );
|
||||
REQUIRE(test(" 0.0123", "%7.4G", .0123) );
|
||||
@@ -287,7 +287,7 @@ TEST_CASE("vsnprintf g")
|
||||
// REQUIRE(test("1e+05", "%.0g", 123000.25) );
|
||||
}
|
||||
|
||||
TEST_CASE("vsnprintf")
|
||||
TEST_CASE("Format %c, %s, %S", "[string][printf]")
|
||||
{
|
||||
REQUIRE(test("x", "%c", 'x') );
|
||||
REQUIRE(test("x ", "%-20c", 'x') );
|
||||
@@ -315,7 +315,7 @@ TEST_CASE("vsnprintf")
|
||||
) );
|
||||
}
|
||||
|
||||
TEST_CASE("vsnprintf write")
|
||||
TEST_CASE("WriterI", "[string][printf]")
|
||||
{
|
||||
char tmp[64];
|
||||
bx::StaticMemoryBlock mb(tmp, sizeof(tmp));
|
||||
@@ -330,7 +330,7 @@ TEST_CASE("vsnprintf write")
|
||||
REQUIRE(0 == bx::strCmp(str, "1389") );
|
||||
}
|
||||
|
||||
TEST_CASE("snprintf invalid")
|
||||
TEST_CASE("Invalid", "[string][printf]")
|
||||
{
|
||||
char temp[64];
|
||||
REQUIRE(0 == bx::snprintf(temp, sizeof(temp), "%", 1) );
|
||||
|
||||
Reference in New Issue
Block a user