text stringlengths 0 2.2M |
|---|
EXPECT_TRUE(b.get(30));
|
for (size_t i = 31; i < bitset::NUM_BITS(); ++i) {
|
EXPECT_FALSE(b.get(i));
|
}
|
}
|
struct IndexCallbackMock final {
|
std::vector<size_t> called_for_indices;
|
void operator()(size_t index) {
|
called_for_indices.push_back(index);
|
}
|
void expect_was_called_for_indices(std::vector<size_t> expected_indices) {
|
EXPECT_EQ(expected_indices.size(), called_for_indices.size());
|
for (const auto i : c10::irange(expected_indices.size())) {
|
EXPECT_EQ(expected_indices[i], called_for_indices[i]);
|
}
|
}
|
};
|
TEST(BitsetTest, givenEmptyBitset_whenCallingForEachBit_thenDoesntCall) {
|
IndexCallbackMock callback;
|
bitset b;
|
b.for_each_set_bit(callback);
|
callback.expect_was_called_for_indices({});
|
}
|
TEST(
|
BitsetTest,
|
givenBitsetWithOneBitSet_whenCallingForEachBit_thenCallsForEachBit) {
|
IndexCallbackMock callback;
|
bitset b;
|
b.set(5);
|
b.for_each_set_bit(callback);
|
callback.expect_was_called_for_indices({5});
|
}
|
TEST(
|
BitsetTest,
|
givenBitsetWithMultipleBitsSet_whenCallingForEachBit_thenCallsForEachBit) {
|
IndexCallbackMock callback;
|
bitset b;
|
b.set(5);
|
b.set(2);
|
b.set(25);
|
b.set(32);
|
b.set(50);
|
b.set(0);
|
b.unset(25);
|
b.set(10);
|
b.for_each_set_bit(callback);
|
callback.expect_was_called_for_indices({0, 2, 5, 10, 32, 50});
|
}
|
///
|
//
|
// LibSourcey
|
// Copyright (c) 2005, Sourcey <https://sourcey.com>
|
//
|
// SPDX-License-Identifier: LGPL-2.1+
|
//
|
/// @addtogroup symple
|
/// @{
|
#include "scy/symple/message.h"
|
#include "assert.h"
|
#include "scy/logger.h"
|
#include "scy/util.h"
|
using std::endl;
|
namespace scy {
|
namespace smpl {
|
Message::Message()
|
: json::value(json::value::object())
|
{
|
(*this)["id"] = util::randomString(16);
|
(*this)["type"] = "message";
|
assert(is_object());
|
}
|
Message::Message(const Message& root)
|
: json::value(static_cast<const json::value&>(root))
|
{
|
if (find("id") == end())
|
(*this)["id"] = util::randomString(16);
|
if (find("type") == end())
|
(*this)["type"] = "message";
|
assert(is_object());
|
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.