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 "VerbatimFormatterTest.h"
#include "EditorDataController.h"
#include "VerbatimFormatter.h"
using namespace std;
namespace VerbatimFormatterTesting {
static void LoadEdc(EditorDataController &edc)
{
for (int i = 0; i<10; ++i) {
for (int j = 0; j<10; ++j) {
edc.InsertCharacter('a'+i+j,i,j);
}
edc.InsertNewLine(i,10);
}
}
class TestInit: public UnitTest
{
public:
TestInit() { testName = "TestInit"; }
void PerformTest()
{
EditorDataController edc;
VerbatimFormatter f(&edc);
f.SetMaxWidth(5);
f.SetMaxHeight(5);
int x,y;
f.GetCursorPosition(y,x);
AssertEquals(y,x);
AssertEquals(y,0);
}
};
class TestMoveRight: public UnitTest
{
public:
TestMoveRight() { testName = "Test Move Right"; }
void PerformTest()
{
EditorDataController edc;
VerbatimFormatter f(&edc);
f.SetMaxHeight(5);
f.SetMaxWidth(5);
for (int i = 0; i<10; ++i) {
edc.InsertCharacter('0' + i, 0, i);
}
AssertEquals(edc.GetLine(0), string("0123456789"));
cout << "We're going to move right 10 times. And we're going to track where the fuck the cursor is going" << endl;
int i = 0;
for (; i<5; ++i) {
int row,col;
f.GetCursorPosition(row,col);
cout << "Before" << endl;
cout << "Row: " << row << " Col: " << col << endl;
f.HandleMoveRight();
f.Build();
f.GetCursorPosition(row,col);
cout << "After" << endl;
cout << "Row: " << row << " Col: " << col << endl;
AssertEquals(row,0);
}
for (; i<10; ++i) {
int row,col;
f.GetCursorPosition(row,col);
cout << "Before" << endl;
cout << "Row: " << row << " Col: " << col << endl;
f.HandleMoveRight();
f.Build();
f.GetCursorPosition(row,col);
cout << "After" << endl;
cout << "Row: " << row << " Col: " << col << endl;
AssertEquals(row,0);
AssertEquals(col,4);
}
}
};
class TestAdvancedCursorSetAndGet: public UnitTest
{
public:
TestAdvancedCursorSetAndGet() { testName = "Advanced Cursor Set and Get"; }
void PerformTest()
{
EditorDataController edc;
VerbatimFormatter f(&edc);
f.SetMaxHeight(5);
f.SetMaxWidth(5);
LoadEdc(edc);
}
};
}
VerbatimFormatterTest :: VerbatimFormatterTest()
{
using namespace VerbatimFormatterTesting;
testName = "VerbatimFormatter";
tests.push_back(new TestInit());
tests.push_back(new TestMoveRight());
tests.push_back(new TestAdvancedCursorSetAndGet());
}
VerbatimFormatterTest :: ~VerbatimFormatterTest()
{
}