// Path: src/adql-validator/src/cds/adql/validation/parser/ValidationSetParser.java
// public interface ValidationSetParser {
// 
//     /**
//      * Parses a set of ADQL validation queries.
//      *
//      * @param stream    The serialized queries set to parse.
//      *
//      * @return  The object representation of this queries set.
//      *
//      * @throws ParseException   In case of parsing error.
//      */
//     ValidationSet parse(final InputStream stream) throws ParseException;
// 
//     /** ADQL version set by default when none is specified.
//      * Generally it corresponds to the most recent ADQL version. */
//     ADQLVersion DEFAULT_ADQL_VERSION = ADQLVersion.V2_1;
// 
//     /** Regular expression for the version 2.1 of ADQL. */
//     Pattern PATTERN_ADQL_2_1 = Pattern.compile("^(adql-?)?v?2(.1)?$");
// 
//     /** Regular expression for the version 2.0 of ADQL. */
//     Pattern PATTERN_ADQL_2_0 = Pattern.compile("^(adql-?)?v?2.0$");
// 
//     /**
//      * Tell whether the given string represents an ADQL version.
//      *
//      * <p><i><b>Notes:</b>
//      *     This function is case IN-sensitive. Many variants are tested: with
//      *     or without <code>adql</code> prefix, <code>v</code> prefix, minor
//      *     release number suffix, ...
//      * </i></p>
//      *
//      * @param str   The string which may represent an ADQL version.
//      *
//      * @return  <code>true</code> if an ADQL version,
//      *          <code>false</code> otherwise.
//      *
//      * @see #PATTERN_ADQL_2_0
//      * @see #PATTERN_ADQL_2_1
//      */
//     static boolean matchesVersion(String str){
//         if (str == null || str.trim().length() == 0)
//             return false;
// 
//         // Normalize the input string:
//         str = str.trim().toLowerCase();
// 
//         // Try to resolve a version:
//         return PATTERN_ADQL_2_1.matcher(str).find()
//                 || PATTERN_ADQL_2_0.matcher(str).find();
//     }
// 
//     /**
//      * Parse the given ADQL version string serialization.
//      *
//      * <p><i><b>Notes:</b>
//      *     This function is case IN-sensitive. Many variants are tested: with
//      *     or without <code>adql</code> prefix, <code>v</code> prefix, minor
//      *     release number suffix, ...
//      * </i></p>
//      *
//      * @param str   The string serialization of an ADQL version.
//      *
//      * @return  The interpreted ADQL version,
//      *          or {@link #DEFAULT_ADQL_VERSION} if none is provided or if the
//      *          given string can not be resolved as an {@link ADQLVersion}.
//      */
//     static ADQLVersion parseVersion(String str){
//         if (str == null || str.trim().length() == 0)
//             return DEFAULT_ADQL_VERSION;
// 
//         // Normalize the input string:
//         str = str.trim().toLowerCase();
// 
//         // Parse and resolve the version as much as possible:
//         if (PATTERN_ADQL_2_1.matcher(str).find())
//             return ADQLVersion.V2_1;
//         else if (PATTERN_ADQL_2_0.matcher(str).find())
//             return ADQLVersion.V2_0;
//         else
//             return DEFAULT_ADQL_VERSION;
//     }
// 
// }


import static adql.parser.ADQLParser.ADQLVersion;
import static org.junit.jupiter.api.Assertions.*;
import cds.adql.validation.parser.ValidationSetParser;
import org.junit.jupiter.api.Test;
package cds.adql.validation.query;



public class ADQLVersionParsingTest {

    final String[] CORRECT_2_0 = new String[]{"2.0", "v2.0", "V2.0", "adql-2.0", "adql-v2.0", "Adql-V2.0", "ADQL-2.0"};
    final String[] CORRECT_2_1 = new String[]{"2.1", "2", "v2", "v2.1", "V2", "V2.1", "adql-2.1", "adql-v2.1", "adql-v2", "Adql-V2", "ADQL-2.1", "ADQL-v2.1"};

