-
Notifications
You must be signed in to change notification settings - Fork 533
Wide space input support #574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
#include "TestOutput.h" | ||
#include "CommandLineArguments.h" | ||
#include "TestFilter.h" | ||
#include <cwchar> | ||
|
||
class JUnitTestOutput; | ||
class TestRegistry; | ||
|
@@ -49,8 +50,12 @@ class CommandLineTestRunner | |
|
||
static int RunAllTests(int ac, const char** av); | ||
static int RunAllTests(int ac, char** av); | ||
static int RunAllTests(int ac, const wchar_t** av); | ||
static int RunAllTests( int ac, wchar_t** av ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we have the const, do we need the non-const? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For symmetry I think it would be best, although the char one might just be there for historical reasons that it was the first 'RunAllTests' function. |
||
CommandLineTestRunner(int ac, const char** av, TestOutput*, TestRegistry* registry); | ||
|
||
static char** ConvertWideArgumentsToNormal( int ac, const wchar_t** av ); | ||
|
||
virtual ~CommandLineTestRunner(); | ||
int runAllTestsMain(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,34 @@ int CommandLineTestRunner::RunAllTests(int ac, const char** av) | |
return result; | ||
} | ||
|
||
int CommandLineTestRunner::RunAllTests( int ac, wchar_t** av ) { | ||
return RunAllTests( ac, const_cast<const wchar_t**> ( av ) ); | ||
} | ||
|
||
int CommandLineTestRunner::RunAllTests( int ac, const wchar_t** av ) | ||
{ | ||
char** avc = ConvertWideArgumentsToNormal( ac, av ); | ||
|
||
int result = RunAllTests( ac, avc ); | ||
|
||
for ( int i = 0; i < ac; i++ ) { | ||
delete[] avc[i]; | ||
} | ||
delete[] avc; | ||
|
||
return result; | ||
} | ||
|
||
char** CommandLineTestRunner::ConvertWideArgumentsToNormal( int ac, const wchar_t** av ) { | ||
char** avc = new char*[ac]; | ||
for( int i = 0; i < ac; i++ ) { | ||
size_t len = wcslen( av[i] ) + 1; | ||
avc[i] = new char[len]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having the new here and the delete at another scope is asking for trouble :( |
||
wcstombs( avc[i], av[i], len ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The conversion methods of Lib C would need to be in PlatformSpecific... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting challenge considering the lack of experience and access to half the current platforms. |
||
} | ||
return avc; | ||
} | ||
|
||
int CommandLineTestRunner::runAllTestsMain() | ||
{ | ||
int testResult = 0; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Direct dependencies with Lib C aren't allowed in CppUTest. You'd need to wrap the methods in PlatformSpecific to deal with portability to "less supported" platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@basvodde I don't know offhand about wchar_t. What I do know is that, due to limited memory, we had to use the non-std-C++ lib option. I suppose that means at least the conversion functions won't be available for the cl2000.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to be a c lib though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, though we are going to have problems with wchar_t not being a type without #include...