
package com.intellij.openapi.editor.actions;

import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
import org.jetbrains.annotations.NotNull;

/**
 * @author Denis Zhdanov
 */
public class CutLineBackwardActionTest extends LightPlatformCodeInsightTestCase {

  public void testZeroPosition() {
    String text = 
      "<caret>class Test {\n" +
      "}";
    doTest(text, text);
  }
  
  public void testNonZeroPositionOfFirstLine() {
    doTest(
      "class <caret>Test {\n" +
      "}",
      "<caret>Test {\n" +
      "}"
    );
  }
  
  public void testZeroPositionNonFirstLine() {
    doTest(
      "class Test {\n" +
      "<caret>    // This is comment string\n" +
      "}",
      "<caret>    // This is comment string\n" +
      "}"
    );
  }

  public void testNonZeroPositionNonFirstLine() {
    doTest(
      "class Test {\n" +
      "    // This is the comment string\n" +
      "    // <caret>int i;\n" +
      "}",
      "class Test {\n" +
      "<caret>int i;\n" +
      "}"
    );
  }
  
  private void doTest(@NotNull String before, @NotNull String after) {
    configureFromFileText(getTestName(false) + ".txt", before);
    cutLineBackward();
    checkResultByText(after);
  }
}
