Skip to content

Commit

Permalink
Added test for #68
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Jun 9, 2021
1 parent 4ba5eaa commit 12faf63
Showing 1 changed file with 92 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.List;

import org.junit.Test;

import com.helger.commons.collection.impl.ICommonsList;
import com.helger.css.ECSSVersion;
import com.helger.css.decl.CSSDeclaration;
import com.helger.css.property.ECSSProperty;
Expand Down Expand Up @@ -56,7 +55,7 @@ public void testBorder1 ()
final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString ("border:1px", ECSSVersion.CSS30).getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (3, aSplittedDecls.size ());
assertEquals ("border-width:1px", aSplittedDecls.get (0).getAsCSSString (CWS));
Expand All @@ -73,7 +72,7 @@ public void testBorder2 ()
final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString ("border:1px dashed", ECSSVersion.CSS30).getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (3, aSplittedDecls.size ());
assertEquals ("border-width:1px", aSplittedDecls.get (0).getAsCSSString (CWS));
Expand All @@ -91,7 +90,7 @@ public void testBorder3a ()
.getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (3, aSplittedDecls.size ());
assertEquals ("border-style:dashed", aSplittedDecls.get (0).getAsCSSString (CWS));
Expand All @@ -109,7 +108,7 @@ public void testBorder3b ()
.getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (3, aSplittedDecls.size ());
assertEquals ("border-color:red", aSplittedDecls.get (0).getAsCSSString (CWS));
Expand All @@ -126,7 +125,7 @@ public void testMargin1 ()
final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString ("margin:1px", ECSSVersion.CSS30).getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (4, aSplittedDecls.size ());

Expand All @@ -145,7 +144,7 @@ public void testMargin2 ()
final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString ("margin:1px 3px", ECSSVersion.CSS30).getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (4, aSplittedDecls.size ());

Expand All @@ -165,7 +164,7 @@ public void testMargin3 ()
.getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (4, aSplittedDecls.size ());

Expand All @@ -185,7 +184,7 @@ public void testMargin4 ()
.getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (4, aSplittedDecls.size ());

Expand All @@ -204,7 +203,7 @@ public void testPadding1 ()
final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString ("padding:1px", ECSSVersion.CSS30).getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (4, aSplittedDecls.size ());

Expand All @@ -223,7 +222,7 @@ public void testPadding2 ()
final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString ("padding:1px 3px", ECSSVersion.CSS30).getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (4, aSplittedDecls.size ());

Expand All @@ -243,7 +242,7 @@ public void testPadding3 ()
.getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (4, aSplittedDecls.size ());

Expand All @@ -263,7 +262,7 @@ public void testPadding4 ()
.getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (4, aSplittedDecls.size ());

Expand All @@ -284,7 +283,7 @@ public void testBackground1 ()
.getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (8, aSplittedDecls.size ());

Expand All @@ -307,7 +306,7 @@ public void testBorderColor1 ()
final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString ("border-color: red", ECSSVersion.CSS30).getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (4, aSplittedDecls.size ());
assertEquals ("border-top-color:red", aSplittedDecls.get (0).getAsCSSString (CWS));
Expand All @@ -326,12 +325,88 @@ public void testBorderColor2 ()
.getDeclarationAtIndex (0);
assertNotNull (aDecl);

final List <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (4, aSplittedDecls.size ());
assertEquals ("border-top-color:red", aSplittedDecls.get (0).getAsCSSString (CWS));
assertEquals ("border-right-color:blue", aSplittedDecls.get (1).getAsCSSString (CWS));
assertEquals ("border-bottom-color:red", aSplittedDecls.get (2).getAsCSSString (CWS));
assertEquals ("border-left-color:blue", aSplittedDecls.get (3).getAsCSSString (CWS));
}

@Test
public void testBorderWidth1 ()
{
final CSSShortHandDescriptor aSHD = CSSShortHandRegistry.getShortHandDescriptor (ECSSProperty.BORDER_WIDTH);
assertNotNull (aSHD);

final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString ("border-width: thick", ECSSVersion.CSS30)
.getDeclarationAtIndex (0);
assertNotNull (aDecl);

final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (4, aSplittedDecls.size ());
assertEquals ("border-top-width:thick", aSplittedDecls.get (0).getAsCSSString (CWS));
assertEquals ("border-right-width:thick", aSplittedDecls.get (1).getAsCSSString (CWS));
assertEquals ("border-bottom-width:thick", aSplittedDecls.get (2).getAsCSSString (CWS));
assertEquals ("border-left-width:thick", aSplittedDecls.get (3).getAsCSSString (CWS));
}

@Test
public void testBorderWidth2 ()
{
final CSSShortHandDescriptor aSHD = CSSShortHandRegistry.getShortHandDescriptor (ECSSProperty.BORDER_WIDTH);
assertNotNull (aSHD);

final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString ("border-width: 1px 3rem", ECSSVersion.CSS30)
.getDeclarationAtIndex (0);
assertNotNull (aDecl);

final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (4, aSplittedDecls.size ());
assertEquals ("border-top-width:1px", aSplittedDecls.get (0).getAsCSSString (CWS));
assertEquals ("border-right-width:3rem", aSplittedDecls.get (1).getAsCSSString (CWS));
assertEquals ("border-bottom-width:1px", aSplittedDecls.get (2).getAsCSSString (CWS));
assertEquals ("border-left-width:3rem", aSplittedDecls.get (3).getAsCSSString (CWS));
}

@Test
public void testBorderWidth3 ()
{
final CSSShortHandDescriptor aSHD = CSSShortHandRegistry.getShortHandDescriptor (ECSSProperty.BORDER_WIDTH);
assertNotNull (aSHD);

final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString ("border-width: 1px 3rem 4px", ECSSVersion.CSS30)
.getDeclarationAtIndex (0);
assertNotNull (aDecl);

final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (4, aSplittedDecls.size ());
assertEquals ("border-top-width:1px", aSplittedDecls.get (0).getAsCSSString (CWS));
assertEquals ("border-right-width:3rem", aSplittedDecls.get (1).getAsCSSString (CWS));
assertEquals ("border-bottom-width:4px", aSplittedDecls.get (2).getAsCSSString (CWS));
assertEquals ("border-left-width:3rem", aSplittedDecls.get (3).getAsCSSString (CWS));
}

@Test
public void testBorderWidth4 ()
{
final CSSShortHandDescriptor aSHD = CSSShortHandRegistry.getShortHandDescriptor (ECSSProperty.BORDER_WIDTH);
assertNotNull (aSHD);

final CSSDeclaration aDecl = CSSReaderDeclarationList.readFromString ("border-width: 1px 3rem 4px thick", ECSSVersion.CSS30)
.getDeclarationAtIndex (0);
assertNotNull (aDecl);

final ICommonsList <CSSDeclaration> aSplittedDecls = aSHD.getSplitIntoPieces (aDecl);
assertNotNull (aSplittedDecls);
assertEquals (4, aSplittedDecls.size ());
assertEquals ("border-top-width:1px", aSplittedDecls.get (0).getAsCSSString (CWS));
assertEquals ("border-right-width:3rem", aSplittedDecls.get (1).getAsCSSString (CWS));
assertEquals ("border-bottom-width:4px", aSplittedDecls.get (2).getAsCSSString (CWS));
assertEquals ("border-left-width:thick", aSplittedDecls.get (3).getAsCSSString (CWS));
}
}

0 comments on commit 12faf63

Please sign in to comment.