Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8589681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:06:54+00:00 2026-06-11T23:06:54+00:00

When I am using ASSERT_TRUE() provided in Gtest I am getting below error. return

  • 0

When I am using ASSERT_TRUE() provided in Gtest I am getting below error.
return type does not match function type with an underline in VS 2010..

abc.h

#include "gtest\gtest.h"

class abc {
pubilc:
    bool fun();
    private:
    bool fun1();
};

abc.c

bool abc::fun()
{
    ASSERT_TRUE(fun1()); // Getting error: return type does not match function type
}

bool abc::fun1()
{
    return true; // True or false depanding on operation
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:06:55+00:00Added an answer on June 11, 2026 at 11:06 pm

    There is no return statement specified in fun() but it returns a bool. Add a return false; or return true; to fun() or change its return type to void:

    void abc::fun()
    {
        ASSERT_TRUE(fun1());
    }
    

    Based on My compiler complains that a constructor (or destructor) cannot return a value. What’s going on? which states (verbatim):

    Due to a peculiarity of C++, in order to support the syntax for streaming messages to an ASSERT_*, e.g.

    ASSERT_EQ(1, Foo()) << "blah blah" << foo;
    

    we had to give up using ASSERT* and FAIL* (but not EXPECT* and ADD_FAILURE*) in constructors and destructors. The workaround is to move the content of your constructor/destructor to a private void member function, or switch to EXPECT_*() if that works. This section in the user’s guide explains it.

    the return type must be void in functions that use ASSERT_*() macros.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting the exception The type initializer for 'Moq.Mock`1' threw an exception. using Moq
I'm using this is_enum function to check if a variable is an enum or
I'm using Visual Studio 2008, and I want to implement string formatting function without
I'm using selenium RC with Java. to verify the text present i'm using below
Using nodeunit is there an assert to check for false values? Other testing frameworks
Using JUnit 4.10 here is my test. package geometry; import org.junit.Assert.*; import org.junit.Test; public
When using implicit waits, as advised here , I still sometimes want to assert
I am using XUnit framework to test my C# code. Is there any assert
I'm using asserts_redirected_to in my unit tests, and I'm receiving this warning: DEPRECATION WARNING:
I'm using Rails' asset pipeline to concatenate all my CSS/JS (although I imagine the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.