VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /proc/thread-self/root/usr/local/lib/node_modules/mediasoup/worker/test/src/Utils/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/thread-self/root/usr/local/lib/node_modules/mediasoup/worker/test/src/Utils/TestJson.cpp
#include "common.hpp"
#include "Utils.hpp"
#include <json.hpp>
#include <catch.hpp>

using namespace Utils;
using json = nlohmann::json;

SCENARIO("Json::IsPositiveInteger()")
{
	json jsonValue;
	int intValue;
	int8_t int8Value;
	int32_t int32Value;
	unsigned int uintValue;
	uint8_t uint8Value;
	uint32_t uint32Value;
	float floatValue;
	json jsonArray{ json::array() };
	json jsonObject{ json::object() };

	jsonValue = 0;
	REQUIRE(Json::IsPositiveInteger(jsonValue));

	jsonValue = 1;
	REQUIRE(Json::IsPositiveInteger(jsonValue));

	jsonValue = 0u;
	REQUIRE(Json::IsPositiveInteger(jsonValue));

	jsonValue = 1u;
	REQUIRE(Json::IsPositiveInteger(jsonValue));

	jsonValue = -1;
	REQUIRE(!Json::IsPositiveInteger(jsonValue));

	intValue = 0;
	REQUIRE(Json::IsPositiveInteger(intValue));

	intValue = 1;
	REQUIRE(Json::IsPositiveInteger(intValue));

	intValue = -1;
	REQUIRE(!Json::IsPositiveInteger(intValue));

	int8Value = 0;
	REQUIRE(Json::IsPositiveInteger(int8Value));

	int8Value = 1;
	REQUIRE(Json::IsPositiveInteger(int8Value));

	int8Value = -1;
	REQUIRE(!Json::IsPositiveInteger(int8Value));

	int32Value = 0;
	REQUIRE(Json::IsPositiveInteger(int32Value));

	int32Value = 1;
	REQUIRE(Json::IsPositiveInteger(int32Value));

	int32Value = -1;
	REQUIRE(!Json::IsPositiveInteger(int32Value));

	uintValue = 0;
	REQUIRE(Json::IsPositiveInteger(uintValue));

	uintValue = 1;
	REQUIRE(Json::IsPositiveInteger(uintValue));

	uint8Value = 0;
	REQUIRE(Json::IsPositiveInteger(uint8Value));

	uint8Value = 1;
	REQUIRE(Json::IsPositiveInteger(uint8Value));

	uint32Value = 0;
	REQUIRE(Json::IsPositiveInteger(uint32Value));

	uint32Value = 1;
	REQUIRE(Json::IsPositiveInteger(uint32Value));

	floatValue = 0;
	REQUIRE(!Json::IsPositiveInteger(floatValue));

	floatValue = 0.0;
	REQUIRE(!Json::IsPositiveInteger(floatValue));

	floatValue = 1;
	REQUIRE(!Json::IsPositiveInteger(floatValue));

	floatValue = 1.1;
	REQUIRE(!Json::IsPositiveInteger(floatValue));

	floatValue = -1;
	REQUIRE(!Json::IsPositiveInteger(floatValue));

	floatValue = -1.1;
	REQUIRE(!Json::IsPositiveInteger(floatValue));

	REQUIRE(!Json::IsPositiveInteger(jsonArray));
	REQUIRE(!Json::IsPositiveInteger(jsonObject));
	REQUIRE(!Json::IsPositiveInteger(nullptr));
	REQUIRE(!Json::IsPositiveInteger(true));
	REQUIRE(!Json::IsPositiveInteger(false));
}

VaKeR 2022