diff options
author | Roland Reichwein <mail@reichwein.it> | 2023-01-29 15:17:50 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2023-01-29 15:17:50 +0100 |
commit | b1fb4f3aa1ec29781d2e25b1a05fb70e143fd24d (patch) | |
tree | dde76c41fa7aaf8b8b7e036b72c9983590ae873d /tests | |
parent | fa0cfcee2c7494e5025f6fb51152352282cbc032 (diff) |
Diff bugfix
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-diff.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
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 <stdlib.h> +#include <boost/property_tree/ptree.hpp> + #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{"<diff><start>5</start><end>50</end><data>abc</data></diff>"}; EXPECT_EQ(d.get_xml(), "<diff><start>5</start><end>50</end><data>abc</data></diff>"); } + + // 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(), "<diff><start>0</start><end>0</end><data>abc</data></diff>"); + } // constructor via versions { @@ -120,6 +135,18 @@ TEST_F(DiffTest, constructor) Diff d{"abc", "c"}; EXPECT_EQ(d.get_xml(), "<diff><start>0</start><end>2</end><data/></diff>"); } + { + Diff d{"aaaa", "aa"}; + EXPECT_EQ(d.get_xml(), "<diff><start>2</start><end>4</end><data/></diff>"); + } + { + Diff d{"baaaa", "baa"}; + EXPECT_EQ(d.get_xml(), "<diff><start>3</start><end>5</end><data/></diff>"); + } + { + Diff d{"baaaab", "baab"}; + EXPECT_EQ(d.get_xml(), "<diff><start>1</start><end>3</end><data/></diff>"); + } } TEST_F(DiffTest, diff_create) |