/*
 * Copyright 2012 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.errorprone.bugpatterns;

import com.google.errorprone.CompilationTestHelper;

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

import java.io.File;

/**
 * Test cases for {@link LongLiteralLowerCaseSuffix}.
 *
 * @author Simon Nickerson (sjnickerson@google.com)
 */
public class LongLiteralLowerCaseSuffixTest {

  private CompilationTestHelper compilationHelper;

  @Before
  public void setUp() {
    compilationHelper = new CompilationTestHelper(new LongLiteralLowerCaseSuffix.Scanner());
  }

  @Test
  public void testPositiveCase() throws Exception {
    compilationHelper.assertCompileFailsWithMessages(
        new File(
            this.getClass().getResource("LongLiteralLowerCaseSuffixPositiveCase1.java").toURI()));
  }

  /**
   * Test for Java 7 integer literals that include underscores.
   */
  @Test
  public void testJava7PositiveCase() throws Exception {
    String[] javaVersion = System.getProperty("java.version").split("\\.");
    if (Integer.parseInt(javaVersion[1]) >= 7) {
      compilationHelper.assertCompileFailsWithMessages(
          new File(
              this.getClass().getResource("LongLiteralLowerCaseSuffixPositiveCase2.java").toURI()));
    }
  }

  @Test
  public void testNegativeCase() throws Exception {
    compilationHelper.assertCompileSucceeds(
        new File(
            this.getClass().getResource("LongLiteralLowerCaseSuffixNegativeCases.java").toURI()));
  }
}

@@ -654,16 +654,60 @@
 terns;%0A%0A
+import static org.junit.Assume.assumeTrue;%0A%0A
 import c
@@ -1631,11 +1631,18 @@
     
-if 
+assumeTrue
 (Int
@@ -1676,21 +1676,19 @@
 %5D) %3E= 7)
- %7B%0A  
+;%0A%0A
     comp
@@ -1737,26 +1737,24 @@
 es(%0A        
-  
 new File(%0A  
@@ -1743,34 +1743,32 @@
       new File(%0A
-  
             this
@@ -1854,14 +1854,8 @@
 ));%0A
-    %7D%0A
   %7D%0A

Use assumeTrue() to let JUnit know this test is specific to Java 7.