I an new to using CATCH, and I wondering how one would go about testing whether two std::vectors
are equal.
My very naive attempt is this:
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include <vector>
TEST_CASE( "are vectors equal", "vectors")
{
std::vector<int> vec_1 = {1,2,3};
std::vector<int> vec_2 = {1,2,3};
REQUIRE (vec_1.size() == vec_2.size());
for (int i = 0; i < vec_1.size(); ++i)
REQUIRE (vec_1[i] == vec_2[i]);
}
Is there a better way to do this? Some thing like magic REQUIRE_VECTOR_EQUAL
?
Also, my above solution, is passing if one array contained doubles {1.0, 2.0, 3.0}
; It's fine if two vectors are not considered equal because of this.