From b1fb4f3aa1ec29781d2e25b1a05fb70e143fd24d Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 29 Jan 2023 15:17:50 +0100 Subject: Diff bugfix --- tests/test-diff.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests') diff --git a/tests/test-diff.cpp b/tests/test-diff.cpp index 1704cfd..1625716 100644 --- a/tests/test-diff.cpp +++ b/tests/test-diff.cpp @@ -6,11 +6,14 @@ #include +#include + #include "libreichwein/file.h" #include "diff.h" namespace fs = std::filesystem; +namespace pt = boost::property_tree; using namespace Reichwein; class DiffTest: public ::testing::Test @@ -58,6 +61,18 @@ TEST_F(DiffTest, constructor) Diff d{"550abc"}; EXPECT_EQ(d.get_xml(), "550abc"); } + + // constructor via ptree + { + pt::ptree ptree; + EXPECT_THROW(Diff d{ptree}, std::exception); + + ptree.put("diff.start", 0); + ptree.put("diff.end", 0); + ptree.put("diff.data", "abc"); + Diff d{ptree}; + EXPECT_EQ(d.get_xml(), "00abc"); + } // constructor via versions { @@ -120,6 +135,18 @@ TEST_F(DiffTest, constructor) Diff d{"abc", "c"}; EXPECT_EQ(d.get_xml(), "02"); } + { + Diff d{"aaaa", "aa"}; + EXPECT_EQ(d.get_xml(), "24"); + } + { + Diff d{"baaaa", "baa"}; + EXPECT_EQ(d.get_xml(), "35"); + } + { + Diff d{"baaaab", "baab"}; + EXPECT_EQ(d.get_xml(), "13"); + } } TEST_F(DiffTest, diff_create) -- cgit v1.2.3