<commit_before>/*
-------------------------------------------------------------------------------
Name:
	FPL-Demo | Test

Description:
	This demo is used to test all the things. It is basically a unit-test.

Requirements:
	- C++ Compiler
	- Final Platform Layer

Author:
	<NAME>

Changelog:
    ## 2019-05-30
    - Fixed os version was not properly printed (%d instead of %s)
    - Rearranged code a bit

	## 2018-10-22
	- Reflect api changes in FPL 0.9.3

	## 2018-09-24
	- Reflect api changes in FPL 0.9.2
	- Transition of test framework from C++ to C99

	## 2018-08-10
	- Correction for api change in fplPlatformInit

	## 2018-08-09
	- Correction for api change in fplMemoryInfo
	- Added a new more strings tests

	## 2018-06-29
	- Added condition-variable tests

	## 2018-05-15:
	- Corrected for api change in FPL v0.8.1+
	- Added semaphores sync test

	## 2018-05-10:
	- Small bugfixes

	## 2018-04-27:
	- Added wrap test for unsigned integers for AtomicExchange

	## 2018-04-23:
	- Initial creation of this description block
	- Forced Visual-Studio-Project to compile in C++ always
-------------------------------------------------------------------------------
*/

#define FPL_IMPLEMENTATION
#define FPL_NO_AUDIO
#define FPL_NO_VIDEO
#define FPL_NO_WINDOW
#define FPL_LOGGING
#include <final_platform_layer.h>

#define FT_IMPLEMENTATION
#include "final_test.h"

static void TestColdInit() {
	ftMsg("Test Cold-Initialize of InitPlatform\n");
	{
		size_t errorCount = fplGetErrorCount();
		ftAssertSizeEquals(0, errorCount);
		bool inited = fplPlatformInit(fplInitFlags_None, nullptr);
        ftAssert(inited);
        fplPlatformResultType resultType = fplGetPlatformResult();
        ftAssert(resultType == fplPlatformResultType_Success);
        const char *errorStr = fplGetLastError();
		ftAssertStringEquals("", errorStr);
		fplPlatformRelease();
	}
}

static void TestInit() {
	ftMsg("Test InitPlatform with All init flags\n");
	{
		fplClearErrors();
		bool inited = fplPlatformInit(fplInitFlags_All, nullptr);
        ftAssert(inited);
        fplPlatformResultType resultType = fplGetPlatformResult();
        ftAssert(resultType == fplPlatformResultType_Success);
		const char *errorStr = fplGetLastError();
		ftAssertStringEquals("", errorStr);
		fplPlatformRelease();
	}
	ftMsg("Test InitPlatform with None init flags\n");
	{
		fplClearErrors();
		bool inited = fplPlatformInit(fplInitFlags_None, fpl_null);
        ftAssert(inited);
        fplPlatformResultType resultType = fplGetPlatformResult();
        ftAssert(resultType == fplPlatformResultType_Success);
		const fplSettings *settings = fplGetCurrentSettings();
		ftIsNotNull(settings);
		const char *errorStr = fplGetLastError();
		ftAssertStringEquals("", errorStr);
		fplPlatformRelease();
	}
	ftMsg("Test fplGetCurrentSettings in non-initialized state\n");
	{
		ftIsFalse(fpl__global__InitState.isInitialized);
		fplClearErrors();
		const fplSettings *settings = fplGetCurrentSettings();
		ftIsNull(settings);
		size_t errorCount = fplGetErrorCount();
		ftAssertSizeEquals(1, errorCount);
		const char *errorStr = fplGetLastError();
		ftAssertStringNotEquals("", errorStr);
	}
}

