Skip to content
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

Wide space input support #574

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

WilcoBT
Copy link

@WilcoBT WilcoBT commented Apr 2, 2015

Due to internationalisation, everything here has to go in wide characters. I discovered an uncommited change floating around here to run tests with wide character parameter input support that might be useful here as well.

@basvodde
Copy link
Member

basvodde commented Apr 3, 2015

Also thanks for your pull requests. Also, as started, the tests are missing. Perhaps you want to add them to the pull request? Also, the try/catch isn't going to get accepted like that. We avoid using exception handling, except in specific places (and then only when providing an alternative)

@WilcoBT
Copy link
Author

WilcoBT commented Apr 7, 2015

Hmm, adding that tests isn't exactly trivial. The moment I add a test that actually uses the "RunAllTests" public interface I get access violations in the memory leak reporting. I get the impression it is interfering with itself as it seems it runs itself for these commandlinetestrunner tests. I suspect this explains why the following test is thus missing:

TEST( CommandLineTestRunner, VerifyRunAllTests ) {
    const char* argv[] = { "dummy.exe", "-fdskjnfkds" };

    CommandLineTestRunner::RunAllTests( 2, argv );

    LONGS_EQUAL( 0, registry.countPlugins() );
}

So I guess this means I can't test the complete function but have to do with extracting the conversion from wide and adding a test for that.

@arstrube
Copy link
Contributor

arstrube commented Apr 7, 2015

Maybe make your test more like the existing ones, e.g.

const char* argv[] = { "dummy.exe", "-fdskjnfkds" };
CommandLineTestRunner commandLineTestRunner(2, argv, &output, &registry);
commandLineTestRunner.runAllTestsMain();

Also, maybe look at CommandLineArgumentsTest.

@WilcoBT
Copy link
Author

WilcoBT commented Apr 7, 2015

No, because that is already at a level that everything is normal characters. I only added a top level that transforms from wide to normal such that that level can stay the same.

@WilcoBT WilcoBT closed this Apr 7, 2015
@WilcoBT WilcoBT reopened this Apr 7, 2015
@WilcoBT
Copy link
Author

WilcoBT commented Apr 7, 2015

oeps, wrong button

@arstrube
Copy link
Contributor

arstrube commented Apr 7, 2015

I was actually wondering that in your test you declare the args as const char*?

@WilcoBT
Copy link
Author

WilcoBT commented Apr 7, 2015

I mirrored the const/not constness of the normal char RunAllTests functions where the actual code is also in the const arguments version. From that, and that the argumenets are only read, follows that the input of the conversion function is also a const.

@WilcoBT
Copy link
Author

WilcoBT commented Apr 7, 2015

Well, it looks at Travis like I still have some crossplatform compatibility work to do...

@arstrube
Copy link
Contributor

arstrube commented Apr 7, 2015

I meant char as opposed to wchar_t, sorry.

@arstrube
Copy link
Contributor

arstrube commented Apr 7, 2015

I also meant passing in the address of output and registry to the constructor, as opposed to not to.

@WilcoBT
Copy link
Author

WilcoBT commented Apr 7, 2015

The test I placed here was more about signalling a problem trying to test the top level function before any of my changes so still with the normal chars.

And that passing is only possible one level lower that I am not touching and also using from the wide top level functions.
I'm used to equalising these things at the front door.

@WilcoBT
Copy link
Author

WilcoBT commented Apr 7, 2015

Ok, I have an error on Travis CI that I don't get and my colleague's have no idea either. But we normally program for Windows (CE5/7)
Any clue how to fix this? Seems an internal issue:

/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/x86_64-linux-gnu/bits/os_defines.h:40:10: fatal error:
'features.h' file not found
#include <features.h>
^
1 error generated.

@basvodde
Copy link
Member

basvodde commented Apr 7, 2015

Hmm, the wchar_t does raises some questions on support on embedded platforms. @arstrube do you know the cl2000 support of wchart_t? I assume wchar_t is one of the first things to go?

@@ -32,6 +32,7 @@
#include "TestOutput.h"
#include "CommandLineArguments.h"
#include "TestFilter.h"
#include <cwchar>
Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that makes sense.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member

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...

@WilcoBT
Copy link
Author

WilcoBT commented Apr 7, 2015

Well as I was adding this one as a sidenote while fixing the verbose junit combinetion I can't invest to much time in this. I am getting the feeling I'd better move the conversion to our mains and be done with it.

An interesting experience though, discovering the details to keep in mind. But something I rather not work on with only a continuous integration server to verify with.

@basvodde
Copy link
Member

basvodde commented Apr 7, 2015

@WilcoBT Though, I like to have wchar_t support... I'm wondering whether we should. Would you mind explaining a bit how you ended up implementing it, so that we can understand why it was needed.

The reason for this is:

  • It will mean several PlatformSpecific methods to wrap C-lib, which would mean additional effort for porting them
  • I'm not sure if the wchar_t can be used without an #include (which caused problems with size_t)

If the reason for adding these is worth the effort, I'm definitively for it. Just want to reflect on that before continuing...

@WilcoBT
Copy link
Author

WilcoBT commented Apr 7, 2015

I didn't implement it. I found it in our local git clone. But the reason it was added it because we have test suites for multiple repositories(a shared and a few products). Practically each such suite is build in visual studio with unicode support which automagically gives the arguments in wchars.
To avoid code duplication of the conversion in the main of all these test suites, I'd rather have cppUtest be able to handle it.

@arstrube
Copy link
Contributor

arstrube commented Apr 7, 2015

@WilcoBT putting it into your own main() is an excellent idea in your case.

We have set up all our tests suites to share the same main() ;-)

There need not be any code duplication that way. We have put our CppUTestMain.cpp into a the folder above the CppUTest lib and headers, but anywhere is fine.

@WilcoBT
Copy link
Author

WilcoBT commented Apr 7, 2015

no, multiple mains :) one per repository
I have to see if I can do something with the shared though.

@arstrube
Copy link
Contributor

arstrube commented Apr 7, 2015

P.S. Just that VS likes putting a main() in when you create a new project doesn't mean it has to be there. You can safely delete all those and then add the one and only main that contains your wide character support.

@basvodde
Copy link
Member

basvodde commented Apr 8, 2015

So, what do we do with the wchar_t support? need it? Decline as we don't want the additional dependencies? We could just leave it open for now and see if other people would want it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants