eraseData() method from fcf::NTest::State class
Class:
Package: fcfTest
File: test.hpp
Available from version: 1.2.1
Removes a data entry from the state storage.
The
This is useful for cleaning up resources or ensuring that subsequent tests do not accidentally access stale data left behind by previous execution steps.
Arguments
- The unique string identifier of the data entry to be removed.
Example: Removing data from state
Demonstrating how to delete a stored data entry.
#define FCF_TEST_IMPLEMENTATION
#include <fcfTest/test.hpp>
FCF_TEST_DEFINE ("EraseDemo", "Cleanup", "RemoveKey") {
// 1. Set some data
fcf::NTest::state ().data ("temp_key", fcf::NTest::SharedPtrAny::make <int>(100));
// 2. Verify it exists
FCF_TEST (fcf::NTest::state ().data ("temp_key").cast <int>() != nullptr);
// 3. Erase the data
fcf::NTest::state ().eraseData ("temp_key");
// 4. Verify it is gone
FCF_TEST (!fcf::NTest::state ().data ("temp_key"));
}
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: "EraseDemo" -> "Cleanup" -> "RemoveKey" ...
[SUCCESS] Test completed successfully (0.000`002`250 sec)
[SUCCESS] All tests were completed.
Tests: 1 passed, 0 failed, 0 skipped, 1 total
Duration: 0.000`002`250 sec
VPSDime is an industry leading VPS hosting company that provides virtualized server services with high performance, availability and friendly support.