text stringlengths 0 2.2M |
|---|
// This component is not up to date with current BDE coding standards, and
|
// should not be used as an example for new development.
|
// ----------------------------------------------------------------------------
|
#include <balm_metricid.h>
|
#include <bsls_ident.h>
|
BSLS_IDENT_RCSID(balm_metricid_cpp,"$Id$ $CSID$")
|
#include <bsl_ostream.h>
|
namespace BloombergLP {
|
namespace balm {
|
// --------------
|
// class MetricId
|
// --------------
|
// ACCESSORS
|
bsl::ostream& MetricId::print(bsl::ostream& stream) const
|
{
|
if (0 == d_description_p) {
|
stream << "INVALID_ID";
|
}
|
else {
|
stream << *d_description_p;
|
}
|
return stream;
|
}
|
} // close package namespace
|
} // close enterprise namespace
|
// ----------------------------------------------------------------------------
|
// Copyright 2015 Bloomberg Finance L.P.
|
//
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
// you may not use this file except in compliance with the License.
|
// You may obtain a copy of the License at
|
//
|
// http://www.apache.org/licenses/LICENSE-2.0
|
//
|
// Unless required by applicable law or agreed to in writing, software
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// See the License for the specific language governing permissions and
|
// limitations under the License.
|
// ----------------------------- END-OF-FILE ----------------------------------
|
/*
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
*
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
* you may not use this file except in compliance with the License.
|
* You may obtain a copy of the License at
|
*
|
* http://www.apache.org/licenses/LICENSE-2.0
|
*
|
* Unless required by applicable law or agreed to in writing, software
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* See the License for the specific language governing permissions and
|
* limitations under the License.
|
*/
|
#include <folly/lang/Ordering.h>
|
#include <folly/portability/GTest.h>
|
using namespace folly;
|
template <typename T>
|
struct OddCompare {
|
constexpr ordering operator()(T const& a, T const& b) const {
|
return b < a ? ordering::lt : a < b ? ordering::gt : ordering::eq;
|
}
|
};
|
class OrderingTest : public testing::Test {};
|
TEST_F(OrderingTest, ordering) {
|
EXPECT_EQ(-1, int(ordering::lt));
|
EXPECT_EQ(0, int(ordering::eq));
|
EXPECT_EQ(+1, int(ordering::gt));
|
}
|
TEST_F(OrderingTest, to_ordering) {
|
EXPECT_EQ(ordering::lt, to_ordering(int(ordering::lt)));
|
EXPECT_EQ(ordering::eq, to_ordering(int(ordering::eq)));
|
EXPECT_EQ(ordering::gt, to_ordering(int(ordering::gt)));
|
EXPECT_EQ(ordering::lt, to_ordering(-22));
|
EXPECT_EQ(ordering::eq, to_ordering(0));
|
EXPECT_EQ(ordering::gt, to_ordering(+44));
|
}
|
TEST_F(OrderingTest, compare_equal_to) {
|
compare_equal_to<OddCompare<int>> op;
|
EXPECT_FALSE(op(3, 4));
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.