package net.sf.jabref.logic.formatter.casechanger;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

/**
 * Tests in addition to the general tests from {@link net.sf.jabref.logic.formatter.FormatterTest}
 */
public class TitleCaseFormatterTest {

    private TitleCaseFormatter formatter;

    @Before
    public void setUp() {
        formatter = new TitleCaseFormatter();
    }

    @Test
    public void test() {
        Assert.assertEquals("Upper Each First", formatter.format("upper each first"));
        Assert.assertEquals("An Upper Each First And", formatter.format("an upper each first and"));
        Assert.assertEquals("An Upper Each of the and First And",
                formatter.format("an upper each of the and first and"));
        Assert.assertEquals("An Upper Each of: The and First And",
                formatter.format("an upper each of: the and first and"));
        Assert.assertEquals("An Upper First with and without {CURLY} {brackets}",
                formatter.format("AN UPPER FIRST WITH AND WITHOUT {CURLY} {brackets}"));
        Assert.assertEquals("An Upper First with {A}nd without {C}urly {b}rackets",
                formatter.format("AN UPPER FIRST WITH {A}ND WITHOUT {C}URLY {b}rackets"));
    }

    @Test
    public void formatExample() {
        Assert.assertEquals("{BPMN} Conformance in Open Source Engines", formatter.format(formatter.getExampleInput()));
    }
}

@@ -425,20 +425,43 @@
 ic void 
-test
+eachFirstLetterIsUppercased
 () %7B%0A   
@@ -552,243 +552,1111 @@
     
-    Assert.assertEquals(%22An Upper Each First And%22, formatter.format(%22an upper each first and%22));%0A        Assert.assertEquals(%22An Upper Each of the and First And%22,%0A                formatter.format(%22an upper each of the and first and%22));
+%7D%0A%0A    @Test%0A    public void eachFirstLetterIsUppercasedAndOthersLowercased() %7B%0A        Assert.assertEquals(%22Upper Each First%22, formatter.format(%22upper eACH first%22));%0A    %7D%0A%0A    @Test%0A    public void eachFirstLetterIsUppercasedAndATralingAndIsAlsoUppercased() %7B%0A        Assert.assertEquals(%22An Upper Each First And%22, formatter.format(%22an upper each first and%22));%0A    %7D%0A%0A    @Test%0A    public void eachFirstLetterIsUppercasedAndATralingAndIsAlsoCorrectlyCased() %7B%0A        Assert.assertEquals(%22An Upper Each First And%22, formatter.format(%22an upper each first AND%22));%0A    %7D%0A%0A    @Test%0A    public void eachFirstLetterIsUppercasedButIntermediateAndsAreKeptLowercase()%7B%0A        Assert.assertEquals(%22An Upper Each of the and First And%22,%0A                formatter.format(%22an upper each of the and first and%22));%0A    %7D%0A%0A    @Test%0A    public void eachFirstLetterIsUppercasedButIntermediateAndsArePutLowercase()%7B%0A        Assert.assertEquals(%22An Upper Each of the and First And%22,%0A                formatter.format(%22an upper each of the AND first and%22));%0A    %7D%0A%0A    @Test%0A    public void theAfterColonGetsCapitalized() %7B
 %0A   
@@ -1789,24 +1789,105 @@
 rst and%22));%0A
+    %7D%0A%0A    @Test%0A    public void completeWordsInCurlyBracketsIsLeftUnchanged() %7B%0A
         Asse
@@ -2041,24 +2041,99 @@
 ackets%7D%22));%0A
+    %7D%0A%0A    @Test%0A    public void lettersInCurlyBracketsIsLeftUnchanged() %7B%0A
         Asse
@@ -2294,32 +2294,492 @@
 kets%22));%0A    %7D%0A%0A
+    @Test%0A    public void intraWordLettersInCurlyBracketsIsLeftUnchanged() %7B%0A        Assert.assertEquals(%22%7Bb%7Drackets %7Bb%7Drac%7BK%7Dets Brack%7BE%7Dts%22,%0A                formatter.format(%22%7Bb%7DRaCKeTS %7Bb%7DRaC%7BK%7DeTS bRaCK%7BE%7Dts%22));%0A    %7D%0A%0A    @Test%0A    public void testTwoExperiencesTitle() %7B%0A        Assert.assertEquals(%0A            %22Two Experiences Designing for Effective Security%22,%0A            formatter.format(%22Two experiences designing for effective security%22));%0A    %7D%0A%0A
     @Test%0A    pu
@@ -2933,10 +2933,11 @@
 ;%0A    %7D%0A
+%0A
 %7D%0A

Improve TitleCaseFormatterTest (#2178)