Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include "DocumentFormatterTest.h"
#include "DocumentFormatter.h"
#include <string>
#include <memory>
using namespace std;
namespace DocumentFormatterTesting {
typedef shared_ptr<string> _sps;
class TestInit: public UnitTest
{
public:
TestInit() { testName = "TestInit"; }
void PerformTest()
{
EditorDataController edc;
DocumentFormatter f(&edc);
f.SetMaxWidth(10);
f.SetMaxHeight(10);
f.Build();
AssertEquals(f.GetRenderableLineCount(),1);
AssertEquals(*f.GetLine(0),string());
cout << "I found the issue. It's the initial get cursor position call" << endl;
int x,y;
try {
f.GetCursorPosition(y,x);
} catch (string e) {
cout << "Caught: " << e << endl;
}
AssertEquals(y,x);
AssertEquals(x,0);
}
};
class TestGetLine: public UnitTest
{
public:
TestGetLine() { testName = "GetLine"; }
void PerformTest()
{
EditorDataController edc;
string str = "This ";
int i = 0;
for (char c : str) {
edc.InsertCharacter(c,0,i++);
}
DocumentFormatter f(&edc);
f.Build();
_sps line = f.GetLine(0);
cout << "Expected: 'This ' Got '" << *line << "'" << endl;
AssertEquals(*line, str);
}
};
}
DocumentFormatterTest :: DocumentFormatterTest()
{
using namespace DocumentFormatterTesting;
testName = "DocumentFormatter";
tests.push_back(new TestInit());
tests.push_back(new TestGetLine());
}
DocumentFormatterTest :: ~DocumentFormatterTest()
{
}