Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2018 The LevelDB Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file. See the AUTHORS file for names of contributors.5#include <cstdint>6#include <cstdlib>7#include <utility>9#include "util/no_destructor.h"10#include "util/testharness.h"12namespace leveldb {14namespace {16struct DoNotDestruct {17public:18DoNotDestruct(uint32_t a, uint64_t b) : a(a), b(b) {}19~DoNotDestruct() { std::abort(); }21// Used to check constructor argument forwarding.22uint32_t a;23uint64_t b;24};26constexpr const uint32_t kGoldenA = 0xdeadbeef;27constexpr const uint64_t kGoldenB = 0xaabbccddeeffaabb;29} // namespace31class NoDestructorTest {};33TEST(NoDestructorTest, StackInstance) {34NoDestructor<DoNotDestruct> instance(kGoldenA, kGoldenB);35ASSERT_EQ(kGoldenA, instance.get()->a);36ASSERT_EQ(kGoldenB, instance.get()->b);37}39TEST(NoDestructorTest, StaticInstance) {40static NoDestructor<DoNotDestruct> instance(kGoldenA, kGoldenB);41ASSERT_EQ(kGoldenA, instance.get()->a);42ASSERT_EQ(kGoldenB, instance.get()->b);43}45} // namespace leveldb47int main(int argc, char** argv) { return leveldb::test::RunAllTests(); }
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.