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/VerbatimFormatterTest.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
112 lines (98 sloc)
2.5 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 "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() | |
{ | |
} |