Browse Source

123

Signed-off-by: hirfgqiurgqi <diwit95894@kravify.com>
master
hirfgqiurgqi 7 months ago
parent
commit
07c2360274
  1. 35
      123.cpp

35
123.cpp

@ -0,0 +1,35 @@
#include <iostream>
#include <vector>
#include <gtest/gtest.h>
using namespace std;
vector<int> vecc(vector<int> vec, int n) {
for (int i = 0; i < vec.size(); i++) {
vec[i] += n;
}
return vec;
}
TEST(VecTest, test1) {
vector<int> input = {1, 2, 3, 4, 5};
vector<int> expected = {6, 7, 8, 9, 10};
ASSERT_EQ(vecc(input, 5), expected);
}
TEST(VecTest, test2) {
vector<int> input = {5, -3, 7, 2, 0};
vector<int> expected = {2, -6, 2, -3, -5};
ASSERT_EQ(vecc(input, -3), expected);
}
TEST(VecTest, test3) {
vector<int> input = {10000, 20000, 30000};
vector<int> expected = {20000, 30000, 40000};
ASSERT_EQ(vecc(input, 10000), expected);
}
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Loading…
Cancel
Save