onnxruntime/winml/test/common/googletest/main.cpp
Justin Chu eeef157888
Format c++ code under winml/ (#16660)
winml/ was previously excluded from lintrunner config. This change
includes the directory and adds the clang-format config file specific to
winml/ that fits existing style.

---------

Signed-off-by: Justin Chu <justinchu@microsoft.com>
2023-07-25 21:56:50 -07:00

45 lines
1.3 KiB
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include <iostream>
#include <unordered_map>
#include <gtest/gtest.h>
#include "runtimeParameters.h"
namespace RuntimeParameters {
std::unordered_map<std::string, std::string> Parameters;
}
namespace {
void usage(char** argv, int failedArgument) {
std::cerr << "Unrecognized argument: " << argv[failedArgument] << "\n"
<< "Usage:\n\t" << argv[0] << " [/p:parameterName=parameterValue ...]\n";
}
bool parseArgument(const std::string& argument) {
if (argument.rfind("/p:", 0) == 0) {
// Parse argument in the form of /p:parameterName=parameterValue
auto separatorIndex = argument.find('=');
if (separatorIndex == std::string::npos || separatorIndex == 3) {
return false;
}
auto parameterName = argument.substr(3, separatorIndex - 3);
auto parameterValue = argument.substr(separatorIndex + 1);
RuntimeParameters::Parameters[parameterName] = parameterValue;
return true;
}
return false;
}
} // namespace
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
for (int i = 1; i < argc; i++) {
if (!parseArgument(argv[i])) {
usage(argv, i);
return -1;
}
}
return RUN_ALL_TESTS();
}