Add DqnFixedString, remove DqnIni, minor cleanup
This commit is contained in:
parent
2c24eacc28
commit
056c0b3aea
68
DqnFixedString.cpp
Normal file
68
DqnFixedString.cpp
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
void DqnFixedString_Test()
|
||||||
|
{
|
||||||
|
LOG_HEADER();
|
||||||
|
{
|
||||||
|
DqnFixedString<512> str = DQN_SLICE_NAME("hello world");
|
||||||
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello world") == 0);
|
||||||
|
|
||||||
|
Log(Status::Ok, "Copy constructor DqnSlice<char>");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
DqnFixedString<512> zero = {};
|
||||||
|
DqnFixedString<512> str = DQN_SLICE_NAME("hello world");
|
||||||
|
str = zero;
|
||||||
|
DQN_ASSERT(str.len == 0 && str.str[0] == 0);
|
||||||
|
|
||||||
|
DqnSlice<char const> helloSlice = DQN_SLICE_NAME("hello");
|
||||||
|
str = helloSlice;
|
||||||
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello") == 0);
|
||||||
|
|
||||||
|
Log(Status::Ok, "Copy constructor (DqnFixedString<>)");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
DqnFixedString<512> str = DQN_SLICE_NAME("hello world");
|
||||||
|
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
||||||
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor") == 0);
|
||||||
|
|
||||||
|
Log(Status::Ok, "Sprintf");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
{
|
||||||
|
DqnFixedString<512> str = DQN_SLICE_NAME("hello world");
|
||||||
|
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
||||||
|
str += DQN_SLICE_NAME(".end");
|
||||||
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor.end") == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
DqnFixedString<512> str = DQN_SLICE_NAME("hello world");
|
||||||
|
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
||||||
|
DQN_ASSERT(str.SprintfAppend(" %d, %d", 100, 200));
|
||||||
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor 100, 200") == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log(Status::Ok, "Concatenation, operator +=, SprintfAppend");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
DqnFixedString<512> str;
|
||||||
|
str = "hello big world";
|
||||||
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello big world") == 0);
|
||||||
|
str = DqnFixedString<512>("goodbye", DQN_CHAR_COUNT("goodbye"));
|
||||||
|
DQN_ASSERT(DqnStr_Cmp(str.str, "goodbye") == 0);
|
||||||
|
|
||||||
|
Log(Status::Ok, "Copy constructor (char const *str, int len)");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
DqnFixedString<512> str = DQN_SLICE_NAME("hello world");
|
||||||
|
DQN_ASSERT(str.Sprintf("hello %s", "sailor"));
|
||||||
|
str = str + " end" + DQN_SLICE_NAME(" of");
|
||||||
|
DQN_ASSERT(DqnStr_Cmp(str.str, "hello sailor end of") == 0);
|
||||||
|
|
||||||
|
Log(Status::Ok, "Operator +");
|
||||||
|
}
|
||||||
|
}
|
@ -46,7 +46,6 @@ enum class Status
|
|||||||
Ok,
|
Ok,
|
||||||
Error
|
Error
|
||||||
};
|
};
|
||||||
|
|
||||||
void Log(Status status, char const *fmt, va_list argList)
|
void Log(Status status, char const *fmt, va_list argList)
|
||||||
{
|
{
|
||||||
DQN_ASSERT(globalIndent >= 0);
|
DQN_ASSERT(globalIndent >= 0);
|
||||||
@ -136,6 +135,8 @@ void LogHeader(char const *funcName)
|
|||||||
globalIndent++;
|
globalIndent++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "DqnFixedString.cpp"
|
||||||
|
|
||||||
void HandmadeMathVerifyMat4(DqnMat4 dqnMat, hmm_mat4 hmmMat)
|
void HandmadeMathVerifyMat4(DqnMat4 dqnMat, hmm_mat4 hmmMat)
|
||||||
{
|
{
|
||||||
f32 *hmmMatf = (f32 *)&hmmMat;
|
f32 *hmmMatf = (f32 *)&hmmMat;
|
||||||
@ -1879,11 +1880,11 @@ FILE_SCOPE void JobQueueDebugCallbackIncrementCounter(DqnJobQueue *const queue,
|
|||||||
DqnLockGuard guard = globalJobQueueLock.LockGuard();
|
DqnLockGuard guard = globalJobQueueLock.LockGuard();
|
||||||
globalDebugCounter++;
|
globalDebugCounter++;
|
||||||
|
|
||||||
u32 number = globalDebugCounter;
|
// u32 number = globalDebugCounter;
|
||||||
#if defined(DQN_WIN32_IMPLEMENTATION)
|
#if defined(DQN_WIN32_IMPLEMENTATION)
|
||||||
Log("JobQueueDebugCallbackIncrementCounter(): Thread %d: Incrementing Number: %d", GetCurrentThreadId(), number);
|
// Log("JobQueueDebugCallbackIncrementCounter(): Thread %d: Incrementing Number: %d", GetCurrentThreadId(), number);
|
||||||
#elif defined(DQN_UNIX_IMPLEMENTATION)
|
#elif defined(DQN_UNIX_IMPLEMENTATION)
|
||||||
Log("JobQueueDebugCallbackIncrementCounter(): Thread unix: Incrementing Number: %d", number);
|
// Log("JobQueueDebugCallbackIncrementCounter(): Thread unix: Incrementing Number: %d", number);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1944,7 +1945,7 @@ void DqnQuickSort_Test()
|
|||||||
u32 *stdArray = (u32 *)stack.Push(sizeInBytes);
|
u32 *stdArray = (u32 *)stack.Push(sizeInBytes);
|
||||||
DQN_ASSERT(dqnCPPArray && stdArray);
|
DQN_ASSERT(dqnCPPArray && stdArray);
|
||||||
|
|
||||||
f64 dqnCPPTimings[5] = {};
|
f64 dqnCPPTimings[2] = {};
|
||||||
f64 stdTimings[DQN_ARRAY_COUNT(dqnCPPTimings)] = {};
|
f64 stdTimings[DQN_ARRAY_COUNT(dqnCPPTimings)] = {};
|
||||||
|
|
||||||
f64 dqnCPPAverage = 0;
|
f64 dqnCPPAverage = 0;
|
||||||
@ -2871,6 +2872,8 @@ FILE_SCOPE void DqnMemStack_Test()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DqnFixedString_Test();
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
globalIndent = 1;
|
globalIndent = 1;
|
||||||
@ -2887,6 +2890,7 @@ int main(void)
|
|||||||
DqnHashTable_Test();
|
DqnHashTable_Test();
|
||||||
Dqn_BSearch_Test();
|
Dqn_BSearch_Test();
|
||||||
DqnMemSet_Test();
|
DqnMemSet_Test();
|
||||||
|
DqnFixedString_Test();
|
||||||
|
|
||||||
#ifdef DQN_XPLATFORM_LAYER
|
#ifdef DQN_XPLATFORM_LAYER
|
||||||
DqnFile_Test();
|
DqnFile_Test();
|
||||||
@ -2894,16 +2898,6 @@ int main(void)
|
|||||||
DqnJobQueue_Test();
|
DqnJobQueue_Test();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct Item
|
|
||||||
{
|
|
||||||
f32 a, b, c, d;
|
|
||||||
};
|
|
||||||
|
|
||||||
Item storage[20] = {};
|
|
||||||
DqnArray<Item> array = {};
|
|
||||||
array.UseMemory(storage, DQN_ARRAY_COUNT(storage));
|
|
||||||
|
|
||||||
|
|
||||||
// Log("\nPress 'Enter' Key to Exit\n");
|
// Log("\nPress 'Enter' Key to Exit\n");
|
||||||
// getchar();
|
// getchar();
|
||||||
|
|
@ -2,8 +2,8 @@
|
|||||||
@REM vcvarsall.bat to setup command-line compiler.
|
@REM vcvarsall.bat to setup command-line compiler.
|
||||||
|
|
||||||
@echo OFF
|
@echo OFF
|
||||||
set ProjectName=dqn_unit_test
|
set ProjectName=DqnUnitTest
|
||||||
set CompileEntryPoint=..\dqn_unit_test.cpp
|
set CompileEntryPoint=..\DqnUnitTest.cpp
|
||||||
|
|
||||||
REM Build tags file if you have ctags in path
|
REM Build tags file if you have ctags in path
|
||||||
where /q ctags
|
where /q ctags
|
||||||
|
Loading…
Reference in New Issue
Block a user