package com.jetbrains.python;

import com.intellij.openapi.util.io.FileUtil;
import com.intellij.testFramework.UsefulTestCase;
import com.jetbrains.python.console.PyConsoleIndentUtil;

import java.io.File;
import java.io.IOException;

/**
 * @author traff
 */
public class PyConsoleIndentTest extends UsefulTestCase {
  public void testIndent1() {
    doTest();
  }

  public void testIndent2() {
    doTest();
  }

  public void testIndent3() {
    doTest();
  }

  public void testIndent4() {
    doTest();
  }

  public void testIndent5() {
    doTest();
  }

  public void testIndent6() {
    doTest();
  }

  public void testIndent7() {
    doTest(2);
  }

  private void doTest() {
    doTest(0);
  }

  private void doTest(int indent) {
    String name = getTestName(true);
    try {
      String fileText = FileUtil.loadFile(new File(getTestDataPath() + name + ".py"));
      String expected = FileUtil.loadFile(new File(getTestDataPath() + name + ".after.py"));
      assertEquals(expected, PyConsoleIndentUtil.normalize(fileText, indent));
    }
    catch (IOException e) {
      throw new RuntimeException(e);
    }
  }

  public static String getTestDataPath() {
    return PythonTestUtil.getTestDataPath() + "/console/";
  }
}


@@ -70,16 +70,66 @@
 leUtil;%0A
+import com.intellij.openapi.util.text.StringUtil;%0A
 import c
@@ -1033,24 +1033,57 @@
 tEquals(
+StringUtil.convertLineSeparators(
 expected
 , PyCons
@@ -1074,17 +1074,60 @@
 expected
+)
 ,
+ StringUtil.convertLineSeparators(%0A       
  PyConso
@@ -1167,16 +1167,17 @@
 indent))
+)
 ;%0A    %7D%0A

Convert line separators in test.