summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-diff.cpp27
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)