|
| 1 | +// Copyright 2018, OpenCensus 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 | +// http://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 "opencensus/stats/testing/test_utils.h" |
| 16 | + |
| 17 | +#include <memory> |
| 18 | + |
| 19 | +#include "absl/memory/memory.h" |
| 20 | +#include "absl/time/time.h" |
| 21 | + |
| 22 | +namespace opencensus { |
| 23 | +namespace stats { |
| 24 | +namespace testing { |
| 25 | + |
| 26 | +// static |
| 27 | +ViewData TestUtils::MakeViewData( |
| 28 | + const ViewDescriptor& descriptor, |
| 29 | + std::initializer_list<std::pair<std::vector<std::string>, double>> values) { |
| 30 | + auto impl = absl::make_unique<ViewDataImpl>(absl::UnixEpoch(), descriptor); |
| 31 | + for (const auto& value : values) { |
| 32 | + impl->Add(value.second, value.first, absl::UnixEpoch()); |
| 33 | + } |
| 34 | + return ViewData(std::move(impl)); |
| 35 | +} |
| 36 | + |
| 37 | +} // namespace testing |
| 38 | +} // namespace stats |
| 39 | +} // namespace opencensus |
0 commit comments