<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: VladimirM</title>
    <description>The latest articles on DEV Community by VladimirM (@vladimirm).</description>
    <link>https://dev.to/vladimirm</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1182813%2F1c5746d8-3b58-4576-be5d-1302eb5e609b.png</url>
      <title>DEV Community: VladimirM</title>
      <link>https://dev.to/vladimirm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vladimirm"/>
    <language>en</language>
    <item>
      <title>Testing Private Logic in C++ Libraries Without Breaking Encapsulation</title>
      <dc:creator>VladimirM</dc:creator>
      <pubDate>Wed, 21 Oct 2026 12:51:51 +0000</pubDate>
      <link>https://dev.to/vladimirm/testing-private-logic-in-c-libraries-without-breaking-encapsulation-2c04</link>
      <guid>https://dev.to/vladimirm/testing-private-logic-in-c-libraries-without-breaking-encapsulation-2c04</guid>
      <description>&lt;h1&gt;
  
  
  Testing Private Logic in C++ Libraries Without Breaking Encapsulation
&lt;/h1&gt;

&lt;p&gt;When developing dynamic or static libraries, a common challenge arises: how to achieve high test coverage for internal logic without exposing private members to the end-user.&lt;/p&gt;

&lt;p&gt;Typically, without a specialized testing framework, testing private methods often leads to "dirty" code—either by making members public or by using intrusive workarounds that violate the principles of Object-Oriented Programming.&lt;/p&gt;

&lt;p&gt;My name is Vladimir Markin, and I am the author of &lt;strong&gt;fcfTest&lt;/strong&gt;—a lightweight C++ unit testing library designed to solve exactly this problem. In this article, I will show you two "lifehacks" for testing private methods within a shared library using fcfTest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Documentation:&lt;/strong&gt; &lt;a href="https://fcf-framework.is-a-fullstack.dev/cpp-libraries/fcfTest" rel="noopener noreferrer"&gt;https://fcf-framework.is-a-fullstack.dev/cpp-libraries/fcfTest&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/fcf-framework/fcfTest" rel="noopener noreferrer"&gt;https://github.com/fcf-framework/fcfTest&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Hack 1: Testing Private Class Methods via &lt;code&gt;friend&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;To make a test a "friend" of a class, you usually need to know the exact name of the class generated by the testing framework. In fcfTest, the &lt;code&gt;FCF_TEST_DEFINE&lt;/code&gt; macro accepts an optional fourth parameter: an explicit name for the generated test class. This allows you to elegantly grant your test access to the &lt;code&gt;private&lt;/code&gt; sections of your class.&lt;/p&gt;
&lt;h3&gt;
  
  
  Implementation Example (&lt;code&gt;shared_engine.cpp&lt;/code&gt;)
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;fcfTest/test.hpp&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MySecretEngine&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;private:&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;_state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;computeInternalData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;multiplier&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;_state&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;multiplier&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Declare the future test class as a friend.&lt;/span&gt;
    &lt;span class="c1"&gt;// You decide the name!&lt;/span&gt;
    &lt;span class="k"&gt;friend&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyEnginePrivateTester&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Define the test.&lt;/span&gt;
&lt;span class="c1"&gt;// We pass our chosen name as the fourth argument.&lt;/span&gt;
&lt;span class="c1"&gt;// The first three arguments are the Part, Group, and Test name strings.&lt;/span&gt;
&lt;span class="n"&gt;FCF_TEST_DEFINE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Engine"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Internal"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"PrivateMethodTest"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MyEnginePrivateTester&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;MySecretEngine&lt;/span&gt; &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// The test has full access to private methods and fields!&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;computeInternalData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Perform the assertion.&lt;/span&gt;
    &lt;span class="n"&gt;FCF_TEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;84&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Why is this better?&lt;/strong&gt;&lt;br&gt;
You aren't opening your class internals to the entire world. Instead, you are providing surgical, targeted access to one specific test class.&lt;/p&gt;


&lt;h2&gt;
  
  
  Hack 2: Separating the Shared Library from the Test Runner
&lt;/h2&gt;

&lt;p&gt;The example above should reside within your dynamic library (&lt;code&gt;.dll&lt;/code&gt; or &lt;code&gt;.so&lt;/code&gt;), but you still need a way to execute those internal tests. &lt;/p&gt;

&lt;p&gt;The strategy is simple: your dynamic library will contain all the necessary tests and export the fcfTest symbols. An external "Runner" application will then link against your library and trigger the execution.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 1. Embedding Tests in the Library
&lt;/h3&gt;

