map pair ok

This commit is contained in:
hugogogo
2022-06-20 15:40:35 +02:00
parent 8a404b0839
commit 8c181b6407
7 changed files with 287 additions and 67 deletions

View File

@@ -9,15 +9,12 @@ TEST_M(tests_map_simple)
// title
TITLE(simple test)
typename std::map<T, U> first;
typename std::map<T, U>::iterator it;
first[VALT('a')]=VALU(10);
first[VALT('b')]=VALU(30);
first[VALT('c')]=VALU(50);
first[VALT('d')]=VALU(70);
PRINT(first)
typename ft::map<T, U> mp;
// typename std::map<T, U>::iterator it;
//
// mp[VALT('a')] = VALU(10);
//
// PRINT(mp)
DELETE
}
@@ -543,6 +540,71 @@ TEST_M(tests_map_get_allocator)
DELETE
}
TEST_M(tests_map_relational_operators)
{
// title
TITLE(cplusplus.com reference)
std::map<int, char> alice{{1, 'a'}, {2, 'b'}, {3, 'c'}};
std::map<int, char> bob{{7, 'Z'}, {8, 'Y'}, {9, 'X'}, {10, 'W'}};
std::map<int, char> eve{{1, 'a'}, {2, 'b'}, {3, 'c'}};
std::cout << std::boolalpha;
// Compare non equal containers
std::cout << "alice == bob returns " << (alice == bob) << '\n';
std::cout << "alice != bob returns " << (alice != bob) << '\n';
std::cout << "alice < bob returns " << (alice < bob) << '\n';
std::cout << "alice <= bob returns " << (alice <= bob) << '\n';
std::cout << "alice > bob returns " << (alice > bob) << '\n';
std::cout << "alice >= bob returns " << (alice >= bob) << '\n';
std::cout << '\n';
// Compare equal containers
std::cout << "alice == eve returns " << (alice == eve) << '\n';
std::cout << "alice != eve returns " << (alice != eve) << '\n';
std::cout << "alice < eve returns " << (alice < eve) << '\n';
std::cout << "alice <= eve returns " << (alice <= eve) << '\n';
std::cout << "alice > eve returns " << (alice > eve) << '\n';
std::cout << "alice >= eve returns " << (alice >= eve) << '\n';
DELETE
}
TEST_M(tests_map_swap_non_member)
{
// title
TITLE(cplusplus.com reference)
std::map<int, char> alice{{1, 'a'}, {2, 'b'}, {3, 'c'}};
std::map<int, char> bob{{7, 'Z'}, {8, 'Y'}, {9, 'X'}, {10, 'W'}};
auto print = [](std::pair<const int, char>& n) {
std::cout << " " << n.first << '(' << n.second << ')';
};
// Print state before swap
std::cout << "alice:";
std::for_each(alice.begin(), alice.end(), print);
std::cout << "\n" "bob :";
std::for_each(bob.begin(), bob.end(), print);
std::cout << '\n';
std::cout << "-- SWAP\n";
std::swap(alice, bob);
// Print state after swap
std::cout << "alice:";
std::for_each(alice.begin(), alice.end(), print);
std::cout << "\n" "bob :";
std::for_each(bob.begin(), bob.end(), print);
std::cout << '\n';
DELETE
}
*/
#endif