// Path: tests/org/udalov/jclang/TestUtils.java
// public static void createOrCompare(@NotNull String actual, @NotNull String expectedFileName) {
//     try {
//         String expected = loadFileContents(expectedFileName);
//         assertEquals(expected, actual);
//     }
//     catch (IOException e) {
//         try {
//             PrintWriter out = new PrintWriter(new File(expectedFileName));
//             out.print(actual);
//             out.close();
//             assertEquals("Expected file wasn't found, it will be created", "", actual);
//         }
//         catch (IOException ee) {
//             ee.printStackTrace();
//             fail(ee.getMessage());
//         }
//     }
// }


import junit.framework.TestSuite;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.List;
import static org.udalov.jclang.Diagnostic.DisplayOptions.DISPLAY_SOURCE_LOCATION;
import static org.udalov.jclang.TestUtils.createOrCompare;
/*
 * Copyright 2013 Alexander Udalov
 *
 * 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 org.udalov.jclang;




public class DiagnosticTest extends ClangTest {
    private final File file;
    private static final String EXPECTED_SUFFIX = ".expected";

    private DiagnosticTest(@NotNull File file) {
        this.file = file;
    }

    @Override
    protected void runTest() throws Throwable {
        Index index = Clang.INSTANCE.createIndex(false, false);
        TranslationUnit unit = index.parseTranslationUnit(file.getPath(), new String[]{});
        List<Diagnostic> diagnostics = unit.getDiagnostics();
        String actual = serializeDiagnostics(diagnostics);
// Path: tests/org/udalov/jclang/TestUtils.java
// public static void createOrCompare(@NotNull String actual, @NotNull String expectedFileName) {
//     try {
//         String expected = loadFileContents(expectedFileName);
//         assertEquals(expected, actual);
//     }
//     catch (IOException e) {
//         try {
//             PrintWriter out = new PrintWriter(new File(expectedFileName));
//             out.print(actual);
//             out.close();
//             assertEquals("Expected file wasn't found, it will be created", "", actual);
//         }
//         catch (IOException ee) {
//             ee.printStackTrace();
//             fail(ee.getMessage());
//         }
//     }
// }


// Path: tests/org/udalov/jclang/DiagnosticTest.java
import junit.framework.TestSuite;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.List;
import static org.udalov.jclang.Diagnostic.DisplayOptions.DISPLAY_SOURCE_LOCATION;
import static org.udalov.jclang.TestUtils.createOrCompare;

/*
 * Copyright 2013 Alexander Udalov
 *
 * 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 org.udalov.jclang;




public class DiagnosticTest extends ClangTest {
    private final File file;
    private static final String EXPECTED_SUFFIX = ".expected";

    private DiagnosticTest(@NotNull File file) {
        this.file = file;
    }

    @Override
    protected void runTest() throws Throwable {
        Index index = Clang.INSTANCE.createIndex(false, false);
        TranslationUnit unit = index.parseTranslationUnit(file.getPath(), new String[]{});
        List<Diagnostic> diagnostics = unit.getDiagnostics();
        String actual = serializeDiagnostics(diagnostics);
        createOrCompare(actual, file + EXPECTED_SUFFIX);