/**
 * @file test_nvm.cpp
 * @brief Unit tests for NVM driver component
 * @author Mahmoud Elmohtady
 * @company Nabd solutions - ASF
 * @copyright Copyright (c) 2025
 */

#include "unity.h"
#include "nvm.hpp"

extern "C" {

void setUp(void)
{
}

void tearDown(void)
{
}

void test_nvm_initialize(void)
{
    NvmDriver nvm;
    bool result = nvm.initialize();
    TEST_ASSERT_TRUE(result);
    TEST_ASSERT_TRUE(nvm.isInitialized());
}

void test_nvm_read_write(void)
{
    NvmDriver nvm;
    nvm.initialize();
    
    uint32_t writeValue = 12345;
    size_t length = sizeof(writeValue);
    
    NvmResult result = nvm.write("test_key", &writeValue, length);
    TEST_ASSERT_EQUAL(NvmResult::OK, result);
    
    uint32_t readValue = 0;
    result = nvm.read("test_key", &readValue, &length);
    TEST_ASSERT_EQUAL(NvmResult::OK, result);
}

} // extern "C"

