chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
||||
|
||||
cc_library(
|
||||
name = "example_lib",
|
||||
srcs = ["example.cc"],
|
||||
hdrs = ["example.h"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "example_test",
|
||||
size = "small",
|
||||
srcs = ["example_test.cc"],
|
||||
tags = ["team:ci"],
|
||||
deps = [
|
||||
":example_lib",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "example.h"
|
||||
|
||||
int SumMapValues(const std::unordered_map<int, int> &map) {
|
||||
int sum = 0;
|
||||
for (const auto &[_, val] : map) {
|
||||
sum += val;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef __EXAMPLE_H__
|
||||
#define __EXAMPLE_H__
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
// Function to calculate the sum of values in an unordered_map
|
||||
int SumMapValues(const std::unordered_map<int, int> &map);
|
||||
|
||||
#endif // __EXAMPLE_H__
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "example.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
TEST(SumMapTest, HandlesEmptyMap) {
|
||||
std::unordered_map<int, int> empty_map;
|
||||
EXPECT_EQ(SumMapValues(empty_map), 0);
|
||||
}
|
||||
Reference in New Issue
Block a user