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 785823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:56:25+00:00 2026-05-14T20:56:25+00:00

I am looking to compare two arrays in google test. In UnitTest++ this is

  • 0

I am looking to compare two arrays in google test. In UnitTest++ this is done through CHECK_ARRAY_EQUAL. How do you do it in google test?

  • 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-05-14T20:56:25+00:00Added an answer on May 14, 2026 at 8:56 pm

    I would really suggest looking at Google C++ Mocking Framework. Even if you don’t want to mock anything, it allows you to write rather complicated assertions with ease.

    For example

    //checks that vector v is {5, 10, 15}
    ASSERT_THAT(v, ElementsAre(5, 10, 15));
    
    //checks that map m only have elements 1 => 10, 2 => 20
    ASSERT_THAT(m, ElementsAre(Pair(1, 10), Pair(2, 20)));
    
    //checks that in vector v all the elements are greater than 10 and less than 20
    ASSERT_THAT(v, Each(AllOf(Gt(10), Lt(20))));
    
    //checks that vector v consist of 
    //   5, number greater than 10, anything.
    ASSERT_THAT(v, ElementsAre(5, Gt(10), _));
    

    There’s plenty of matchers for every possible situations, and you can combine them to achieve almost anything.

    Did I tell you that ElementsAre needs only iterators and size() method on a class to work? So it not only works with any container from STL but with custom containers also.

    Google Mock claims to be almost as portable as Google Test and frankly I don’t see why you wouldn’t use it. It is just purely awesome.

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

Sidebar

Related Questions

I am looking for a gem that can compare two strings (in this case
I'm looking for a concise way to compare two arrays for any match. I
I am trying to compare two different arrays. I am looking for the values
I have two NSArrays, what I'm looking to do is to compare two arrays
A peculiar request this one. I am looking to compare two times in C#.
I'm looking to compare two documents to determine what percentage of their text matches
I'm looking to compare two varchars in SQL, one would be something like Cafe
I'm looking to compare two big sets of csv files and/or a csv file
I'm looking to compare two sets and display the missing elements in second set
I'm looking to run a Linux command that will recursively compare two directories and

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.