MCPcopy Create free account
hub / github.com/SpartanJ/eepp / UTEST

Function UTEST

src/tests/unit_tests/uidiffview_test.cpp:12–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10using namespace EE::UI::Tools;
11
12UTEST( UIDiffView, LoadFromStringsAndVerifyDiffLines ) {
13 UIApplication app( WindowSettings{ 800, 600, "eepp - unit tests" } );
14 UIDiffView* diffView = UIDiffView::New();
15
16 std::string oldText = "line 1\nline 2\nline 3\nline 4";
17 std::string newText = "line 1\nline 2 changed\nline 3\nline 4 added\nline 5";
18
19 diffView->loadFromStrings( oldText, newText );
20
21 const auto& lines = diffView->getDiffLines();
22
23 ASSERT_EQ( (size_t)7, lines.size() );
24
25 ASSERT_EQ( UIDiffView::DiffLineType::Common, lines[0].type );
26 ASSERT_TRUE( lines[0].text.toUtf8() == "line 1" );
27
28 ASSERT_EQ( UIDiffView::DiffLineType::Added, lines[1].type );
29 ASSERT_TRUE( lines[1].text.toUtf8() == "line 2 changed" );
30
31 ASSERT_EQ( UIDiffView::DiffLineType::Removed, lines[2].type );
32 ASSERT_TRUE( lines[2].text.toUtf8() == "line 2" );
33
34 ASSERT_EQ( UIDiffView::DiffLineType::Common, lines[3].type );
35 ASSERT_TRUE( lines[3].text.toUtf8() == "line 3" );
36
37 ASSERT_EQ( UIDiffView::DiffLineType::Added, lines[4].type );
38 ASSERT_TRUE( lines[4].text.toUtf8() == "line 4 added" );
39
40 ASSERT_EQ( UIDiffView::DiffLineType::Added, lines[5].type );
41 ASSERT_TRUE( lines[5].text.toUtf8() == "line 5" );
42
43 ASSERT_EQ( UIDiffView::DiffLineType::Removed, lines[6].type );
44 ASSERT_TRUE( lines[6].text.toUtf8() == "line 4" );
45
46 const auto& text = diffView->getEditor()->getDocument().getText();
47
48 std::string expectedCleanText =
49 "line 1\nline 2 changed\nline 2\nline 3\nline 4 added\nline 5\nline 4\n";
50
51 std::string textUtf8 = text.toUtf8();
52 ASSERT_TRUE( expectedCleanText == textUtf8 );
53
54 eeDelete( diffView );
55}
56
57UTEST( UIDiffView, LoadFromPatchAndVerifyCleanText ) {
58 UIApplication app( WindowSettings{ 800, 600, "eepp - unit tests" } );

Callers

nothing calls this directly

Calls 7

loadFromStringsMethod · 0.80
toUtf8Method · 0.80
getDocumentMethod · 0.80
loadFromPatchMethod · 0.80
NewFunction · 0.50
sizeMethod · 0.45
getTextMethod · 0.45

Tested by

no test coverage detected