Compilation Problems

345 views
Skip to first unread message

Eduardo Hernández Guerra

unread,
May 27, 2011, 4:42:13 AM5/27/11
to Google C++ Mocking Framework
I have been using and gtest and gmock for testing embeded SW for a
while, using Green Hills C/C++ compiler (v5). I only had to do minor
modifications to the code to make work, mostly related to OS calls.

However when I try to use the ElementsAreArray() matcher, I get the
following compilation errors:

1>gmock-1.6.0\Include\gmock/gmock-matchers.h(2533): error #276: name
1> followed by "::" must be a class or namespace name
1> typedef typename
internal::StlContainerView<RawContainer>::type::value_type
1> ^
1> detected during instantiation of
1>
"testing::internal::ElementsAreArrayMatcher<T>::operator
1> testing::Matcher<T>() const [with T=uint8_t,
1> Container=const uint8_t *]" at line 70 of
1> "APP\Test\FBFPollTask_UT.cpp"
1>
1>gmock-1.6.0\Include\gmock/gmock-matchers.h(2399): error #276: name
1> followed by "::" must be a class or namespace name
1> typedef typename StlContainer::value_type Element;
1> ^
1> detected during:
1> instantiation of class
1>
"testing::internal::ElementsAreMatcherImpl<Container>
1> [with Container=const uint8_t *]" at line
2536
1> instantiation of
1>
"testing::internal::ElementsAreArrayMatcher<T>::operator
1> testing::Matcher<T>() const [with T=uint8_t,
1> Container=const uint8_t *]" at line 70 of
1> "APP\Test\FBFPollTask_UT.cpp"
1>
1>gmock-1.6.0\Include\gmock/gmock-matchers.h(2451): error #153:
1> expression must have class type
1> const size_t actual_count = stl_container.size();
1> ^
1> detected during instantiation of "bool
1>
testing::internal::ElementsAreMatcherImpl<Container>::Match
1> AndExplain(Container,
testing::MatchResultListener *)
1> const [with Container=const uint8_t *]"
1>
1>gmock-1.6.0\Include\gmock/gmock-matchers.h(2463): error #276: name
1> followed by "::" must be a class or namespace name
1> typename StlContainer::const_iterator it =
stl_container.begin();
1> ^
1> detected during instantiation of "bool
1>
testing::internal::ElementsAreMatcherImpl<Container>::Match
1> AndExplain(Container,
testing::MatchResultListener *)
1> const [with Container=const uint8_t *]"
1>
1>gmock-1.6.0\Include\gmock/gmock-matchers.h(2463): error #153:
1> expression must have class type
1> typename StlContainer::const_iterator it =
stl_container.begin();
1> ^
1> detected during instantiation of "bool
1>
testing::internal::ElementsAreMatcherImpl<Container>::Match
1> AndExplain(Container,
testing::MatchResultListener *)
1> const [with Container=const uint8_t *]"

I've tried to work around these but nothing seems to work. Can you
help?

Dean Sturtevant

unread,
May 27, 2011, 1:35:32 PM5/27/11
to Eduardo Hernández Guerra, Google C++ Mocking Framework
If I had to guess, the matcher expects a value_type typedef in the class  internal::StlContainerView<RawContainer>::type.
- Dean

Vlad Losev

unread,
May 27, 2011, 11:49:07 PM5/27/11
to Eduardo Hernández Guerra, Google C++ Mocking Framework
Eduardo -

The ElementsAre and ElementsAreArray match containers, mainly STL-like ones. They can match a container passed in as tuple(pointer, size) as described in http://code.google.com/p/googlemock/wiki/CheatSheet#Container_Matchers, but you are apparently not passing in the size.

It's hard to give you concrete advice without seeing your code, but in general, the size must be passed into the function together with the pointer and you should use the Args selector to give ElementsAre the right set of arguments to match.

- Vlad

2011/5/27 Eduardo Hernández Guerra <eduar...@gmail.com>

Garrick Scott

unread,
Apr 6, 2012, 10:04:56 PM4/6/12
to googl...@googlegroups.com
What changes did you have to make in order to get GTest to build under Green Hills?
Reply all
Reply to author
Forward
0 new messages