ATLAS Offline Software
Loading...
Searching...
No Matches
CombinationsGeneratorTest.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "gtest/gtest.h"
7#include <vector>
8
9using vec = std::vector<size_t>;
10
11TEST(CombinationsGeneratorTester, n3k1) {
12 CombinationsGenerator gen(3,1);
13 // return value from bump() says whether the generator has cycled.
14 EXPECT_EQ (vec{0}, gen.get());
15 EXPECT_EQ (false, gen.bump());
16 EXPECT_EQ (vec{1}, gen.get());
17 EXPECT_EQ (false, gen.bump());
18 EXPECT_EQ (vec{2}, gen.get());
19 EXPECT_EQ (true, gen.bump());
20}
21
22TEST(CombinationsGeneratorTester, n3k2) {
23 CombinationsGenerator gen(3,2);
24 vec v0 {0,1};
25 vec v1 {0,2};
26 vec v2 {1,2};
27 EXPECT_EQ (v0, gen.get());
28 EXPECT_EQ (false, gen.bump());
29 EXPECT_EQ (v1, gen.get());
30 EXPECT_EQ (false, gen.bump());
31 EXPECT_EQ (v2, gen.get());
32 EXPECT_EQ (true, gen.bump());
33}
34
35TEST(CombinationsGeneratorTester, n3k3) {
36 CombinationsGenerator gen(3,3);
37 vec v0 {0,1,2};
38 EXPECT_EQ (v0, gen.get());
39 EXPECT_EQ (true, gen.bump());
40}
41
42TEST(CombinationsGeneratorTester, n3k0) {
43 CombinationsGenerator gen(3,0);
44 vec v0 {};
45 EXPECT_EQ (v0, gen.get());
46 EXPECT_EQ (true, gen.bump());
47}
48
49TEST(CombinationsGeneratorTester, n3k4) {
50 CombinationsGenerator gen(3,4);
51 vec v0 {};
52 EXPECT_EQ (v0, gen.get());
53 EXPECT_EQ (true, gen.bump());
54}
55
56
57
TEST(CombinationsGeneratorTester, n3k1)
std::vector< size_t > vec
generate all possible combinations of objects