<commit_before>/*
 * Copyright 2013 <NAME>, <NAME>, <NAME>
 *
 * 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 uk.org.raje.maven.plugin.msbuild.parser;

import static org.junit.Assert.assertEquals;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.ParseException;
import java.util.Arrays;

import javax.xml.parsers.ParserConfigurationException;

import org.junit.Assert;
import org.junit.Test;
import org.xml.sax.SAXException;

/**
 * Test CppCheckMojo configuration options.
 */
public class VCProjectParserTest
{
    @Test
    public void testSinglePlatformSingleConfigProprocessorDefs()
    {
        testProject( TEST_PROJECT_PREPROCESSOR_DEFS, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[0], 
                TEST_PREPROCESSOR_DEFS[0][0], new File[0] );
    }

    @Test
    public void testSinglePlatformMultipleConfigProprocessorDefs()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            testProject( TEST_PROJECT_PREPROCESSOR_DEFS, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    TEST_PREPROCESSOR_DEFS[0][i], new File[0] );
        }
    }

    @Test
    public void testMultiplePlatformSingleConfigProprocessorDefs()
    {
        for ( int i = 0; i < TEST_PLATFORMS.length; i++ )
        {
            testProject( TEST_PROJECT_PREPROCESSOR_DEFS, TEST_PLATFORMS[i], TEST_CONFIGURATIONS[0], 
                    TEST_PREPROCESSOR_DEFS[i][0], new File[0] );
        }
    }
    
    @Test
    public void testSinglePlatformSingleConfigIncludeDirs()
    {
        testProject( TEST_PROJECT_INCLUDE_DIRS, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[0], 
                new String[0], TEST_INCLUDE_DIRS[0][0] );
    }

    @Test
    public void testSinglePlatformMultipleConfigIncludeDirs()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            testProject( TEST_PROJECT_INCLUDE_DIRS, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    new String[0], TEST_INCLUDE_DIRS[0][i] );
        }
    }

    @Test
    public void testMultiplePlatformSingleConfigIncludeDirs()
    {
        for ( int i = 0; i < TEST_PLATFORMS.length; i++ )
        {
            testProject( TEST_PROJECT_INCLUDE_DIRS, TEST_PLATFORMS[i], TEST_CONFIGURATIONS[0], 
                    new String[0], TEST_INCLUDE_DIRS[i][0] );
        }
    }    

    @Test
    public void testEmptyConfigSetting()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            testProject( TEST_PROJECT_EMPTY_SETTINGS, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    new String[0], new File[0] );
        }
    }    

    @Test
    public void testOutDefaultDir()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            VCProject vcProject = testProject( TEST_PROJECT_OUTDIR_DEFAULT, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    TEST_PREPROCESSOR_DEFS[0][i], new File[0] );
            assertEquals( new File( vcProject.getProjectFile().getParent(), TEST_CONFIGURATIONS[i] ),
                    vcProject.getOutputDirectory() );
        }
    }

    @Test
    public void testOutDir()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            VCProject vcProject = testProject( TEST_PROJECT_OUTDIR_SET, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    TEST_PREPROCESSOR_DEFS[0][i], new File[0] );
            assertEquals( new File( vcProject.getProjectFile().getParentFile(), "Runtime\\" + TEST_CONFIGURATIONS[i] ),
                    vcProject.getOutputDirectory() );
        }
    }

    /**
     * Test OutDir with older style layout in project file.
     */
    @Test
    public void testOutDir2()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            VCProject vcProject = testProject( TEST_PROJECT_OUTDIR2_SET, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    TEST_PREPROCESSOR_DEFS[0][i], new File[0] );
            assertEquals( new File( vcProject.getProjectFile().getParentFile(), 
                    "Runtime\\" + TEST_PLATFORMS[0] + "\\" + TEST_CONFIGURATIONS[i] ),
                    vcProject.getOutputDirectory() );
        }
    }
    
    @Test
    public void testRelativeOutDir()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            VCProject vcProject = testProject( TEST_PROJECT_RELATIVE_OUTDIR_SET, 
                    TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    TEST_PREPROCESSOR_DEFS[0][i], new File[0] );
            assertEquals( new File( vcProject.getProjectFile().getParentFile(), ".\\" + TEST_CONFIGURATIONS[i] ),<commit_msg>Add test for old project file format with a solution file.<commit_after>/*
 * Copyright 2013 <NAME>, <NAME>, <NAME>
 *
 * 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 uk.org.raje.maven.plugin.msbuild.parser;

import static org.junit.Assert.assertEquals;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.ParseException;
import java.util.Arrays;

import javax.xml.parsers.ParserConfigurationException;

import org.junit.Assert;
import org.junit.Test;
import org.xml.sax.SAXException;

/**
 * Test CppCheckMojo configuration options.
 */
public class VCProjectParserTest
{
    @Test
    public void testSinglePlatformSingleConfigProprocessorDefs()
    {
        testProject( TEST_PROJECT_PREPROCESSOR_DEFS, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[0], 
                TEST_PREPROCESSOR_DEFS[0][0], new File[0] );
    }

    @Test
    public void testSinglePlatformMultipleConfigProprocessorDefs()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            testProject( TEST_PROJECT_PREPROCESSOR_DEFS, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    TEST_PREPROCESSOR_DEFS[0][i], new File[0] );
        }
    }

    @Test
    public void testMultiplePlatformSingleConfigProprocessorDefs()
    {
        for ( int i = 0; i < TEST_PLATFORMS.length; i++ )
        {
            testProject( TEST_PROJECT_PREPROCESSOR_DEFS, TEST_PLATFORMS[i], TEST_CONFIGURATIONS[0], 
                    TEST_PREPROCESSOR_DEFS[i][0], new File[0] );
        }
    }
    
    @Test
    public void testSinglePlatformSingleConfigIncludeDirs()
    {
        testProject( TEST_PROJECT_INCLUDE_DIRS, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[0], 
                new String[0], TEST_INCLUDE_DIRS[0][0] );
    }

    @Test
    public void testSinglePlatformMultipleConfigIncludeDirs()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            testProject( TEST_PROJECT_INCLUDE_DIRS, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    new String[0], TEST_INCLUDE_DIRS[0][i] );
        }
    }

    @Test
    public void testMultiplePlatformSingleConfigIncludeDirs()
    {
        for ( int i = 0; i < TEST_PLATFORMS.length; i++ )
        {
            testProject( TEST_PROJECT_INCLUDE_DIRS, TEST_PLATFORMS[i], TEST_CONFIGURATIONS[0], 
                    new String[0], TEST_INCLUDE_DIRS[i][0] );
        }
    }    

    @Test
    public void testEmptyConfigSetting()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            testProject( TEST_PROJECT_EMPTY_SETTINGS, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    new String[0], new File[0] );
        }
    }    

    @Test
    public void testOutDefaultDir()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            VCProject vcProject = testProject( TEST_PROJECT_OUTDIR_DEFAULT, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    TEST_PREPROCESSOR_DEFS[0][i], new File[0] );
            assertEquals( new File( vcProject.getProjectFile().getParent(), TEST_CONFIGURATIONS[i] ),
                    vcProject.getOutputDirectory() );
        }
    }

    @Test
    public void testOutDir()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            VCProject vcProject = testProject( TEST_PROJECT_OUTDIR_SET, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    TEST_PREPROCESSOR_DEFS[0][i], new File[0] );
            assertEquals( new File( vcProject.getProjectFile().getParentFile(), "Runtime\\" + TEST_CONFIGURATIONS[i] ),
                    vcProject.getOutputDirectory() );
        }
    }

    /**
     * Test OutDir with older style layout in project file.
     */
    @Test
    public void testOutDir2()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            VCProject vcProject = testProject( TEST_PROJECT_OUTDIR2_SET, TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    TEST_PREPROCESSOR_DEFS[0][i], new File[0] );
            assertEquals( new File( vcProject.getProjectFile().getParentFile(), 
                    "Runtime\\" + TEST_PLATFORMS[0] + "\\" + TEST_CONFIGURATIONS[i] ),
                    vcProject.getOutputDirectory() );
        }
    }

    /**
     * As {@link #testOutDir2()} but including a solution file
     */
    @Test
    public void testOutDir2WithSolution()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            VCProject vcProject = testProject( TEST_PROJECT_OUTDIR2_SET, TEST_CONFIG_SOLUTION, 
                    TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    TEST_PREPROCESSOR_DEFS[0][i], new File[0] );
            assertEquals( new File( vcProject.getProjectFile().getParentFile().getParentFile(), 
                    "Runtime\\" + TEST_PLATFORMS[0] + "\\" + TEST_CONFIGURATIONS[i] ),
                    vcProject.getOutputDirectory() );
        }
    }
    
    @Test
    public void testRelativeOutDir()
    {
        for ( int i = 0; i < TEST_CONFIGURATIONS.length; i++ )
        {
            VCProject vcProject = testProject( TEST_PROJECT_RELATIVE_OUTDIR_SET, 
                    TEST_PLATFORMS[0], TEST_CONFIGURATIONS[i], 
                    TEST_PREPROCESSOR_DEFS[0][i], new File[0] );
            assertEquals( new File( vcProject.getProjectFile().getParentFile(), ".\\" + TEST_CONFIGURATIONS[i] ),
{'fraction_non_alphanumeric': 0.1032487761459724, 'fraction_numerical': 0.010858923008455718, 'mean_word_length': 2.4970432617491443, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2021339', 'n_tokens_mistral': 3611, 'n_tokens_neox': 3409, 'n_words': 731}