Skip to content

Commit

Permalink
Add value setter test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Master92 committed Nov 14, 2024
1 parent 92868de commit a6f049f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/CInterfaceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

#include <array>
#include <filesystem>
#include <format>

#include <cppIni/cppIni_c.h>
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit a6f049f

Please sign in to comment.