static void TestOSInfos() {
	ftMsg("Get Platform Type:\n");
	{
		fplPlatformType platType = fplGetPlatformType();
		ftAssert(fplPlatformType_Unknown != platType);
        fplConsoleFormatOut("\tPlatform: %s\n", fplGetPlatformTypeString(platType));
	}
	ftMsg("Get OS Type:\n");
	{
		fplOSInfos osInfos = {};
		bool r = fplGetOperatingSystemInfos(&osInfos);
		ftIsTrue(r);
        fplConsoleFormatOut("\tName: %s\n", osInfos.osName);
        fplConsoleFormatOut("\tVersion: %s.%s.%s.%s\n", osInfos.osVersion.major, osInfos.osVersion.minor, osInfos.osVersion.fix, osInfos.osVersion.build);
        fplConsoleFormatOut("\tDistribution Name: %s\n", osInfos.distributionName);<commit_msg>- Reflect api changes in FPL 0.9.4<commit_after>/*
-------------------------------------------------------------------------------
Name:
	FPL-Demo | Test

Description:
	This demo is used to test all the things. It is basically a unit-test.

Requirements:
	- C++ Compiler
	- Final Platform Layer

Author:
	<NAME>

Changelog:
	## 2019-06-17
	- Reflect api changes in FPL 0.9.4

    ## 2019-05-30
    - Fixed os version was not properly printed (%d instead of %s)
    - Rearranged code a bit

	## 2018-10-22
	- Reflect api changes in FPL 0.9.3

	## 2018-09-24
	- Reflect api changes in FPL 0.9.2
	- Transition of test framework from C++ to C99

	## 2018-08-10
	- Correction for api change in fplPlatformInit

	## 2018-08-09
	- Correction for api change in fplMemoryInfo
	- Added a new more strings tests

	## 2018-06-29
	- Added condition-variable tests

	## 2018-05-15:
	- Corrected for api change in FPL v0.8.1+
	- Added semaphores sync test

	## 2018-05-10:
	- Small bugfixes

	## 2018-04-27:
	- Added wrap test for unsigned integers for AtomicExchange

	## 2018-04-23:
	- Initial creation of this description block
	- Forced Visual-Studio-Project to compile in C++ always
-------------------------------------------------------------------------------
*/

#define FPL_IMPLEMENTATION
#define FPL_NO_AUDIO
#define FPL_NO_VIDEO
#define FPL_NO_WINDOW
#define FPL_LOGGING
#include <final_platform_layer.h>

#define FT_IMPLEMENTATION
#include "final_test.h"

static void TestColdInit() {
	ftMsg("Test Cold-Initialize of InitPlatform\n");
	{
		size_t errorCount = fplGetErrorCount();
		ftAssertSizeEquals(0, errorCount);
		bool inited = fplPlatformInit(fplInitFlags_None, nullptr);
        ftAssert(inited);
        fplPlatformResultType resultType = fplGetPlatformResult();
        ftAssert(resultType == fplPlatformResultType_Success);
        const char *errorStr = fplGetLastError();
		ftAssertStringEquals("", errorStr);
		fplPlatformRelease();
	}
}

static void TestInit() {
	ftMsg("Test InitPlatform with All init flags\n");
	{
		fplClearErrors();
		bool inited = fplPlatformInit(fplInitFlags_All, nullptr);
        ftAssert(inited);
        fplPlatformResultType resultType = fplGetPlatformResult();
        ftAssert(resultType == fplPlatformResultType_Success);
		const char *errorStr = fplGetLastError();
		ftAssertStringEquals("", errorStr);
		fplPlatformRelease();
	}
	ftMsg("Test InitPlatform with None init flags\n");
	{
		fplClearErrors();
		bool inited = fplPlatformInit(fplInitFlags_None, fpl_null);
        ftAssert(inited);
        fplPlatformResultType resultType = fplGetPlatformResult();
        ftAssert(resultType == fplPlatformResultType_Success);
		const fplSettings *settings = fplGetCurrentSettings();
		ftIsNotNull(settings);
		const char *errorStr = fplGetLastError();
		ftAssertStringEquals("", errorStr);
		fplPlatformRelease();
	}
	ftMsg("Test fplGetCurrentSettings in non-initialized state\n");
	{
		ftIsFalse(fpl__global__InitState.isInitialized);
		fplClearErrors();
		const fplSettings *settings = fplGetCurrentSettings();
		ftIsNull(settings);
		size_t errorCount = fplGetErrorCount();
		ftAssertSizeEquals(1, errorCount);
		const char *errorStr = fplGetLastError();
		ftAssertStringNotEquals("", errorStr);
	}
}

static void TestOSInfos() {
	ftMsg("Get Platform Type:\n");
	{
		fplPlatformType platType = fplGetPlatformType();
		ftAssert(fplPlatformType_Unknown != platType);
        fplConsoleFormatOut("\tPlatform: %s\n", fplGetPlatformName(platType));
	}
	ftMsg("Get OS Type:\n");
	{
		fplOSInfos osInfos = {};
		bool r = fplGetOperatingSystemInfos(&osInfos);
		ftIsTrue(r);
        fplConsoleFormatOut("\tName: %s\n", osInfos.osName);
        fplConsoleFormatOut("\tVersion: %s.%s.%s.%s\n", osInfos.osVersion.major, osInfos.osVersion.minor, osInfos.osVersion.fix, osInfos.osVersion.build);
        fplConsoleFormatOut("\tDistribution Name: %s\n", osInfos.distributionName);
{'fraction_non_alphanumeric': 0.14703985553979104, 'fraction_numerical': 0.025796465884173867, 'mean_word_length': 3.5212827988338193, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7120362', 'n_tokens_mistral': 2730, 'n_tokens_neox': 2483, 'n_words': 588}