    @Test
    public void parseEmpty() {
        for(String s : new String[]{null, "", "  ", " \t\n "})
// Path: src/adql-validator/src/cds/adql/validation/parser/ValidationSetParser.java
// public interface ValidationSetParser {
// 
//     /**
//      * Parses a set of ADQL validation queries.
//      *
//      * @param stream    The serialized queries set to parse.
//      *
//      * @return  The object representation of this queries set.
//      *
//      * @throws ParseException   In case of parsing error.
//      */
//     ValidationSet parse(final InputStream stream) throws ParseException;
// 
//     /** ADQL version set by default when none is specified.
//      * Generally it corresponds to the most recent ADQL version. */
//     ADQLVersion DEFAULT_ADQL_VERSION = ADQLVersion.V2_1;
// 
//     /** Regular expression for the version 2.1 of ADQL. */
//     Pattern PATTERN_ADQL_2_1 = Pattern.compile("^(adql-?)?v?2(.1)?$");
// 
//     /** Regular expression for the version 2.0 of ADQL. */
//     Pattern PATTERN_ADQL_2_0 = Pattern.compile("^(adql-?)?v?2.0$");
// 
//     /**
//      * Tell whether the given string represents an ADQL version.
//      *
//      * <p><i><b>Notes:</b>
//      *     This function is case IN-sensitive. Many variants are tested: with
//      *     or without <code>adql</code> prefix, <code>v</code> prefix, minor
//      *     release number suffix, ...
//      * </i></p>
//      *
//      * @param str   The string which may represent an ADQL version.
//      *
//      * @return  <code>true</code> if an ADQL version,
//      *          <code>false</code> otherwise.
//      *
//      * @see #PATTERN_ADQL_2_0
//      * @see #PATTERN_ADQL_2_1
//      */
//     static boolean matchesVersion(String str){
//         if (str == null || str.trim().length() == 0)
//             return false;
// 
//         // Normalize the input string:
//         str = str.trim().toLowerCase();
// 
//         // Try to resolve a version:
//         return PATTERN_ADQL_2_1.matcher(str).find()
//                 || PATTERN_ADQL_2_0.matcher(str).find();
//     }
// 
//     /**
//      * Parse the given ADQL version string serialization.
//      *
//      * <p><i><b>Notes:</b>
//      *     This function is case IN-sensitive. Many variants are tested: with
//      *     or without <code>adql</code> prefix, <code>v</code> prefix, minor
//      *     release number suffix, ...
//      * </i></p>
//      *
//      * @param str   The string serialization of an ADQL version.
//      *
//      * @return  The interpreted ADQL version,
//      *          or {@link #DEFAULT_ADQL_VERSION} if none is provided or if the
//      *          given string can not be resolved as an {@link ADQLVersion}.
//      */
//     static ADQLVersion parseVersion(String str){
//         if (str == null || str.trim().length() == 0)
//             return DEFAULT_ADQL_VERSION;
// 
//         // Normalize the input string:
//         str = str.trim().toLowerCase();
// 
//         // Parse and resolve the version as much as possible:
//         if (PATTERN_ADQL_2_1.matcher(str).find())
//             return ADQLVersion.V2_1;
//         else if (PATTERN_ADQL_2_0.matcher(str).find())
//             return ADQLVersion.V2_0;
//         else
//             return DEFAULT_ADQL_VERSION;
//     }
// 
// }


// Path: src/adql-validator/test/cds/adql/validation/query/ADQLVersionParsingTest.java
import static adql.parser.ADQLParser.ADQLVersion;
import static org.junit.jupiter.api.Assertions.*;
import cds.adql.validation.parser.ValidationSetParser;
import org.junit.jupiter.api.Test;

package cds.adql.validation.query;



public class ADQLVersionParsingTest {

    final String[] CORRECT_2_0 = new String[]{"2.0", "v2.0", "V2.0", "adql-2.0", "adql-v2.0", "Adql-V2.0", "ADQL-2.0"};
    final String[] CORRECT_2_1 = new String[]{"2.1", "2", "v2", "v2.1", "V2", "V2.1", "adql-2.1", "adql-v2.1", "adql-v2", "Adql-V2", "ADQL-2.1", "ADQL-v2.1"};

    @Test
    public void parseEmpty() {
        for(String s : new String[]{null, "", "  ", " \t\n "})
            assertEquals(ValidationSetParser.DEFAULT_ADQL_VERSION, ValidationSetParser.parseVersion(s));