MCPcopy Create free account
hub / github.com/boostorg/json / equal

Function equal

test/test.hpp:973–1056  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

971//----------------------------------------------------------
972
973inline
974bool
975equal(
976 value const& lhs,
977 value const& rhs)
978{
979 if(lhs.kind() != rhs.kind())
980 return false;
981 switch(lhs.kind())
982 {
983 case kind::object:
984 {
985 auto const& obj1 =
986 lhs.get_object();
987 auto const& obj2 =
988 rhs.get_object();
989 auto n = obj1.size();
990 if(obj2.size() != n)
991 return false;
992 auto it1 = obj1.begin();
993 auto it2 = obj2.begin();
994 while(n--)
995 {
996 if( it1->key() !=
997 it2->key())
998 return false;
999 if(! equal(
1000 it1->value(),
1001 it2->value()))
1002 return false;
1003 ++it1;
1004 ++it2;
1005 }
1006 return true;
1007 }
1008
1009 case kind::array:
1010 {
1011 auto const& arr1 =
1012 lhs.get_array();
1013 auto const& arr2 =
1014 rhs.get_array();
1015 auto n = arr1.size();
1016 if(arr2.size() != n)
1017 return false;
1018 auto it1 = arr1.begin();
1019 auto it2 = arr2.begin();
1020 while(n--)
1021 if(! equal(*it1++, *it2++))
1022 return false;
1023 return true;
1024 }
1025
1026 case kind::string:
1027 return
1028 lhs.get_string() ==
1029 rhs.get_string();
1030

Callers 7

check_array_implFunction · 0.85
check_round_tripMethod · 0.85
usingExchangeFunction · 0.85
grind_oneMethod · 0.85
testOstreamMethod · 0.85
check_round_tripMethod · 0.85

Calls 9

kindMethod · 0.80
keyMethod · 0.80
valueMethod · 0.80
get_doubleMethod · 0.80
get_int64Method · 0.80
get_uint64Method · 0.80
get_boolMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected