Files
cpp-course/modules/11_cpp17/test/structured_bindings_test.cpp
T

23 lines
637 B
C++
Raw Normal View History

2026-08-11 17:40:36 +03:00
#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);
}