package io.bit3.jsass;

import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;

import org.junit.Before;
import org.junit.Test;

public class PrecisionTest {

  private static final String scss = ".something {\n"
          + "  padding: 0 0.8em (5/7) 0.8em;\n"
          + "}";

  Compiler compiler;
  Options options;

  /**
   * Set up test defaults.
   */
  @Before
  public void init() {
    compiler = new Compiler();
    options = new Options();
    options.setOutputStyle(OutputStyle.COMPRESSED);
  }

  private Output getOutput(int precision) throws CompilationException {
    options.setPrecision(precision);
    return compiler.compileString(scss, options);
  }

  @Test
  public void testLowPrecisionOsX() throws CompilationException {
    Output output = getOutput(5);

    assertThat(output.getCss(), containsString("padding:0 0.8em 0.71429 0.8em"));
  }

  @Test
  public void testHighPrecisionOsX() throws CompilationException {
    Output output = getOutput(10);

    assertThat(output.getCss(), containsString("padding:0 0.8em 0.7142857143 0.8em"));
  }

  @Test
  public void testLowPrecisionLinux() throws CompilationException {
    Output output = getOutput(5);

    assertThat(output.getCss(), containsString("padding:0 0.8em .71429 0.8em"));
  }

  @Test
  public void testHighPrecisionLinux() throws CompilationException {
    Output output = getOutput(10);

    assertThat(output.getCss(), containsString("padding:0 0.8em .7142857143 0.8em"));
  }
}

@@ -73,16 +73,61 @@
 String;%0A
+import static org.hamcrest.CoreMatchers.not;%0A
 import s
@@ -888,32 +888,36 @@
 utput.getCss(), 
+not(
 containsString(%22
@@ -940,32 +940,33 @@
 0.71429 0.8em%22))
+)
 ;%0A  %7D%0A%0A  @Test%0A 
@@ -1091,32 +1091,36 @@
 utput.getCss(), 
+not(
 containsString(%22
@@ -1148,32 +1148,33 @@
 2857143 0.8em%22))
+)
 ;%0A  %7D%0A%0A  @Test%0A 

update tests