&lt;p&gt;To achieve this, you must define two macros before including the &lt;code&gt;fcfTest/test.hpp&lt;/code&gt; header: &lt;code&gt;FCF_TEST_IMPLEMENTATION&lt;/code&gt; and &lt;code&gt;FCF_TEST_EXPORT&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;FCF_TEST_IMPLEMENTATION&lt;/code&gt;: Enables the implementation section within the header. This should be defined in &lt;strong&gt;only one&lt;/strong&gt; C++ file in your library.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;FCF_TEST_EXPORT&lt;/code&gt;: Tells the compiler to export the fcfTest symbols (essential for DLL/SO).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's update &lt;code&gt;shared_engine.cpp&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Defining FCF_TEST_IMPLEMENTATION tells the compiler &lt;/span&gt;
&lt;span class="c1"&gt;// to include the actual logic of the library in this file.&lt;/span&gt;
&lt;span class="cp"&gt;#define FCF_TEST_IMPLEMENTATION
&lt;/span&gt;
&lt;span class="c1"&gt;// Export fcfTest symbols so they are available to the runner.&lt;/span&gt;
&lt;span class="cp"&gt;#define FCF_TEST_EXPORT
&lt;/span&gt;
&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;fcfTest/test.hpp&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MySecretEngine&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;private:&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;_state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;computeInternalData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;multiplier&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;_state&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;multiplier&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;friend&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyEnginePrivateTester&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="n"&gt;FCF_TEST_DEFINE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Engine"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Internal"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"PrivateMethodTest"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MyEnginePrivateTester&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;MySecretEngine&lt;/span&gt; &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;computeInternalData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;FCF_TEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;84&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2. Creating the Runner
&lt;/h3&gt;

&lt;p&gt;The Runner is a lightweight standalone application that links to your library. You include the framework using the &lt;code&gt;FCF_TEST_IMPORT&lt;/code&gt; macro. When executed, the framework automatically discovers all tests "embedded" within the linked library.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;File: &lt;code&gt;runner_main.cpp&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#define FCF_TEST_IMPORT // Import registered tests from linked libraries
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;fcfTest/test.hpp&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;argc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// fcfTest automatically collects and runs tests from the linked library!&lt;/span&gt;
    &lt;span class="c1"&gt;// Supports flexible CLI filtering (e.g., --test-part Engine)&lt;/span&gt;
    &lt;span class="n"&gt;fcf&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;NTest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cmdRun&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;argc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fcf&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;NTest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;CRM_RUN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3. Create CMakeLists.txt
&lt;/h3&gt;

&lt;p&gt;Here is a standard &lt;code&gt;CMakeLists.txt&lt;/code&gt; to tie it all together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cmake"&gt;&lt;code&gt;&lt;span class="nb"&gt;cmake_minimum_required&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;VERSION 3.15...&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;CMAKE_VERSION&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;project&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;FcfTestProject&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Locate the external 'fcfTest' package.&lt;/span&gt;
&lt;span class="nb"&gt;find_package&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;fcfTest CONFIG REQUIRED&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# 1. Create a dynamic shared library&lt;/span&gt;
&lt;span class="nb"&gt;add_library&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;shared SHARED shared_engine.cpp&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;target_link_libraries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;shared PRIVATE fcf::fcfTest&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# 2. Create the runner executable&lt;/span&gt;
&lt;span class="nb"&gt;add_executable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;runner runner_main.cpp&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;target_link_libraries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;runner PRIVATE fcf::fcfTest&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Link the runner with our shared library&lt;/span&gt;
&lt;span class="nb"&gt;target_link_libraries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;runner PRIVATE shared&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4. Configuring and Installing fcfTest
&lt;/h3&gt;

&lt;p&gt;You have two main ways to integrate fcfTest into your project:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Using vcpkg
&lt;/h4&gt;

&lt;p&gt;This is the easiest way to manage dependencies.&lt;/p&gt;

&lt;p&gt;Please note that the version on vcpkg typically lags a few days behind the current version on GitHub.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install the package:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   vcpkg &lt;span class="nb"&gt;install &lt;/span&gt;fcftest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Configure your CMake project by pointing to the vcpkg toolchain:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   cmake .. &lt;span class="nt"&gt;-DCMAKE_TOOLCHAIN_FILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"~/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. Manual Installation from GitHub
&lt;/h4&gt;

&lt;p&gt;If you prefer to manage the source yourself:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clone the repository:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;cd&lt;/span&gt; ~/path/to/projects/directory
   git clone https://github.com/fcf-framework/fcfTest.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Configure your project by providing the path to the cloned directory:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;mkdir&lt;/span&gt; ~/path/to/test/project/build
   &lt;span class="nb"&gt;cd&lt;/span&gt; ~/path/to/test/project/build
   cmake .. &lt;span class="nt"&gt;-DCMAKE_PREFIX_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"~/path/to/projects/directory"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5. Build and Run
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/path/to/test/project/build
cmake &lt;span class="nt"&gt;--build&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;
./runner 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Expected Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Performing the test: "Engine" -&amp;gt; "Internal" -&amp;gt; "PrivateMethodTest" ...
    [SUCCESS] Test completed successfully (0.000`003`562 sec)

