package org.asciidoctor.asciidoclet;

import com.google.common.base.Charsets;
import org.junit.Test;

import java.nio.charset.Charset;

import static org.junit.Assert.*;
import static org.asciidoctor.asciidoclet.DocletOptions.*;

public class DocletOptionsTest {

    @Test
    public void testGetBaseDir(){
        assertFalse(DocletOptions.NONE.includeBasedir().isPresent());
        assertEquals("test", new DocletOptions(new String[][]{{INCLUDE_BASEDIR, "test"}}).includeBasedir().get().getName());
    }

    @Test
    public void testEncoding() {
        assertEquals(Charset.defaultCharset(), DocletOptions.NONE.encoding());
        assertEquals(Charsets.UTF_8, new DocletOptions(new String[][]{{ENCODING, "UTF-8"}}).encoding());
        assertEquals(Charsets.US_ASCII, new DocletOptions(new String[][]{{ENCODING, "US-ASCII"}}).encoding());
        assertEquals(Charsets.ISO_8859_1, new DocletOptions(new String[][]{{ENCODING, "ISO-8859-1"}}).encoding());
    }

    @Test
    public void testOverview() {
        assertFalse(DocletOptions.NONE.overview().isPresent());
        assertEquals("test.adoc", new DocletOptions(new String[][]{{OVERVIEW, "test.adoc"}}).overview().get().getName());
    }

    @Test
    public void testStylesheetFile() {
        assertFalse(DocletOptions.NONE.stylesheetFile().isPresent());
        assertEquals("foo.css", new DocletOptions(new String[][]{{STYLESHEETFILE, "foo.css"}}).stylesheetFile().get().getName());
    }

    @Test
    public void testDestDir() {
        assertFalse(DocletOptions.NONE.destDir().isPresent());
        assertEquals("target", new DocletOptions(new String[][]{{DESTDIR, "target"}}).destDir().get().getName());
    }
}

@@ -163,16 +163,55 @@
 sert.*;%0A
+import static org.hamcrest.Matchers.*;%0A
 import s
@@ -1718,11 +1718,250 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testRequires() %7B%0A        assertTrue(DocletOptions.NONE.requires().isEmpty());%0A        assertThat(new DocletOptions(new String%5B%5D%5B%5D%7B%7BREQUIRES, %22foo%22%7D, %7BREQUIRES, %22bar%22%7D%7D).requires(), contains(%22foo%22, %22bar%22));%0A    %7D
 %0A%7D%0A

Test for multiple occurrences of "-r" option.