diff --git a/tests/CInterfaceTest.cpp b/tests/CInterfaceTest.cpp index 729d777..a979e59 100644 --- a/tests/CInterfaceTest.cpp +++ b/tests/CInterfaceTest.cpp @@ -15,6 +15,7 @@ // along with this program. If not, see . #include +#include #include #include @@ -60,6 +61,25 @@ TEST_CASE("Try to read a non-existing entry") CHECK_EQ(buffer[0], '\0'); } +TEST_CASE("Change a value") +{ + constexpr auto tempFileName = "tmp.ini"; + std::filesystem::copy_file(fileName, tempFileName); + + { + constexpr auto newValue = 1337; + void* file = cppIni_open(tempFileName); + ScopeGuard guard{file}; + + const auto previousValue = cppIni_geti(file, "Section1", "IntEntry"); + CHECK_NE(previousValue, newValue); + cppIni_set(file, "Section1", "IntEntry", std::to_string(newValue).c_str()); + CHECK_EQ(cppIni_geti(file, "Section1", "IntEntry"), newValue); + } + + std::filesystem::remove(tempFileName); +} + TEST_CASE("Read an integer entry") { void* file = cppIni_open(fileName.c_str());