Permalink
Cannot retrieve contributors at this time
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?
CSE3150_Project/DocumentFormatterTest.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
71 lines (61 sloc)
1.44 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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() | |
{ | |
} |