YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/util/flag_tags-test.cc
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
//
18
// The following only applies to changes made to this file as part of YugaByte development.
19
//
20
// Portions Copyright (c) YugaByte, Inc.
21
//
22
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
23
// in compliance with the License.  You may obtain a copy of the License at
24
//
25
// http://www.apache.org/licenses/LICENSE-2.0
26
//
27
// Unless required by applicable law or agreed to in writing, software distributed under the License
28
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
29
// or implied.  See the License for the specific language governing permissions and limitations
30
// under the License.
31
//
32
33
#include <unordered_set>
34
35
#include <gtest/gtest.h>
36
37
#include "yb/gutil/map-util.h"
38
#include "yb/util/flag_tags.h"
39
#include "yb/util/test_util.h"
40
41
DEFINE_int32(flag_with_no_tags, 0, "test flag that has no tags");
42
43
DEFINE_int32(flag_with_one_tag, 0, "test flag that has 1 tag");
44
TAG_FLAG(flag_with_one_tag, stable);
45
46
DEFINE_int32(flag_with_two_tags, 0, "test flag that has 2 tags");
47
TAG_FLAG(flag_with_two_tags, evolving);
48
TAG_FLAG(flag_with_two_tags, unsafe);
49
50
using std::string;
51
using std::unordered_set;
52
53
namespace yb {
54
55
class FlagTagsTest : public YBTest {
56
};
57
58
1
TEST_F(FlagTagsTest, TestTags) {
59
1
  unordered_set<string> tags;
60
1
  GetFlagTags("flag_with_no_tags", &tags);
61
1
  EXPECT_EQ(0, tags.size());
62
63
1
  GetFlagTags("flag_with_one_tag", &tags);
64
1
  EXPECT_EQ(1, tags.size());
65
1
  EXPECT_TRUE(ContainsKey(tags, "stable"));
66
67
1
  GetFlagTags("flag_with_two_tags", &tags);
68
1
  EXPECT_EQ(2, tags.size());
69
1
  EXPECT_TRUE(ContainsKey(tags, "evolving"));
70
1
  EXPECT_TRUE(ContainsKey(tags, "unsafe"));
71
72
1
  GetFlagTags("missing_flag", &tags);
73
1
  EXPECT_EQ(0, tags.size());
74
1
}
75
76
} // namespace yb