<?xml version="1.0" encoding="UTF-8"?>
<test-data
    xmlns="http://pmd.sourceforge.net/rule-tests"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">

    <test-code>
        <description>ok</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    void bar(int x) {
        switch(x) {
            case 1:
                break;
            default:
                break;
        }
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>bad</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    void bar(int x) {
        switch(x) {
            case 1:
                break;
            default:
                break;
            case 2:
                break;
        }
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>ok, no default</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    void bar(int x) {
        switch(x) {
            case 1:
                break;
            case 2:
                break;
        }
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>switch expression, ok</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    void bar(int x) {
        x = switch(x) {
            case 1: yield 1;
            default: yield -1;
        };
    }
}
]]></code>
    </test-code>

    <test-code>
        <description>switch expression, not ok</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    void bar(int x) {
        x = switch(x) {
            case 1: yield 1;
            default: yield -1;
            case 2: yield 2;
        };
    }
}
]]></code>
    </test-code>

    <test-code>
        <description>switch arrow, ok</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    void bar(int x) {
        switch(x) {
            case 1 -> System.out.println("a");
            default -> System.out.println("default");
        }
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>switch arrow, not ok</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    void bar(int x) {
        switch(x) {
            case 1 -> System.out.println("a");
            default -> System.out.println("default");
            case 2 -> System.out.println("b");
        }
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>switch with pattern and default case, ok</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    void barPattern(Object x) {
        x = switch(x) {
            case Integer i: yield 1;
            case null, default: yield -1;
        };
    }
}
]]></code>
    </test-code>
</test-data>
