Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Add failing test, demonstrating the offset with swedish characters #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/CursorTest.re
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ let input = s => ignore(Vim.input(s));
describe("Cursor", ({describe, _}) => {
describe("setLocation", ({test, _}) => {
test("cursor location gets updated", ({expect}) => {
let _ = resetBuffer();

Cursor.setLocation(~line=Index.zero, ~column=Index.(zero + 1));
expect.int((Cursor.getLine() :> int)).toBe(0);
expect.int((Cursor.getColumn() :> int)).toBe(1);
Expand Down
47 changes: 47 additions & 0 deletions test/CursorTestSwedish.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
open EditorCoreTypes;
open Vim;
open TestFramework;

let resetBuffer = () => Helpers.resetBuffer("test/testfile_swedish.txt");
let input = s => ignore(Vim.input(s));

describe("Cursor with Swedish characters", ({describe, _}) => {
describe("normal mode", ({test, _}) => {
test("l over a swedish character", ({expect}) => {
let _ = resetBuffer();

let cursorMoves: ref(list(Location.t)) = ref([]);
let dispose = Cursor.onMoved(p => cursorMoves := [p, ...cursorMoves^]);

expect.int((Cursor.getLine() :> int)).toBe(0);
expect.int((Cursor.getColumn() :> int)).toBe(0);
expect.int(List.length(cursorMoves^)).toBe(0);

input("l");

expect.int((Cursor.getLine() :> int)).toBe(0);
expect.int((Cursor.getColumn() :> int)).toBe(1);

dispose();
});

test("l without swedish characters", ({expect}) => {
let _ = resetBuffer();

let cursorMoves: ref(list(Location.t)) = ref([]);
let dispose = Cursor.onMoved(p => cursorMoves := [p, ...cursorMoves^]);

expect.int((Cursor.getLine() :> int)).toBe(0);
expect.int((Cursor.getColumn() :> int)).toBe(0);
expect.int(List.length(cursorMoves^)).toBe(0);

input("j");
input("l");

expect.int((Cursor.getLine() :> int)).toBe(1);
expect.int((Cursor.getColumn() :> int)).toBe(1);

dispose();
});
});
});
2 changes: 2 additions & 0 deletions test/testfile_swedish.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
äbcdefgeh
abcdefgeh