Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 1727: problem with refactoring and boost unittest
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kolobog007
Junior Member

Russia
12 Posts

Posted - Jul 07 2009 :  09:23:04 AM  Show Profile  Reply with Quote
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  Show Profile  Reply with Quote
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
Go to Top of Page

kolobog007
Junior Member

Russia
12 Posts

Posted - Jul 09 2009 :  04:34:06 AM  Show Profile  Reply with Quote
visual studio 2003. boost 1.3x(not important). you must compile unittest libs before using. or use installer - http://www.boostpro.com/download

sample code. new project with "main.cpp". only this code inside

#define BOOST_TEST_MODULE test
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(simple_suit) 
BOOST_AUTO_TEST_CASE( simple_test )
{
	int n = 5;
	BOOST_CHECK_EQUAL(n, 5);

}


BOOST_AUTO_TEST_SUITE_END()


or http://www.boost.org/doc/libs/1_39_0/libs/test/doc/html/tutorials/hello-the-testing-world.html for example
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Jul 09 2009 :  10:59:55 AM  Show Profile  Reply with Quote
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
Go to Top of Page

kolobog007
Junior Member

Russia
12 Posts

Posted - Jul 09 2009 :  3:49:10 PM  Show Profile  Reply with Quote
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
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Jul 09 2009 :  7:29:43 PM  Show Profile  Reply with Quote
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
Go to Top of Page

kolobog007
Junior Member

Russia
12 Posts

Posted - Jul 10 2009 :  3:47:44 PM  Show Profile  Reply with Quote
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
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Jul 11 2009 :  4:23:50 PM  Show Profile  Reply with Quote
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
Go to Top of Page

kolobog007
Junior Member

Russia
12 Posts

Posted - Jul 16 2009 :  1:39:00 PM  Show Profile  Reply with Quote
no differences in code. magic...
may be reason in vs intellisens? not in va.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Jul 16 2009 :  3:00:26 PM  Show Profile  Reply with Quote
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
Go to Top of Page

kolobog007
Junior Member

Russia
12 Posts

Posted - Jul 16 2009 :  5:51:23 PM  Show Profile  Reply with Quote
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.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Jul 17 2009 :  1:12:35 PM  Show Profile  Reply with Quote
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
Go to Top of Page

kolobog007
Junior Member

Russia
12 Posts

Posted - Jul 17 2009 :  4:35:05 PM  Show Profile  Reply with Quote
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 =)
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19021 Posts

Posted - Jul 18 2009 :  10:23:44 AM  Show Profile  Reply with Quote
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000