diff options
Diffstat (limited to 'src/jaegertracing/opentelemetry-cpp/api/test/trace/provider_test.cc')
-rw-r--r-- | src/jaegertracing/opentelemetry-cpp/api/test/trace/provider_test.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/jaegertracing/opentelemetry-cpp/api/test/trace/provider_test.cc b/src/jaegertracing/opentelemetry-cpp/api/test/trace/provider_test.cc new file mode 100644 index 000000000..9e5a7aad1 --- /dev/null +++ b/src/jaegertracing/opentelemetry-cpp/api/test/trace/provider_test.cc @@ -0,0 +1,36 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/trace/provider.h" +#include "opentelemetry/nostd/shared_ptr.h" + +#include <gtest/gtest.h> + +using opentelemetry::trace::Provider; +using opentelemetry::trace::Tracer; +using opentelemetry::trace::TracerProvider; + +namespace nostd = opentelemetry::nostd; + +class TestProvider : public TracerProvider +{ + nostd::shared_ptr<Tracer> GetTracer(nostd::string_view library_name, + nostd::string_view library_version, + nostd::string_view schema_url) noexcept override + { + return nostd::shared_ptr<Tracer>(nullptr); + } +}; + +TEST(Provider, GetTracerProviderDefault) +{ + auto tf = Provider::GetTracerProvider(); + EXPECT_NE(nullptr, tf); +} + +TEST(Provider, SetTracerProvider) +{ + auto tf = nostd::shared_ptr<TracerProvider>(new TestProvider()); + Provider::SetTracerProvider(tf); + ASSERT_EQ(tf, Provider::GetTracerProvider()); +} |