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

  • Home
  • SEARCH
  • 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 8503205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:41:42+00:00 2026-06-11T01:41:42+00:00

I tried to use google test framework and can’t see why the following code:

  • 0

I tried to use google test framework and can’t see why the following code:

TEST(MathTest, BelowZeroCandF)
{
    EXPECT_DOUBLE_EQ(convertCtoF(-1), 30.2);
}

where

double convertCtoF(double c)
{
    return 32+1.8*c;
}

fails:

Failure
Value of: -30.20
  Actual: -30.199999999999999
Expected: tc.convertCtoF(-1)
Which is: 30.199999999999999
[  FAILED  ] MathTest.belowZeroCaboveZeroF (1 ms)

I know I could use EXPECT_NEAR, but don’t see why the above does not work…

  • 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-11T01:41:43+00:00Added an answer on June 11, 2026 at 1:41 am

    (Adding the answer to complete the post, as OP confirmed the error in the comment.)

    As shown in the error report, OP accidentally added a minus sign to the result, which is surely wrong. Removing the typo solved the problem.

    Also, in GTest and many other unit testing frameworks (JUnit, etc.), the parameter order of the assertion is

    EXPECT_DOUBLE_EQ(30.2, convertCtoF(-1));
    //               ^     ^ actual value
    //               expected value
    

    otherwise the error report will have the input description flipped, just like what OP demonstrated.

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

Sidebar

Related Questions

Tried following the instructions here: How to use Google app engine with my own
Is it possible to use some mocking framework with Objectify? I've tried the following,
I tried the following code in R on windows: library(RCurl) postForm(https://www.google.com/accounts/ClientLogin/, email = me@gmail.com,
I tried to use the following function in order to set the div's position
I tried to use AsyncProcessor in test scenario, expecting only one message to run
I tried to use dat.GUI in the following three.js example . I just did
I am trying to use the jQuery CSV plugin, as documented here: http://code.google.com/p/js-tables/wiki/CSV According
I am currently trying to build some test code that uses Google C++ Test
If i use Response.Cookies[test].Value =Hi; where are cookie stored in system? Can i check
I want to use GCM. I tried with following in the client side: Manifest:

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.