Author |
Topic |
|
kolobog007
Junior Member
Russia
12 Posts |
Posted - Jul 07 2009 : 09:23:04 AM
|
refactoring is not working with unittest library from boost
i added defines BOOST_AUTO_TEST_CASE BOOST_AUTO_TEST_SUITE to va stdafx.h. before this all variables was underlined. but refactoring still not working.
and still underlined... |
Edited by - kolobog007 on Jul 07 2009 09:56:12 AM |
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Jul 08 2009 : 12:17:37 PM
|
What do I need to know to setup a valid test for this? Using Boost 1.35.0, VS2005 and VA 1727 I have added the following test code to a cpp file:
#include <boost\\test\\unit_test_suite.hpp>
class cover_simple_polygon { };
BOOST_AUTO_TEST_CASE( cover_simple_polygon )
{
int column_width = 10;
}
but it does not compile. Since this is invalid code I am not to surprised that VA is confused by it. |
zen is the art of being at one with the two'ness |
|
|
kolobog007
Junior Member
Russia
12 Posts |
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Jul 09 2009 : 10:59:55 AM
|
That helps, thank you. My initial code did not compile at all, it was not a linker / missing library problem, it was a totally invalid code problem.
I am not sure exactly what you added to VA's StdAfx.h file from your description, but you need to add something constructive for BOOST_AUTO_TEST_CASE. Try adding the following entries to VA's StdAfx.h file:
#define BOOST_AUTO_TEST_SUITE(x) #define BOOST_AUTO_TEST_CASE( funcName ) void funcName() #define BOOST_CHECK_EQUAL(x, y) #define BOOST_AUTO_TEST_SUITE_END()
on a basic test this is working well for me in VS2005 and VA 1727.
|
zen is the art of being at one with the two'ness |
|
|
kolobog007
Junior Member
Russia
12 Posts |
Posted - Jul 09 2009 : 3:49:10 PM
|
now works fine with this changes, except this - add class/function after
#include <boost/test/unit_test.hpp> and before
BOOST_AUTO_TEST_SUITE(simple_test)
[ADDED] magic... now it works normally. once again thnx for solution =)
[and once again added] i think i understood how this bug works - when i save project, close VS, open project - all ok. but if i will change any symbol(even just add space in blank line) - VS intellisense and VA lose variables defines. |
Edited by - kolobog007 on Jul 09 2009 6:06:01 PM |
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Jul 09 2009 : 7:29:43 PM
|
VA does not underline symbols as mistyped symbols when you first open the file after loading the IDE. This is by design, it is an optimisation to speed things up and to avoid underlining code that you are just browsing but not working on.
Once you make an edit in the file, even a tiny one, then the underlining is activated.
Do the helper macro's in VA StdAfx.h file help at all? |
zen is the art of being at one with the two'ness |
|
|
kolobog007
Junior Member
Russia
12 Posts |
Posted - Jul 10 2009 : 3:47:44 PM
|
in others projects all ok. but in one project - not working... thnx for help. |
Edited by - kolobog007 on Jul 10 2009 3:47:59 PM |
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Jul 11 2009 : 4:23:50 PM
|
Is there any obvious difference between the code in these two projects? For example are you using different unit testing macro's in the problem project?
This work around should work in all projects or no projects, not just some of them. |
zen is the art of being at one with the two'ness |
|
|
kolobog007
Junior Member
Russia
12 Posts |
Posted - Jul 16 2009 : 1:39:00 PM
|
no differences in code. magic... may be reason in vs intellisens? not in va. |
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Jul 16 2009 : 3:00:26 PM
|
The IDE intellisense should not matter here, since we don't use it for refactoring.
In the solution where this fails, if you copy a problem piece of code and paste it into one of the other solutions, does the code still fail, or does it start to work?
It is possible the problem is the solution settings, its C++ additional include directories maybe. |
zen is the art of being at one with the two'ness |
|
|
kolobog007
Junior Member
Russia
12 Posts |
Posted - Jul 16 2009 : 5:51:23 PM
|
i think i found reason. refactoring doesn't working with variables, that defined after BOOST_CHECK. Try this code
#include <boost/test/unit_test.hpp>
using namespace std;
#include <iostream>
#include <windows>
class bar{
public:
bar();
~bar();
};
void foo()
{
std::cout << "dummy function";
}
BOOST_AUTO_TEST_SUITE(simple_test_suite)
BOOST_AUTO_TEST_CASE( simple_test )
{
RECT rc1;
rc1.bottom = 5;
BOOST_CHECK(rc1.bottom == 5);
RECT rc2;
rc2.bottom = 3;
BOOST_CHECK(rc2.bottom != 7);
rc1.bottom = 3;
}
BOOST_AUTO_TEST_SUITE_END()
rc2 underlined and i cant get listbox with member variables or refactor it. but with rc1 no problems even after second BOOST_CHECK. |
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Jul 17 2009 : 1:12:35 PM
|
I am seeing the same problem here, thank you for the clear example I have fixed this by adding:
#define BOOST_CHECK(x)
to VA's StdAfx.h file and doing a symbol database rebuild. So in total I have now added:
#define BOOST_AUTO_TEST_SUITE(x) #define BOOST_AUTO_TEST_CASE( funcName ) void funcName() #define BOOST_CHECK_EQUAL(x, y) #define BOOST_CHECK(x) #define BOOST_AUTO_TEST_SUITE_END()
to VA's StdAfx.h file. You may need to add more entries if you encounter more Boost unit test macro's that confuse VA. |
zen is the art of being at one with the two'ness |
|
|
kolobog007
Junior Member
Russia
12 Posts |
Posted - Jul 17 2009 : 4:35:05 PM
|
i added this line yesterday, rebuild symbol database and nothing changed. But after your words i tryed to restart VS n times and rebuild symbol database n times too. And VA started to work normally =) Thnx a lot for solution =) |
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Jul 18 2009 : 10:23:44 AM
|
Do you often run more than once instance of the IDE? If so make sure you close all instances of the IDE before doing the symbol database rebuild.
You should only have to do one rebuild and IDE restart, so I am not sure why you are having to do this several times. One rebuild and restart is enough for me. |
zen is the art of being at one with the two'ness |
|
|
|
Topic |
|