• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Abseil Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "absl/strings/internal/cordz_update_scope.h"
16 
17 #include "gmock/gmock.h"
18 #include "gtest/gtest.h"
19 #include "absl/base/config.h"
20 #include "absl/strings/cordz_test_helpers.h"
21 #include "absl/strings/internal/cord_rep_flat.h"
22 #include "absl/strings/internal/cordz_info.h"
23 #include "absl/strings/internal/cordz_update_tracker.h"
24 
25 namespace absl {
26 ABSL_NAMESPACE_BEGIN
27 namespace cord_internal {
28 
29 namespace {
30 
31 // Used test values
32 auto constexpr kTrackCordMethod = CordzUpdateTracker::kConstructorString;
33 
TEST(CordzUpdateScopeTest,ScopeNullptr)34 TEST(CordzUpdateScopeTest, ScopeNullptr) {
35   CordzUpdateScope scope(nullptr, kTrackCordMethod);
36 }
37 
TEST(CordzUpdateScopeTest,ScopeSampledCord)38 TEST(CordzUpdateScopeTest, ScopeSampledCord) {
39   TestCordData cord;
40   CordzInfo::TrackCord(cord.data, kTrackCordMethod);
41   CordzUpdateScope scope(cord.data.cordz_info(), kTrackCordMethod);
42   cord.data.cordz_info()->SetCordRep(nullptr);
43 }
44 
45 }  // namespace
46 ABSL_NAMESPACE_END
47 }  // namespace cord_internal
48 
49 }  // namespace absl
50