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
 BUG: Autocompletion doesn't work with googletest
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dewtell
Junior Member

18 Posts

Posted - Feb 22 2012 :  12:39:06 PM  Show Profile  Reply with Quote
This is from a C++ project using Visual Studio 2008, Visual Assist X version 10.6.1862.0, and Google Test 1.6 (http://code.google.com/p/googletest/wiki/V1_6_Documentation) for our unit test infrastructure.

The problem that I have noted is that the Visual Assist autocompletion doesn't work correctly when writing code within a test harness - it doesn't correctly identify member variables and methods of objects I'm creating there, and in fact, often overrides a correct member reference with a name that doesn't belong to the class in question at all. The same classes instantiated outside the test harness work fine, so I assume there is probably something in the Google Test macros that throws off the autocompletion.

For example, here is a recent class I'm developing, that barely has any functionality yet:
********* NetCollectionDict.h
#ifndef NETCOLLECTIONDICT_H
#define NETCOLLECTIONDICT_H
#include <map>
#include <string>

class drNet;
class drNetTap;
class drConcatenateOp;
// Object that defines a dictionary (actually 3 dicts) that index net collections: nets, concats, and taps.
class NetCollectionDict {
public:
typedef std::map<std::string,drNet*> NET_DICT;
typedef std::map<std::string,drNetTap*> TAP_DICT;
typedef std::map<std::string,drConcatenateOp*> CONCAT_DICT;
NetCollectionDict() : net_dict_(), tap_dict_(), concat_dict_() {}

// These three give direct access to instance variables. Delete/make private after
// key functionality is implemented in this class
NET_DICT &getNetDict() {return net_dict_;}
TAP_DICT &getTapDict() {return tap_dict_;}
CONCAT_DICT &getConcatDict() {return concat_dict_;}

size_t getNumNets() const {return net_dict_.size();}
size_t getNumTaps() const {return tap_dict_.size();}
size_t getNumConcats() const {return concat_dict_.size();}

private:
NET_DICT net_dict_;
TAP_DICT tap_dict_;
CONCAT_DICT concat_dict_;

};

#endif

***********************
And here is the corresponding test harness, most of which is boilerplate straight out of the Google Test sample code:

************ TestNetCollectionDict.cpp:

#include "foobar/NetCollectionDict.h"
#include "gtest/gtest.h"

namespace {

// The fixture for testing class NetCollectionDict.
class NetCollectionDictTest : public ::testing::Test {
protected:
// You can remove any or all of the following functions if its body
// is empty.

NetCollectionDictTest() {
// You can do set-up work for each test here.
}

virtual ~NetCollectionDictTest() {
// You can do clean-up work that doesn't throw exceptions here.
}

// If the constructor and destructor are not enough for setting up
// and cleaning up each test, you can define the following methods:

virtual void SetUp() {
// Code here will be called immediately after the constructor (right
// before each test).
}

virtual void TearDown() {
// Code here will be called immediately after each test (right
// before the destructor).
}

// Objects declared here can be used by all tests in the test case for NetCollectionDict.
};

TEST_F(NetCollectionDictTest, TestConstructor) {
NetCollectionDict dict;
EXPECT_EQ(0, dict.getNumNets());
EXPECT_EQ(0, dict.getNumTaps());
EXPECT_EQ(0, dict.getNumConcats());
}

// Tests that NetCollectionDict does Xyz.
//TEST_F(NetCollectionDictTest, DoesXyz) {
// Exercises the Xyz feature of NetCollectionDict.
//}

} // namespace

int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

******************
The issue is with the autocompletion of the members of dict up in TestConstructor (which is just a trivial test of the NetCollectionDict constructor, verifying that it creates the object with three empty dictionaries). When typing dict.getNumNets, it does not offer getNumNets() as a suggestion - instead, by the time I complete typing getNumNets, the suggestions are GetNumberOfConsoleInputEvents() and GetNumberOfConsoleMouseButtons(), neither of which is a member of NetCollectionDict. If I continue to type the open parenthesis following getNumNets without breaking away, it physically replaces what I've typed with one of the two suggestions. I need to click elsewhere and then click back before typing the () in order to avoid the bad substitution (this doesn't apply to the other two methods, but it still doesn't have the correct suggestions in the suggestion list for them).

Needless to say, this is rather annoying. Do you have any insight into what's going on here?

Dave Wallace

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Feb 22 2012 :  6:07:08 PM  Show Profile  Reply with Quote
Can you please try turning on the handling of recursive macro calling?

http://docs.wholetomato.com?W363

Try using NoDepthLimit for LimitMacro since it is the newer, better and faster version of recursive macro calling.
Let me know if it doesn't help so I dig deeper.
Go to Top of Page

dewtell
Junior Member

18 Posts

Posted - Feb 22 2012 :  7:20:14 PM  Show Profile  Reply with Quote
That seemed to do it. I needed to rebuild the symbol databases before it worked, but since then, it seems to be working nicely. Could you make this a configuration option (and probably on by default) in a future build, so that users don't have to hand-edit their registries to get this to work?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18754 Posts

Posted - Feb 22 2012 :  10:03:36 PM  Show Profile  Reply with Quote
Thank you for the update, it is good news that this has helped.

We don't want to turn this option on by default since it has been known to cause problems, plus deeper macro parsing is slower, and we don't want to introduce the performance penalty. As for our options dialog, we are trying to keep it from getting overwhelmed with options. There are already quite a few in there.

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