package io.github.classgraph.features;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.Test;

import io.github.classgraph.ClassGraph;
import io.github.classgraph.ClassInfo;
import io.github.classgraph.ScanResult;

/**
 * Test.
 */
public class EnumTest {
    /** Enum */
    private static enum MyEnum {
        A, B, C;
    }

    /** Test */
    @Test
    public void enumConsts() throws Exception {
        try (ScanResult scanResult = new ClassGraph().acceptClasses(MyEnum.class.getName()).enableAllInfo()
                .scan()) {
            assertThat(scanResult.getAllEnums().size() == 1);
            final ClassInfo myEnum = scanResult.getAllEnums().get(0);
            assertThat(myEnum.getName().equals(MyEnum.class.getName()));
            assertThat(myEnum.getEnumConstants().getNames()).containsExactly("A", "B", "C");
        }
    }
}

@@ -297,17 +297,25 @@
     /** 
-E
+Regular e
 num */%0A 
@@ -343,16 +343,29 @@
 m MyEnum
+WithoutMethod
  %7B%0A     
@@ -391,56 +391,871 @@
     
-/** Test */%0A    @Test%0A    public void enumConsts
+private static enum EnumWithMethod %7B%0A        P(1), Q(2);%0A%0A        int val;%0A%0A        EnumWithMethod(final int val) %7B%0A            this.val = val;%0A        %7D%0A%0A        int getVal() %7B%0A            return val;%0A        %7D%0A    %7D;%0A%0A    /** Test regular enum */%0A    @Test%0A    public void enumWithoutMethod() throws Exception %7B%0A        try (ScanResult scanResult = new ClassGraph().acceptClasses(MyEnumWithoutMethod.class.getName())%0A                .enableAllInfo().scan()) %7B%0A            assertThat(scanResult.getAllEnums().size() == 1);%0A            final ClassInfo myEnum = scanResult.getAllEnums().get(0);%0A            assertThat(myEnum.getName().equals(MyEnumWithoutMethod.class.getName()));%0A            assertThat(myEnum.getEnumConstants().getNames()).containsExactly(%22A%22, %22B%22, %22C%22);%0A        %7D%0A    %7D%0A%0A    /** Test enum with method */%0A    @Test%0A    public void enumWithMethod
 () t
@@ -1340,22 +1340,30 @@
 Classes(
-My
 Enum
+WithMethod
 .class.g
@@ -1594,22 +1594,30 @@
 .equals(
-My
 Enum
+WithMethod
 .class.g
@@ -1702,36 +1702,241 @@
 insExactly(%22
-A
+P
 %22, %22
-B%22, %22C%22
+Q%22);%0A            assertThat(((EnumWithMethod) myEnum.getEnumConstantObjects().get(0)).getVal()).isEqualTo(1);%0A            assertThat(((EnumWithMethod) myEnum.getEnumConstantObjects().get(1)).getVal()).isEqualTo(2
 );%0A        %7D

Improve test