Class File + fixes in _free methods.
[qshowdiff.git] / tests / hunk.cpp
blobc2b911e1e5a394e44d7bbc1e61cc4e82946ce4cf
1 #include <cppu.h>
2 #include "../hunk.h"
5 TEST_CASE(TestCaseHunk);
6 Text text;
7 Text text2;
8 void setUp()
10 text.addLine(new QString("Line1"));
11 text.addLine(new QString("Line2"));
12 text.addLine(new QString("Line3"));
13 text.addLine(new QString("Line4"));
14 text.addLine(new QString("Line5"));
16 text2.addLine(new QString("L1"));
17 text2.addLine(new QString("L2"));
18 text2.addLine(new QString("L3"));
19 text2.addLine(new QString("L4"));
20 text2.addLine(new QString("L5"));
23 void testConstructors()
25 Hunk hunk(100,200);
26 Hunk hunk2(hunk);
27 Hunk hunk3(200,100);
28 hunk3 = hunk;
30 assertEquals(hunk.originalBeginsAt(), hunk2.originalBeginsAt());
31 assertEquals(hunk.modifiedBeginsAt(), hunk3.modifiedBeginsAt());
34 void testIterators()
36 Hunk hunk(100,120);
38 hunk.addSnippet(new Context(new Text(text)));
39 hunk.addSnippet(new Added(new Text(text2)));
40 hunk.addSnippet(new Changed(new Text(text), new Text(text2)));
42 Hunk::iterator it = hunk.begin();
43 Hunk::iterator it_end = hunk.end();
44 assertEquals((*it).original(), Context(new Text(text)).original());
45 assertEquals((*it).modified(), Context(new Text(text)).modified());
47 it++;
48 it++;
49 assertEquals((*it).original(), Changed(new Text(text), new Text(text2)).original());
50 assertEquals((*it).modified(), Changed(new Text(text), new Text(text2)).modified());
52 assertEquals(hunk.numSnippets(), 3);
55 TESTS{
56 REG_TEST(testConstructors);
57 REG_TEST(testIterators);
59 TEST_CASE_END;