mame/3rdparty/bx/tests/tokenizecmd_test.cpp
Julian Sikorski 0837e7451a WIP: sync bgfx, bx and bimg with latest upstream (#5723)
* Sync with bgfx upstream revision b91d0b6

* Sync with bx upstream revision d60912b

* Sync with bimg upstream revision bd81f60

* Add astc-codec decoder

* Rename VertexDecl to VertexLayout

* Rename UniformType enum Int1 to Sampler.

* Add NVN stub

* Fix unused-const-variable error on macOS

* Drop redundant explicit language parameters
buildoptions_cpp are only applied to c++ files and buildoptions_objcpp are only
applied to objective c++ files. As such, hardcoding -x offers no benefit while
preventing overrides (such as one needed by 3rdparty/bgfx/src/renderer_vk.cpp on
macOS) from working.

* Re-introduce -x c++ in places where C code is compiled as C++ to prevent clang from throwing a warning

* Build bgfx as Objective-C++ on macOS
It is needed due to included headers

* Enable Direct3D12 and Vulkan bgfx rendering backends

* Enable building of spirv shaders

* Properly escape /c in cmd call

* Comment out dx12 bgfx renderer

* Honor VERBOSE setting during shaders build

* Only invert hlsl shader XYZ_TO_sRGB matrix for opengl

* Add spirv shaders

* OpenGL ES needs transposed matrix too

* Metal needs transposed matrix as well
2019-10-13 07:50:38 -04:00

83 lines
1.7 KiB
C++

/*
* Copyright 2012-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bx#license-bsd-2-clause
*/
#include "test.h"
#include <bx/commandline.h>
#include <bx/string.h>
TEST_CASE("commandLine", "")
{
const char* args[] =
{
"-s",
"--long",
"--platform",
"x",
"--num", "1389",
"--foo",
"--", // it should not parse arguments after argument terminator
"--bar",
};
bx::CommandLine cmdLine(BX_COUNTOF(args), args);
REQUIRE( cmdLine.hasArg("long") );
REQUIRE( cmdLine.hasArg('s') );
int32_t num;
REQUIRE(cmdLine.hasArg(num, '\0', "num") );
REQUIRE(1389 == num);
// test argument terminator
REQUIRE( cmdLine.hasArg("foo") );
REQUIRE(!cmdLine.hasArg("bar") );
// non-existing argument
REQUIRE(!cmdLine.hasArg('x') );
REQUIRE(!cmdLine.hasArg("preprocess") );
}
static bool test(const char* _input, int32_t _argc, ...)
{
char buffer[1024];
uint32_t len = sizeof(buffer);
char* argv[32];
int32_t argc;
bx::tokenizeCommandLine(_input, buffer, len, argc, argv, BX_COUNTOF(argv) );
if (_argc != argc)
{
return false;
}
va_list argList;
va_start(argList, _argc);
for (int32_t ii = 0; ii < _argc; ++ii)
{
const char* arg = va_arg(argList, const char*);
if (0 != bx::strCmp(argv[ii], arg) )
{
return false;
}
}
va_end(argList);
return true;
}
TEST_CASE("tokenizeCommandLine", "")
{
REQUIRE(test(" ", 0, NULL) );
REQUIRE(test("\\", 0, NULL) );
REQUIRE(test("a b v g d", 5, "a", "b", "v", "g", "d") );
REQUIRE(test("\"ab\\\"v\" \"\\\\\" g", 3, "ab\"v", "\\", "g") );
REQUIRE(test("a\\\\\\\"b v g", 3, "a\\\"b", "v", "g") );
REQUIRE(test("a\\\\\\\\\"b v\" g d", 3, "a\\\\b v", "g", "d") );
}