Initial Course
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#include "structured_bindings.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(StructuredBindings, MinMaxPair) {
|
||||
const auto [min, max] = cpp17::minmax_pair({3, 1, 9, 2});
|
||||
EXPECT_EQ(min, 1);
|
||||
EXPECT_EQ(max, 9);
|
||||
}
|
||||
|
||||
TEST(StructuredBindings, SplitKeyValue) {
|
||||
const auto [key, value] = cpp17::split_key_value("name=Ada");
|
||||
EXPECT_EQ(key, "name");
|
||||
EXPECT_EQ(value, "Ada");
|
||||
}
|
||||
|
||||
TEST(StructuredBindings, FirstPair) {
|
||||
const std::map<std::string, int> scores{{"Ada", 100}, {"Grace", 95}};
|
||||
const auto [name, score, found] = cpp17::first_pair(scores);
|
||||
EXPECT_TRUE(found);
|
||||
EXPECT_EQ(name, "Ada");
|
||||
EXPECT_EQ(score, 100);
|
||||
}
|
||||
Reference in New Issue
Block a user