2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-15 17:17:08 +00:00
qpdf/libtests/main_from_wmain.cc
Jay Berkenbilt cb769c62e5 WHITESPACE ONLY -- expand tabs in source code
This comment expands all tabs using an 8-character tab-width. You
should ignore this commit when using git blame or use git blame -w.

In the early days, I used to use tabs where possible for indentation,
since emacs did this automatically. In recent years, I have switched
to only using spaces, which means qpdf source code has been a mixture
of spaces and tabs. I have avoided cleaning this up because of not
wanting gratuitous whitespaces change to cloud the output of git
blame, but I changed my mind after discussing with users who view qpdf
source code in editors/IDEs that have other tab widths by default and
in light of the fact that I am planning to start applying automatic
code formatting soon.
2022-02-08 11:51:15 -05:00

56 lines
1.4 KiB
C++

#include <qpdf/QUtil.hh>
#include <iostream>
#ifndef QPDF_NO_WCHAR_T
void wmain_test()
{
// writable args and function args
auto realmain = [](int argc, char* argv[]) {
for (int i = 0; i < argc; ++i) {
std::cout << argv[i] << std::endl;
} return 0;
};
wchar_t* argv[3];
// This works because call_main_from_wmain doesn't actually write
// to the arguments and neither does our function. Otherwise, this
// cast would be unsafe.
argv[0] = const_cast<wchar_t*>(L"ascii");
argv[1] = const_cast<wchar_t*>(L"10 \xf7 2 = 5");
argv[2] = const_cast<wchar_t*>(L"qwww\xf7\x03c0");
QUtil::call_main_from_wmain(3, argv, realmain);
}
void cwmain_test()
{
// const args and function args
auto realmain = [](int argc, char const* const argv[]) {
for (int i = 0; i < argc; ++i) {
std::cout << "const " << argv[i] << std::endl;
} return 0;
};
wchar_t const* argv[3] = {
L"ascii",
L"10 \xf7 2 = 5",
L"qwww\xf7\x03c0",
};
QUtil::call_main_from_wmain(3, argv, realmain);
}
#endif // QPDF_NO_WCHAR_T
int main(int argc, char* argv[])
{
#ifndef QPDF_NO_WCHAR_T
try
{
wmain_test();
cwmain_test();
}
catch (std::exception& e)
{
std::cout << "unexpected exception: " << e.what() << std::endl;
}
#endif // QPDF_NO_WCHAR_T
return 0;
}