Files

20 lines
692 B
C++
Raw Permalink Normal View History

2026-08-11 17:40:36 +03:00
#include "pipeline_ranges.hpp"
#include <gtest/gtest.h>
TEST(PipelineRanges, TopValuesByCategory) {
const std::vector<cpp26::Record> records{
{"math", 10}, {"math", 50}, {"code", 30}, {"code", 5}};
const auto result = cpp26::top_values_by_category(records, 20);
ASSERT_EQ(result.size(), 2U);
EXPECT_EQ(result[0].category, "math");
EXPECT_EQ(result[0].value, 50);
}
TEST(PipelineRanges, TotalByCategory) {
const std::vector<cpp26::Record> records{{"math", 10}, {"math", 5}, {"code", 7}};
const auto totals = cpp26::total_by_category(records);
ASSERT_EQ(totals.size(), 2U);
EXPECT_EQ(totals[0].first, "code");
EXPECT_EQ(totals[0].second, 7);
}