// Empty mutations
{
// This is an strange edge case, but might as well cover it
doc = Document.createFromString("");
DocOp actual = delete(0, 0, 0);
DocOp expected = builder.rl(1).b();
assertDocOpEquals(expected, actual);
}
{
// This is an strange edge case, but might as well cover it
doc = Document.createFromString("");
DocOp actual = insert(0, 0, "");
DocOp expected = builder.rl(1).b();
assertDocOpEquals(expected, actual);
}
// Mutations without newlines
{
// Ensure no RL
doc = Document.createFromString("");
DocOp actual = insert(0, 0, "a");
DocOp expected = builder.i("a").b();
assertDocOpEquals(expected, actual);
}
{
doc = Document.createFromString("a");
DocOp actual = delete(0, 0, 1);
DocOp expected = builder.d("a").rl(1).b();
assertDocOpEquals(expected, actual);
}
// One/two-line documents and mutations with newlines
{
doc = Document.createFromString("");
DocOp actual = insert(0, 0, "\n");
DocOp expected = builder.i("\n").rl(1).b();
assertDocOpEquals(expected, actual);
}
{
doc = Document.createFromString("\n");
DocOp actual = delete(0, 0, 1);
DocOp expected = builder.d("\n").rl(1).b();
assertDocOpEquals(expected, actual);
}
// Multiple line documents
{
doc = Document.createFromString("\n\n");
DocOp actual = insert(0, 0, "\n");
DocOp expected = builder.i("\n").eolR(1).rl(2).b();
assertDocOpEquals(expected, actual);
}
{
doc = Document.createFromString("\n\n");
DocOp actual = insert(0, 0, "\n\n");
DocOp expected = builder.i("\n").i("\n").eolR(1).rl(2).b();
assertDocOpEquals(expected, actual);
}
{
doc = Document.createFromString("\n\n");
DocOp actual = delete(0, 0, 1);
DocOp expected = builder.d("\n").eolR(1).rl(1).b();
assertDocOpEquals(expected, actual);
}
{
doc = Document.createFromString("\n\n");
DocOp actual = delete(0, 0, 2);
DocOp expected = builder.d("\n").d("\n").rl(1).b();
assertDocOpEquals(expected, actual);
}
// Misc
{
doc = Document.createFromString("a\n");
DocOp actual = insert(0, 0, "a");
DocOp expected = builder.i("a").eolR(2).rl(1).b();
assertDocOpEquals(expected, actual);
}
}