FCF 2.0 development in progress...
> > > > > >
[News] [C++ Libraries API] [C++ Downloads] [Donate to the project] [Contacts]

dataKeys() method from fcf::NTest::State class

std::set<std::string> dataKeys() const

Class: fcf::NTest::State

Package: fcfTest

File: test.hpp

Available from version: 1.2.1

Returns a set of all keys currently present in the state storage.

The dataKeys method provides a way to inspect all the unique identifiers currently used in the framework's internal data storage.

It returns a std::set of strings, where each string is a key that points to a valid fcf::NTest::SharedPtrAny object.

Result
std::set<std::string>
- A set containing all the keys currently stored in the state.

Example: Listing all stored keys

Demonstrating how to iterate through all keys in the state to see what data is available.

#define FCF_TEST_IMPLEMENTATION #include <fcfTest/test.hpp> FCF_TEST_DEFINE("KeysDemo", "Inspection", "ListAllKeys") { fcf::NTest::State& currentState = fcf::NTest::state(); // 1. Populate state with some data currentState.data("key_a", fcf::NTest::SharedPtrAny::make<int>(1)); currentState.data("key_b", fcf::NTest::SharedPtrAny::make<int>(2)); currentState.data("key_c", fcf::NTest::SharedPtrAny::make<int>(3)); // 2. Retrieve all keys std::set<std::string> keys = currentState.dataKeys(); // 3. Print the keys fcf::NTest::log() << "Available keys: " << std::endl; for (const auto& key : keys) { fcf::NTest::log() << " - " << key << std::endl; } FCF_TEST(keys.size() == 3); } int main(int a_argc, char* a_argv[]) { bool error = false; fcf::NTest::cmdRun(a_argc, a_argv, fcf::NTest::CRM_RUN, &error); return error ? 1 : 0; }

Output:

Performing the test: "KeysDemo" -> "Inspection" -> "ListAllKeys" ... > Available keys: > - key_a > - key_b > - key_c [SUCCESS] Test completed successfully (0.000`012`466 sec) [SUCCESS] All tests were completed. Tests: 1 passed, 0 failed, 0 skipped, 1 total Duration: 0.000`012`466 sec