2012-08-02 4 views
0

HippoMocks (Cygwin, GCC 4.5.3, CppUnit)를 사용하여 인터페이스를 조롱하려고 시도하는 중 하나가 컴파일을 실패하게 만듭니다. 추가 분류는 std :: vector를 인자로 사용하여 조롱하는 메소드 만 실패한다는 것을 보여줍니다.HippoMocks - std :: vector를 사용하여 조롱하는 방법이 컴파일에 실패합니다.

m_Mocks.ExpectCall(m_EmpSvcMock.get(), IEmployeeServiceProxy::GetEmployees); // compile error! 
m_Mocks.ExpectCall(m_EmpSvcMock.get(), IEmployeeServiceProxy::AddEmployee); // compile OK! 

class IEmployeeServiceProxy 
{ 
public: 
    virtual ~IEmployeeServiceProxy() { } 
    virtual void AddEmployee(const Employee&) = 0; 
    virtual void GetEmployees(std::vector<Employee>&) = 0; 
}; 

struct Employee 
{ 
    boost::uuids::uuid Id; 
    std::string Name; 
}; 

컴파일러 오류 :

/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stream_iterator.h: In member function ‘std::ostream_iterator<_Tp, _CharT, _Traits>& std::ostream_iterator<_Tp, _CharT, _Traits>::operator=(const _Tp&) [with _Tp = EmployeeServiceLib::Employee, _CharT = char, _Traits = std::char_traits<char>, std::ostream_iterator<_Tp, _CharT, _Traits> = std::ostream_iterator<EmployeeServiceLib::Employee, char, std::char_traits<char> >]’: 
In file included from /usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/iterator:67:0, 
       from /usr/include/boost/uuid/string_generator.hpp:14, 
       from /usr/include/boost/uuid/uuid_generators.hpp:15, 
       from tests/../../RcfTestShared/IEmployeeService.hpp:7, 
       from tests/../IEmployeeServiceProxy.h:11, 
       from tests/ClientTest.h:13, 
       from tests/ClientTest.cpp:8: 
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_algobase.h:349:8: instantiated from ‘static _OI std::__copy_move<false, false, std::random_access_iterator_tag>::__copy_m(_II, _II, _OI) [with _II = const EmployeeServiceLib::Employee*, _OI = std::ostream_iterator<EmployeeServiceLib::Employee, char, std::char_traits<char> >]’ 
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_algobase.h:404:70: instantiated from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false, _II = const EmployeeServiceLib::Employee*, _OI = std::ostream_iterator<EmployeeServiceLib::Employee, char, std::char_traits<char> >]’ 
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_algobase.h:442:39: instantiated from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false, _II = __gnu_cxx::__normal_iterator<const EmployeeServiceLib::Employee*, std::vector<EmployeeServiceLib::Employee> >, _OI = std::ostream_iterator<EmployeeServiceLib::Employee, char, std::char_traits<char> >]’ 
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stl_algobase.h:474:18: instantiated from ‘_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator<const EmployeeServiceLib::Employee*, std::vector<EmployeeServiceLib::Employee> >, _OI = std::ostream_iterator<EmployeeServiceLib::Employee, char, std::char_traits<char> >]’ 
../../RCF/RCF-1.3.1/include/RCF/Tools.hpp:116:9: instantiated from ‘std::ostream& std::operator<<(std::ostream&, const std::vector<_RealType>&) [with T = EmployeeServiceLib::Employee, std::ostream = std::basic_ostream<char>]’ 
../../hippomocks/HippoMocks/hippomocks.h:94:5: instantiated from ‘static void printArg<T>::print(std::ostream&, T, bool) [with T = std::vector<EmployeeServiceLib::Employee>&, std::ostream = std::basic_ostream<char>]’ 
../../hippomocks/HippoMocks/hippomocks.h:170:5: instantiated from ‘void ref_tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>::printTo(std::ostream&) const [with A = std::vector<EmployeeServiceLib::Employee>&, B = NullType, C = NullType, D = NullType, E = NullType, F = NullType, G = NullType, H = NullType, I = NullType, J = NullType, K = NullType, L = NullType, M = NullType, N = NullType, O = NullType, P = NullType, std::ostream = std::basic_ostream<char>]’ 
tests/ClientTest.cpp:47:1: instantiated from here 
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/bits/stream_iterator.h:196:2: error: cannot bind ‘std::ostream_iterator<EmployeeServiceLib::Employee, char, std::char_traits<char> >::ostream_type’ lvalue to ‘std::basic_ostream<char>&&’ 
/usr/lib/gcc/i686-pc-cygwin/4.5.3/include/c++/ostream:579:5: error: initializing argument 1 of ‘std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char, _Traits = std::char_traits<char>, _Tp = EmployeeServiceLib::Employee]’ 
+0

이제는 오류 메시지를 삭제했지만 간단한 시간에 나는 문제가 직원 개체를 연산자 ==와 비교하려고 시도한다는 것을 알았습니다. Employee 클래스에 연산자 ==가 정의되어 있습니까? operator == for std :: vector 은 operator ==가 T에 대해 정의 된만큼 작동합니다. – jahhaj

+0

@ jahhaj : HippoMocks를 svn에서 최신 버전으로 업데이트했습니다. 이제 다른 오류가 발생합니다 ... –

+0

그리고 다른 오류는 무엇입니까? 또한 내 질문에 대답하지 않았다, 연산자 == 직원 정의? 필자는 그것이 Employee 클래스의 단위 테스트에서 매우 중요하다고 생각합니다. – jahhaj

답변

1

이 아마도 당신이 직원에 대해 정의 된 연산자 < <이없는 것을 불평,하지만 확실하지 않다. 오류 메시지의 마지막 줄을 놓친 것 같아요? 어쨌든 나는 문서를 읽고 테스트 할 클래스에 대한 요구 사항을 확인합니다.

연산자 == 및 연산자 < < 등을 정의해야하며 다른 것들은 단위 테스트 프레임 워크의 표준입니다. 당신이 그것에 대해 생각한다면 단위 테스트 프레임 워크는 당신이 테스트하고있는 유형의 객체들을 비교할 필요가 있으며, 일이 잘못되었을 때 그 객체들을 출력하려고 시도 할 것입니다.

+0

클래스에 연산자 <<가 정의되어 있지 않으면 자동으로 다른 것을 사용하는 수정 프로그램이 있습니다. "???"이 인쇄됩니다. 대신. 가능한 해결책이 없다면 더 이상 기본 비교가 없습니다. – dascandy

+0

@dascandy : 따라야 할 몇 가지 질문이 있습니다. SO에 대해 질문하는 대신 직접 어떻게 연락해야합니까? –

+0

언제든지 내 이메일 주소 [email protected]을 사용할 수 있습니다. 나는 위키가 부패한 것을 발견했다.먼저 해결할 것입니다. 대부분의 답변이 있어야하지만 지금은 데이터베이스 오류 만 있습니다. – dascandy

관련 문제