package sds.util;

import org.junit.Test;
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.is;

import static sds.util.AccessFlags.*;

public class AccessFlagsTest {
	@Test
	public void getTest() {
		// class and nested.
		assertThat(get(ACC_PUBLIC | ACC_FINAL | ACC_SYNTHETIC | ACC_INTERFACE, "class")
				, is("public final synthetic interface "));
		assertThat(get(ACC_PUBLIC | ACC_FINAL | ACC_ENUM, "class")
				, is("public final enum "));
		assertThat(get(ACC_PUBLIC | ACC_ANNOTATION, "class")
				, is("public @interface "));
		assertThat(get(ACC_PUBLIC | ACC_STATIC | ACC_FINAL, "class")
				, is(" >>> unknown access flag <<<"));
		assertThat(get(ACC_PUBLIC | ACC_FINAL | ACC_STATIC, "nested")
				, is("public static final class "));

		// field.
		assertThat(
				get(ACC_PUBLIC | ACC_FINAL | ACC_STATIC | ACC_VOLATILE
						| ACC_TRANSIENT | ACC_SYNTHETIC | ACC_ENUM
					, "field")
				, is("public static final volatile transient synthetic enum "));
		assertThat(get(ACC_PRIVATE | ACC_FINAL | ACC_STATIC, "field"), is("private static final "));
		assertThat(get(ACC_PROTECTED | ACC_FINAL, "field"), is("protected final "));
		assertThat(get(ACC_PROTECTED | ACC_FINAL | ACC_INTERFACE, "field")
				, is(" >>> unknown access flag <<<"));

		// method
		assertThat(
				get(ACC_PUBLIC | ACC_FINAL | ACC_STATIC | ACC_SYNCHRONIZED | ACC_SYNTHETIC
						| ACC_BRIDGE | ACC_NATIVE | ACC_ABSTRACT | ACC_STRICT 
					, "method")
				, is("public static final synchronized bridge native abstract strict synthetic "));
		assertThat(get(ACC_PRIVATE | ACC_FINAL | ACC_STATIC | ACC_ANNOTATION, "method")
				, is(" >>> unknown access flag <<<"));
	}
}
test AccessFlags class.