forked from jline/jline3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NanoTest.java
37 lines (33 loc) · 1.26 KB
/
NanoTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* Copyright (c) 2002-2017, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
*
* https://opensource.org/licenses/BSD-3-Clause
*/
package org.jline.builtins;
import org.jline.keymap.KeyMap;
import org.jline.terminal.Size;
import org.jline.terminal.impl.LineDisciplineTerminal;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
public class NanoTest {
@Test(timeout = 1000)
public void nanoBufferLineOverflow() throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
LineDisciplineTerminal terminal = new LineDisciplineTerminal("nano", "xterm", output, StandardCharsets.UTF_8);
terminal.setSize(new Size(80, 25));
for (int i = 0; i < 100; i++) {
terminal.processInputByte(' ');
}
terminal.processInputByte(KeyMap.ctrl('X').getBytes()[0]);
terminal.processInputByte('n');
String[] argv = {"--ignorercfiles"};
Nano nano = new Nano(terminal, Paths.get("target/test.txt"), Options.compile(Nano.usage()).parse(argv));
nano.run();
}
}