[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`003`562 sec
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Summary of Benefits
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Double Encapsulation Protection&lt;/strong&gt;: Your library's public API remains clean for end-users, while internal logic is kept &lt;code&gt;private&lt;/code&gt; and only exposed to specific, authorized tests.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;No "CMake Magic" Required&lt;/strong&gt;: You don't need to mess with complex private include paths in your test targets. The tests live exactly where the code lives.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Smart Debugging&lt;/strong&gt;: If a test fails, the &lt;code&gt;FCF_TEST&lt;/code&gt; macro provides a detailed report including the file, line number, and the exact values of the variables at the moment of failure.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Example Failure Output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Test error: result == 84  [FILE: shared_engine.cpp:25]
  Values: 
    result: 82
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Let's Discuss!
&lt;/h3&gt;

&lt;p&gt;How do you usually test private logic in your C++ libraries?&lt;/p&gt;

&lt;p&gt;Happy testing!&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>testing</category>
      <category>opensource</category>
      <category>showdev</category>
    </item>
    <item>
      <title>fcfTest - Unit Test Library - All in one, yet lightweight</title>
      <dc:creator>VladimirM</dc:creator>
      <pubDate>Mon, 23 Mar 2026 01:40:45 +0000</pubDate>
      <link>https://dev.to/vladimirm/fcftest-unit-test-library-3cgg</link>
      <guid>https://dev.to/vladimirm/fcftest-unit-test-library-3cgg</guid>
      <description>&lt;p&gt;Hello. I finally finished writing the fcfTest unit testing library (MIT License): &lt;a href="https://github.com/fcf-framework/fcfTest" rel="noopener noreferrer"&gt;https://github.com/fcf-framework/fcfTest&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Official documentation page: &lt;a href="https://fcf-framework.is-a-fullstack.dev/cpp-libraries/fcfTest" rel="noopener noreferrer"&gt;https://fcf-framework.is-a-fullstack.dev/cpp-libraries/fcfTest&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Until now, the library consisted of just a single macro; however, it now fully implements all the necessary functionality.&lt;/p&gt;

&lt;p&gt;Its primary distinguishing feature lies in the use of a single assertion macro for all tests - a capability made possible by the fact that the library is written in C++. Furthermore, integrating it requires nothing more than a single header file.&lt;/p&gt;

&lt;p&gt;The library supports independent command-line processing, allows for specifying the test execution order, and most importantly - supports a hierarchical test structure organized into three levels: Section -&amp;gt; Group -&amp;gt; Test. It can also be compiled as a standalone DLL.&lt;/p&gt;

&lt;p&gt;Additionally, the library includes a simple logger (fcf::NTest::Duration::err() … fcf::NTest::log() … fcf::NTest::trc()) and a class for measuring execution duration (fcf::NTest::Duration).&lt;/p&gt;

&lt;p&gt;The main FCF_TEST macro - suitable for all scenarios:&lt;/p&gt;

&lt;p&gt;It allows for writing complex checks that include variable state monitoring.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt; &lt;span class="n"&gt;FCF_TEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in the terminal, you will see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Test error: a == 15  [FILE: DIR_PATH/main.cpp:LINE]
 Values:
   a: 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first parameter is a computed verification expression, while all other parameters are observed variables.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

&lt;p&gt;Next follows the main example from this library; the accompanying comment explains the core mechanics of its operation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;vector&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="c1"&gt;// It is necessary to define the `FCF_TEST_IMPLEMENTATION` macro so that the &lt;/span&gt;
&lt;span class="c1"&gt;// implementations are exposed when the header file is included. &lt;/span&gt;
&lt;span class="c1"&gt;// If the `fcfTest/test.hpp` file is included multiple times within a project, &lt;/span&gt;
&lt;span class="c1"&gt;// this macro should be defined in only one `.cpp` file.&lt;/span&gt;
&lt;span class="c1"&gt;//&lt;/span&gt;
&lt;span class="c1"&gt;// When working with DLLs, you must define both the `FCF_TEST_IMPLEMENTATION` &lt;/span&gt;
&lt;span class="c1"&gt;// and `FCF_TEST_EXPORT` macros within the main library that exports &lt;/span&gt;
&lt;span class="c1"&gt;// the functions; conversely, in libraries that import these functions, &lt;/span&gt;
&lt;span class="c1"&gt;// you need to define only the `FCF_TEST_IMPORT` macro.&lt;/span&gt;
&lt;span class="cp"&gt;#define FCF_TEST_IMPLEMENTATION
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;fcfTest/test.hpp&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;

&lt;span class="c1"&gt;// --- Test Declarations ---&lt;/span&gt;
&lt;span class="n"&gt;FCF_TEST_DECLARE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Math"&lt;/span&gt; &lt;span class="cm"&gt;/*PART NAME*/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                 &lt;span class="s"&gt;"BasicArithmetic"&lt;/span&gt; &lt;span class="cm"&gt;/*GROUP NAME*/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                 &lt;span class="s"&gt;"Addition"&lt;/span&gt; &lt;span class="cm"&gt;/*TEST NAME*/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// We create an object to measure execution duration&lt;/span&gt;
  &lt;span class="c1"&gt;// over 10,000 iterations.&lt;/span&gt;
  &lt;span class="n"&gt;fcf&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;NTest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Duration&lt;/span&gt; &lt;span class="n"&gt;bench&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Set the starting time point for measuring execution time.&lt;/span&gt;
  &lt;span class="n"&gt;bench&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;begin&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;size_t&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;bench&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;iterationCount&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// Performing a check of the unit test execution.&lt;/span&gt;
    &lt;span class="n"&gt;FCF_TEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// We set the final time point for measuring execution time.&lt;/span&gt;
  &lt;span class="n"&gt;bench&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="c1"&gt;// Outputting the execution time measurement result at the 'info' logging level.&lt;/span&gt;
  &lt;span class="n"&gt;fcf&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;NTest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;inf&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"  Itertion count: "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;bench&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;iterationCount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;fcf&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;NTest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;inf&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"  Total: "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;bench&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;totalDuration&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;" ns"&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;fcf&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;NTest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;inf&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"  Avg: "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;bench&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;" ns"&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;FCF_TEST_DECLARE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Math"&lt;/span&gt; &lt;span class="cm"&gt;/*PART NAME*/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                 &lt;span class="s"&gt;"BasicArithmetic"&lt;/span&gt; &lt;span class="cm"&gt;/*GROUP NAME*/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                 &lt;span class="s"&gt;"Subtraction"&lt;/span&gt; &lt;span class="cm"&gt;/*TEST NAME*/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// We create an object to measure execution duration&lt;/span&gt;
  &lt;span class="c1"&gt;// over 10,000 iterations.&lt;/span&gt;
  &lt;span class="n"&gt;fcf&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;NTest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Duration&lt;/span&gt; &lt;span class="n"&gt;bench&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// We perform the task 10,000 times.&lt;/span&gt;
  &lt;span class="n"&gt;bench&lt;/span&gt;&lt;span class="p"&gt;([](){&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// Performing a check of the unit test execution.&lt;/span&gt;
    &lt;span class="n"&gt;FCF_TEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="c1"&gt;// Outputting the execution time measurement result at the 'info' logging level.&lt;/span&gt;
  &lt;span class="n"&gt;fcf&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;NTest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;inf&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"  Itertion count: "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;bench&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;iterationCount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;fcf&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;NTest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;inf&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"  Total: "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;bench&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;totalDuration&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;" ns"&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;fcf&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;NTest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;inf&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"  Avg: "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;bench&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;" ns"&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;FCF_TEST_DECLARE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Vector"&lt;/span&gt; &lt;span class="cm"&gt;/*PART NAME*/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                 &lt;span class="s"&gt;"SizeCheck"&lt;/span&gt; &lt;span class="cm"&gt;/*GROUP NAME*/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                 &lt;span class="s"&gt;"EmptyVector"&lt;/span&gt; &lt;span class="cm"&gt;/*TEST NAME*/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;FCF_TEST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// --- Order Registration ---&lt;/span&gt;
&lt;span class="c1"&gt;// Run Math tests before Vector tests&lt;/span&gt;
&lt;span class="n"&gt;FCF_TEST_PART_ORDER&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Math"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;FCF_TEST_PART_ORDER&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Vector"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Run "BasicArithmetic" group first within Math part&lt;/span&gt;
&lt;span class="n"&gt;FCF_TEST_GROUP_ORDER&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"BasicArithmetic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Run Addition test first&lt;/span&gt;
&lt;span class="n"&gt;FCF_TEST_TEST_ORDER&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Addition"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;a_argc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;a_argv&lt;/span&gt;&lt;span class="p"&gt;[])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Use CRM_RUN for standard execution&lt;/span&gt;
  &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;fcf&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;NTest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cmdRun&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a_argc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;a_argv&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fcf&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;NTest&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;CRM_RUN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you launch this application, you will see the following report:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Performing the test: "Math" -&amp;gt; "BasicArithmetic" -&amp;gt; "Subtraction" ...
Performing the test: "Math" -&amp;gt; "BasicArithmetic" -&amp;gt; "Addition" ...
Performing the test: "Vector" -&amp;gt; "SizeCheck" -&amp;gt; "EmptyVector" ...

All tests were completed. Number of tests: 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, if you specify the logging level parameter beforehand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./full-example &lt;span class="nt"&gt;--test-log-level&lt;/span&gt; inf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the result will be supplemented with information regarding execution speed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Performing the test: "Math" -&amp;gt; "BasicArithmetic" -&amp;gt; "Subtraction" ...
 Itertion count: 10000
 Total: 65652 ns
 Avg: 6 ns
Performing the test: "Math" -&amp;gt; "BasicArithmetic" -&amp;gt; "Addition" ...
 Itertion count: 10000
 Total: 77750 ns
 Avg: 7 ns
Performing the test: "Vector" -&amp;gt; "SizeCheck" -&amp;gt; "EmptyVector" ...

All tests were completed. Number of tests: 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Help on the full set of commands can be obtained by passing the command-line parameter &lt;code&gt;--test-help&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./full-example &lt;span class="nt"&gt;--test-help&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Test options:
 --test-run  - Run tests
 --test-list - Displays a list of all tests
 --test-part  PART_NAME - Run only tests from the part. The parameter can be used multiple times
 --test-group GROUP_NAME - Run only tests from the group. The parameter can be used multiple times
 --test-test  TEST_NAME - Run only this test. The parameter can be used multiple times
 --test-log-level LEVEL - Logging level (VALUES: off, ftl, err, wrn, att, log, inf, dbg, trc)
 --test-help  - Help message
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope this library is useful to you. It's part of a larger project with a long history of development, and a stable second version is currently being developed. The project is unknown and needs support, so if you're interested, subscribe to its resources.&lt;/p&gt;

&lt;p&gt;Links:&lt;/p&gt;

&lt;p&gt;Tumblr:  &lt;a href="https://www.tumblr.com/blog/fcfjs" rel="noopener noreferrer"&gt;https://www.tumblr.com/blog/fcfjs&lt;/a&gt;&lt;br&gt;
Youtube: &lt;a href="https://www.youtube.com/@fcfframework" rel="noopener noreferrer"&gt;https://www.youtube.com/@fcfframework&lt;/a&gt;&lt;br&gt;
Github: &lt;a href="https://github.com/fcf-framework/fcfTest" rel="noopener noreferrer"&gt;https://github.com/fcf-framework/fcfTest&lt;/a&gt;&lt;br&gt;
Instagram: &lt;a href="https://www.instagram.com/v.o.markin221" rel="noopener noreferrer"&gt;https://www.instagram.com/v.o.markin221&lt;/a&gt;&lt;/p&gt;

</description>
      <category>unittest</category>
      <category>cpp</category>
      <category>programming</category>
      <category>development</category>
    </item>
    <item>
      <title>How to reduce the size of an executable file written in C++</title>
      <dc:creator>VladimirM</dc:creator>
      <pubDate>Wed, 18 Mar 2026 17:52:41 +0000</pubDate>
      <link>https://dev.to/vladimirm/how-to-reduce-the-size-of-an-executable-file-written-in-c-2p6j</link>
      <guid>https://dev.to/vladimirm/how-to-reduce-the-size-of-an-executable-file-written-in-c-2p6j</guid>
      <description>&lt;p&gt;Hello. I'd like to describe the basic methods for optimizing the size of a C++ executable file on UNIX systems. This short article also includes a video about the process of optimizing binary file size.&lt;/p&gt;

&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/hKik2K9sO7s"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

&lt;p&gt;To begin with, our main tool will be objdump, with which we will get information about the declared functions.&lt;/p&gt;

&lt;p&gt;The main command looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;objdump  &lt;span class="nt"&gt;-t&lt;/span&gt; YOUR_BINARY_FILE |&lt;span class="se"&gt;\&lt;/span&gt;
c++filt |&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"[0-9a-z]&lt;/span&gt;&lt;span class="se"&gt;\+\s&lt;/span&gt;&lt;span class="s2"&gt;*[a-zA-Z]&lt;/span&gt;&lt;span class="se"&gt;\+\s\+&lt;/span&gt;&lt;span class="s2"&gt;[a-zA-Z]&lt;/span&gt;&lt;span class="se"&gt;\+&lt;/span&gt;&lt;span class="s2"&gt;[.a-zA-Z_]&lt;/span&gt;&lt;span class="se"&gt;\+&lt;/span&gt;&lt;span class="s2"&gt;[0-9a-f]&lt;/span&gt;&lt;span class="se"&gt;\+&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; |&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; &lt;span class="s2"&gt;"s/([0-9a-f]+)[^0]+([0-9a-f]+)&lt;/span&gt;&lt;span class="se"&gt;\s&lt;/span&gt;&lt;span class="s2"&gt;+(.+)/&lt;/span&gt;&lt;span class="se"&gt;\2&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="se"&gt;\3&lt;/span&gt;&lt;span class="s2"&gt;/p"&lt;/span&gt; |&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nb"&gt;sort&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; |&lt;span class="se"&gt;\&lt;/span&gt;
less
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As a result, you will get two columns: the size of the function in hexadecimal notation and the name of the function itself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;000000000006e2fa FcfTest::BasisTest::staticVectorTest()
000000000001d4bb FcfTest::BasisTest::staticVectorPushTest()
0000000000019ded FcfTest::BasisTest::foreachTest()
000000000000edff iteratorTest()
000000000000ccef FcfTest::BasisTest::staticVectorNotReduce()
000000000000b9ca FcfTest::BasisTest::callQuietTest()
000000000000b93b FcfTest::BasisTest::variantConstructorTest()
000000000000b87e variantTest()
00000000000081de indexTypesTest()
000000000000332d FcfTest::BasisTest::metaTypeSequenceTest()
00000000000025cc deepIndexNearestCaller()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By analyzing this information, you can identify problem areas, such as replacing some templates or eliminating code redundancy.&lt;/p&gt;

&lt;p&gt;The next stage of optimization involves using compiler directives to minimize code. The next group of macros directs the compiler to use optimizations based on size minimization, which can be exploited in problematic areas of the code. Implementations are provided for msvc, gcc, and clang.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#ifdef _MSC_VER 
&lt;/span&gt;  &lt;span class="cp"&gt;#define ATTRIBUTE_MINIMIZE 
&lt;/span&gt;  &lt;span class="cp"&gt;#define ATTRIBUTE_MINIMIZE_BEGIN __pragma(optimize("s", on)) 
&lt;/span&gt;  &lt;span class="cp"&gt;#define ATTRIBUTE_MINIMIZE_END __pragma(optimize("", on)) 
#elif defined(__clang__) 
&lt;/span&gt;  &lt;span class="cp"&gt;#define ATTRIBUTE_MINIMIZE_BEGIN 
&lt;/span&gt;  &lt;span class="cp"&gt;#define ATTRIBUTE_MINIMIZE __attribute__((cold, minsize)) 
&lt;/span&gt;  &lt;span class="cp"&gt;#define ATTRIBUTE_MINIMIZE_END 
#else 
&lt;/span&gt;  &lt;span class="cp"&gt;#define ATTRIBUTE_MINIMIZE_BEGIN 
&lt;/span&gt;  &lt;span class="cp"&gt;#define ATTRIBUTE_MINIMIZE __attribute__((cold, optimize("Os")))
&lt;/span&gt;  &lt;span class="cp"&gt;#define ATTRIBUTE_MINIMIZE_END 
#endif 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And a simple example of using these macros:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;ATTRIBUTE_MINIMIZE_BEGIN&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;ATTRIBUTE_MINIMIZE&lt;/span&gt; &lt;span class="nf"&gt;ourFunction&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;ATTRIBUTE_MINIMIZE_END&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope this information was useful to you.&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>optimization</category>
      <category>objdump</category>
    </item>
    <item>
      <title>Video on resolving circular dependencies in C++ HPP files</title>
      <dc:creator>VladimirM</dc:creator>
      <pubDate>Wed, 11 Mar 2026 09:54:34 +0000</pubDate>
      <link>https://dev.to/vladimirm/video-on-resolving-circular-dependencies-in-c-hpp-files-1j34</link>
      <guid>https://dev.to/vladimirm/video-on-resolving-circular-dependencies-in-c-hpp-files-1j34</guid>
      <description>&lt;p&gt;Relaxing video about C++ HPP file cycles&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=vEzBvLwU1GI&amp;amp;list=PLEYoHUtGESJdHg1W3IdZ1VqFJCKxXeFWO" rel="noopener noreferrer"&gt;C++ Development: How to Fix C++ Header File Loops&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;

  &lt;iframe src="https://www.youtube.com/embed/vEzBvLwU1GI"&gt;
  &lt;/iframe&gt;


&lt;/p&gt;

</description>
      <category>coding</category>
      <category>cpp</category>
      <category>fix</category>
    </item>
    <item>
      <title>C++ Vector with the possibility of storage in data in the memory of the object</title>
      <dc:creator>VladimirM</dc:creator>
      <pubDate>Sun, 13 Jul 2025 01:23:33 +0000</pubDate>
      <link>https://dev.to/vladimirm/c-vector-with-the-possibility-of-storage-in-data-in-the-memory-of-the-object-41k4</link>
      <guid>https://dev.to/vladimirm/c-vector-with-the-possibility-of-storage-in-data-in-the-memory-of-the-object-41k4</guid>
      <description>&lt;p&gt;&lt;code&gt;Updates:&lt;/code&gt;&lt;br&gt;
&lt;code&gt;2025-07-15 - Fixed build error when using the clear() method&lt;/code&gt;&lt;br&gt;
&lt;code&gt;2025-07-15 - Fixed pop_back method.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Hello. This small article is dedicated to the StaticVector class, with similar std::vector&lt;/p&gt;

&lt;p&gt;The main distinguishing feature of this class is that it stores can store data in the inner fields of the object, if the volume of data does not fit in the inner fields of the class, then the memory is allocated in a heap. This approach allows you to reduce the execution time on the allocated of memory.&lt;/p&gt;

&lt;p&gt;If the memory is allocated in the heap of the size of the block of the allocated block is determined by the following rules:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F081m3wrvcwrgfdbfr5hy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F081m3wrvcwrgfdbfr5hy.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This blog is conducted with two purposes so that the written things were beneficial and was not boring. Therefore, I also apply the video how the development of this class took place.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/V0WKACMHue4"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Attention: After this video, the OffsetSize parameter was added to the class template and additional changes were made during optimization.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Description of the degree function
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe0qfc2j4yuxambyw4j16.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe0qfc2j4yuxambyw4j16.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is, in the case of memory of memory in a heap, we distinguish memory with a reserve. The size of the buffer in this case is determined by the degree function of the degree N.&lt;/p&gt;

&lt;p&gt;This power function can be set as a linear increase&lt;/p&gt;

&lt;p&gt;OffsetSize = 0;&lt;br&gt;
StepSize = 16;&lt;br&gt;
StepModule = 1;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;N   BufferSize
0   8
1   16
2   24
3   32
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F10m9crot2pppkn3pbnkt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F10m9crot2pppkn3pbnkt.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and increase in power mode&lt;/p&gt;

&lt;p&gt;OffsetSize = 0;&lt;br&gt;
StepSize = 2;&lt;br&gt;
StepModule = 2&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;N   BufferSize
0   2
1   6
2   14
3   30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7yd1e5wl4t7fr6mikxtz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7yd1e5wl4t7fr6mikxtz.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using this function, you can get the result equivalent to 2^N by setting the OffsetSize parameter, equal to 2.&lt;/p&gt;

&lt;p&gt;OffsetSize = 2;&lt;br&gt;
StepSize = 2;&lt;br&gt;
StepModule = 2&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;N   BufferSize
0   4
1   8
2   16
3   32
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Description of a fixed increase function
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fid5ts26k52ub6i58sjpf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fid5ts26k52ub6i58sjpf.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For superly large values, the size of the buffer can be calculated according to the second function, which has a fixed increase in the size of the buffer when calculating the next step and is used if the resulting sizes of the buffer exceeds the value of MaxPow&lt;/p&gt;

&lt;p&gt;MaxPowStepSize step size is determined as the difference in the steppe function of the following after the MaxPow and its previous value.&lt;/p&gt;

&lt;p&gt;F(Laststep) - F(Laststep -1)&lt;/p&gt;

&lt;p&gt;And MaxPowStart is the first value of the degree function that follows the MaxPow parameter.&lt;/p&gt;

&lt;h2&gt;
  
  
  A brief description of the class
&lt;/h2&gt;

&lt;p&gt;The class template has the following view:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;template &amp;lt;
  typename Ty, 
  unsigned int StaticSize=16, 
  unsigned int OffsetSize=2, 
  unsigned int StepSize=2, 
  unsigned int StepModuleInt=2, 
  unsigned int StepModuleFrac=0, 
  unsigned int MaxPow=0&amp;gt;
class StaticVector;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Description of the parameters of the template&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;typename Ty&lt;/strong&gt; - Type of stored elements&lt;br&gt;
&lt;strong&gt;unsigned int StaticSize&lt;/strong&gt; - Maximum number of elements stored in the internal buffer&lt;br&gt;
&lt;strong&gt;unsigned int OffsetSize&lt;/strong&gt; - The offset size used in the calculation function&lt;br&gt;
&lt;strong&gt;unsigned int StepSize&lt;/strong&gt; - The step size used in the calculation function&lt;br&gt;
&lt;strong&gt;unsigned int StepModuleInt&lt;/strong&gt; - The integer part of the StepModule parameter used in the calculation function&lt;br&gt;
&lt;strong&gt;unsigned int StepModuleFrac&lt;/strong&gt; - Fractional part of the StepModule parameter number used in the calculation function&lt;br&gt;
&lt;strong&gt;unsigned int MaxPow&lt;/strong&gt; - The limit value after which the buffer size calculation goes into linear form and a simple increment is performed. If the value is 0, but this functionality is not used&lt;/p&gt;

&lt;p&gt;The class itself in use is similar to std::vector. It has iterators, access element by index and the push_back() and pop_back() operation&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fcf::StaticVector&amp;lt;int, 32&amp;gt; v; 
for(int j = 0; j &amp;lt; a_vecSize; ++j) {
  v.push_back(j); 
} 

for(auto it = v.begin(); it = v.end(); ++it) { 
  std::cout &amp;lt;&amp;lt; *it &amp;lt;&amp;lt; std::endl;
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The speed of execution
&lt;/h2&gt;

&lt;p&gt;And most importantly. Comparison with the speed of std::vector.&lt;/p&gt;

&lt;p&gt;Comparison of push_back operations and creating a container with a given value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Launching on Linux (GCC)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Speed compare StaticVector with std::vector...

Number of iterations: 1024
StaticSize parameter: 64

                               StaticVector std::vector  std::vector/StaticVector

Push back test (1 items):      3            24           8                             
Push back test (4 items):      8            83           10.375                        
Push back test (8 items):      11           115          10.4545                       
Push back test (16 items):     18           145          8.05556                       
Push back test (64 items):     70           226          3.22857                       
Push back test (256 items):    345          450          1.30435                       
Push back test (1024 items):   1305         1191         0.912644                      
Push back test (32768 items):  98878        105334       1.06529                       
Push back test (131072 items): 438563       430047       0.980582                      
Initialize test(1 items):      8            13           1.625                         
Initialize test(4 items):      7            31           4.42857                       
Initialize test(8 items):      8            18           2.25                          
Initialize test(16 items):     9            19           2.11111                       
Initialize test(64 items):     13           27           2.07692                       
Initialize test(256 items):    68           76           1.11765                       
Initialize test(1024 items):   210          249          1.18571                       
Initialize test(32768 items):  8371         8750         1.04528                       
Initialize test(131072 items): 46040        45214        0.982059
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Launching on Windows (Visual Studio 2022)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Speed compare StaticVector with std::vector...

Number of iterations: 1024
StaticSize parameter: 64

                              StaticVector  std::vector std::vector/StaticVector

Push back test (1 items):      2            77          38.5
Push back test (4 items):      7            342         48.8571
Push back test (8 items):      12           495         41.25
Push back test (16 items):     23           664         28.8696
Push back test (64 items):     123          1542        12.5366
Push back test (256 items):    1044         2533        2.42625
Push back test (1024 items):   3544         3548        1.00113
Push back test (32768 items):  105358       201082      1.90856
Push back test (131072 items): 421519       480350      1.13957
Initialize test(1 items):      12           71          5.91667
Initialize test(4 items):      13           70          5.38462
Initialize test(8 items):      16           73          4.5625
Initialize test(16 items):     26           80          3.07692
Initialize test(64 items):     22           87          3.95455
Initialize test(256 items):    136          120         0.882353
Initialize test(1024 items):   347          474         1.36599
Initialize test(32768 items):  10175        10527       1.03459
Initialize test(131072 items): 52172        47994       0.919919

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first and second column is the time of the test, and the third is the ratio of the second column to the first&lt;/p&gt;

&lt;p&gt;As can be seen from the results with a small volume of StaticVector has a significant increase in performance, but it all depends on the platform&lt;/p&gt;

&lt;p&gt;You can download a separate class from the repository to github: &lt;a href="https://github.com/fcf-framework/short-fcfcpp-StaticVector" rel="noopener noreferrer"&gt;https://github.com/fcf-framework/short-fcfcpp-StaticVector&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cpp</category>
    </item>
    <item>
      <title>Started keeping a video blog about the development process. So that it wouldn't be boring.</title>
      <dc:creator>VladimirM</dc:creator>
      <pubDate>Mon, 26 May 2025 21:47:21 +0000</pubDate>
      <link>https://dev.to/vladimirm/started-keeping-a-video-blog-about-the-development-process-so-that-it-wouldnt-be-boring-10e8</link>
      <guid>https://dev.to/vladimirm/started-keeping-a-video-blog-about-the-development-process-so-that-it-wouldnt-be-boring-10e8</guid>
      <description>&lt;p&gt;Developing basic functionality for calling functions with untyped argument passing in C++.&lt;/p&gt;

&lt;p&gt;This functionality will be the main intermediary for the framework, both in the C++ implementation and in NODEJS.&lt;/p&gt;

&lt;p&gt;Video on Youtube.&lt;br&gt;
&lt;a href="https://youtu.be/AQUadKu37_E?si=ZJEuClhHWWX-i7E2" rel="noopener noreferrer"&gt;Part 1.1. Developing untyped function calls in C++. FCF Framework  (IN DEV).&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/AQUadKu37_E"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/QbBkKnFdkd8?si=ZWN8Hb8fNc0keZAI" rel="noopener noreferrer"&gt;Part 1.2. Container transfer. Developing untyped function calls in C++. FCF Framework (IN DEV)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/QbBkKnFdkd8"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Description of the degree function
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1d66md6nsu3yiqya73we.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1d66md6nsu3yiqya73we.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is, in the case of memory of memory in a heap, we distinguish memory with a reserve. The size of the buffer in this case is determined by the degree function of the degree N.&lt;/p&gt;

&lt;p&gt;This steppe function can be set as a linear increase&lt;/p&gt;

&lt;p&gt;OffsetSize = 0;&lt;br&gt;
StepSize = 16;&lt;br&gt;
StepModule = 1;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;N   BufferSize
0   8
1   16
2   24
3   32
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc575osru5509jrxgij40.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc575osru5509jrxgij40.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>node</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
