Skip to content
Browse files

Migrate more tests on FEST-assert

  • Loading branch information...
1 parent 2f35982 commit 1a91c867c4e36e24cd7bed378d5a3fa20bfc7745 @Godin Godin committed Jun 15, 2012
View
4 sslr-devkit/pom.xml
@@ -30,8 +30,8 @@
<artifactId>sslr-core</artifactId>
</dependency>
<dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-all</artifactId>
+ <groupId>org.easytesting</groupId>
+ <artifactId>fest-assert</artifactId>
<scope>test</scope>
</dependency>
<dependency>
View
49 sslr-devkit/src/test/java/com/sonar/sslr/devkit/OffsetsTest.java
@@ -26,8 +26,7 @@
import java.net.URI;
import java.net.URISyntaxException;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
public class OffsetsTest {
@@ -36,35 +35,35 @@ public void test() {
Offsets offsets = new Offsets();
offsets.computeLineOffsets("line1\nline2\n", 15);
- assertThat(offsets.getOffset(1, 1), is(2));
- assertThat(offsets.getOffset(1, 2), is(3));
- assertThat(offsets.getOffset(2, 1), is(8));
- assertThat(offsets.getOffset(2, 2), is(9));
- assertThat(offsets.getOffset(3, 1), is(14));
- assertThat(offsets.getOffset(3, 2), is(14));
- assertThat(offsets.getOffset(4, 1), is(14));
+ assertThat(offsets.getOffset(1, 1)).isEqualTo(2);
+ assertThat(offsets.getOffset(1, 2)).isEqualTo(3);
+ assertThat(offsets.getOffset(2, 1)).isEqualTo(8);
+ assertThat(offsets.getOffset(2, 2)).isEqualTo(9);
+ assertThat(offsets.getOffset(3, 1)).isEqualTo(14);
+ assertThat(offsets.getOffset(3, 2)).isEqualTo(14);
+ assertThat(offsets.getOffset(4, 1)).isEqualTo(14);
- assertThat(offsets.getLineFromOffset(2), is(1));
- assertThat(offsets.getLineFromOffset(3), is(1));
- assertThat(offsets.getLineFromOffset(8), is(2));
- assertThat(offsets.getLineFromOffset(9), is(2));
- assertThat(offsets.getLineFromOffset(14), is(3));
- assertThat(offsets.getLineFromOffset(15), is(3));
+ assertThat(offsets.getLineFromOffset(2)).isEqualTo(1);
+ assertThat(offsets.getLineFromOffset(3)).isEqualTo(1);
+ assertThat(offsets.getLineFromOffset(8)).isEqualTo(2);
+ assertThat(offsets.getLineFromOffset(9)).isEqualTo(2);
+ assertThat(offsets.getLineFromOffset(14)).isEqualTo(3);
+ assertThat(offsets.getLineFromOffset(15)).isEqualTo(3);
- assertThat(offsets.getColumnFromOffsetAndLine(2, 1), is(1));
- assertThat(offsets.getColumnFromOffsetAndLine(3, 1), is(2));
- assertThat(offsets.getColumnFromOffsetAndLine(8, 2), is(1));
- assertThat(offsets.getColumnFromOffsetAndLine(9, 2), is(2));
- assertThat(offsets.getColumnFromOffsetAndLine(14, 3), is(1));
- assertThat(offsets.getColumnFromOffsetAndLine(15, 3), is(2));
+ assertThat(offsets.getColumnFromOffsetAndLine(2, 1)).isEqualTo(1);
+ assertThat(offsets.getColumnFromOffsetAndLine(3, 1)).isEqualTo(2);
+ assertThat(offsets.getColumnFromOffsetAndLine(8, 2)).isEqualTo(1);
+ assertThat(offsets.getColumnFromOffsetAndLine(9, 2)).isEqualTo(2);
+ assertThat(offsets.getColumnFromOffsetAndLine(14, 3)).isEqualTo(1);
+ assertThat(offsets.getColumnFromOffsetAndLine(15, 3)).isEqualTo(2);
Token token = mockToken(1, 1, "l");
- assertThat(offsets.getStartOffset(token), is(2));
- assertThat(offsets.getEndOffset(token), is(3));
+ assertThat(offsets.getStartOffset(token)).isEqualTo(2);
+ assertThat(offsets.getEndOffset(token)).isEqualTo(3);
token = mockToken(1, 1, "line1\nl");
- assertThat(offsets.getStartOffset(token), is(2));
- assertThat(offsets.getEndOffset(token), is(8));
+ assertThat(offsets.getStartOffset(token)).isEqualTo(2);
+ assertThat(offsets.getEndOffset(token)).isEqualTo(8);
}
private static Token mockToken(int line, int column, String value) {
View
6 sslr-grammar-analyser/pom.xml
@@ -22,18 +22,14 @@
<artifactId>sslr-core</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-testing-harness</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
View
1 sslr-tests/pom.xml
@@ -46,6 +46,7 @@
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
View
5 sslr-xpath/pom.xml
@@ -32,6 +32,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.easytesting</groupId>
+ <artifactId>fest-assert</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
View
55 sslr-xpath/src/test/java/com/sonar/sslr/xpath/AstNodeNavigatorTest.java
@@ -31,8 +31,7 @@
import java.net.URI;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -69,9 +68,9 @@ public void getAttributeStringValue() throws Exception {
.setColumn(2)
.setValueAndOriginalValue("foo", "bar")
.build());
- assertThat(navigator.getAttributeStringValue(new Attribute("tokenLine", astNode)), is("1"));
- assertThat(navigator.getAttributeStringValue(new Attribute("tokenColumn", astNode)), is("2"));
- assertThat(navigator.getAttributeStringValue(new Attribute("tokenValue", astNode)), is("bar"));
+ assertThat(navigator.getAttributeStringValue(new Attribute("tokenLine", astNode))).isEqualTo("1");
+ assertThat(navigator.getAttributeStringValue(new Attribute("tokenColumn", astNode))).isEqualTo("2");
+ assertThat(navigator.getAttributeStringValue(new Attribute("tokenValue", astNode))).isEqualTo("bar");
}
@Test
@@ -108,89 +107,89 @@ public void getNamespaceStringValue() {
public void getAttributeName() {
Attribute attribute = mock(Attribute.class);
when(attribute.getName()).thenReturn("foo");
- assertThat(navigator.getAttributeName(attribute), is("foo"));
+ assertThat(navigator.getAttributeName(attribute)).isEqualTo("foo");
}
@Test
public void getAttributeQName() {
Attribute attribute = mock(Attribute.class);
when(attribute.getName()).thenReturn("foo");
- assertThat(navigator.getAttributeQName(attribute), is("foo"));
+ assertThat(navigator.getAttributeQName(attribute)).isEqualTo("foo");
}
/* Elements */
@Test
public void getAttributeNamespaceUri() {
- assertThat(navigator.getAttributeNamespaceUri(null), is(""));
+ assertThat(navigator.getAttributeNamespaceUri(null)).isEqualTo("");
}
@Test
public void getElementName() {
AstNode astNode = mock(AstNode.class);
when(astNode.getName()).thenReturn("foo");
- assertThat(navigator.getElementName(astNode), is("foo"));
+ assertThat(navigator.getElementName(astNode)).isEqualTo("foo");
}
@Test
public void getElementQName() {
AstNode astNode = mock(AstNode.class);
when(astNode.getName()).thenReturn("foo");
- assertThat(navigator.getElementQName(astNode), is("foo"));
+ assertThat(navigator.getElementQName(astNode)).isEqualTo("foo");
}
@Test
public void getElementNamespaceUri() {
- assertThat(navigator.getElementNamespaceUri(null), is(""));
+ assertThat(navigator.getElementNamespaceUri(null)).isEqualTo("");
}
/* Types */
@Test
public void isAttribute() {
- assertThat(navigator.isAttribute(mock(AstNodeNavigator.Attribute.class)), is(true));
- assertThat(navigator.isAttribute(null), is(false));
+ assertThat(navigator.isAttribute(mock(AstNodeNavigator.Attribute.class))).isTrue();
+ assertThat(navigator.isAttribute(null)).isFalse();
}
@Test
public void isComment() {
- assertThat(navigator.isComment(null), is(false));
+ assertThat(navigator.isComment(null)).isFalse();
}
@Test
public void isDocument() {
AstNode astNode = mock(AstNode.class);
Attribute attribute = mock(Attribute.class);
when(attribute.getAstNode()).thenReturn(astNode);
- assertThat(navigator.isDocument(attribute), is(false));
- assertThat(navigator.isDocument(astNode), is(false));
- assertThat(navigator.isDocument(navigator.getDocumentNode(astNode)), is(true));
+ assertThat(navigator.isDocument(attribute)).isFalse();
+ assertThat(navigator.isDocument(astNode)).isFalse();
+ assertThat(navigator.isDocument(navigator.getDocumentNode(astNode))).isTrue();
}
@Test
public void isDocument2() {
- assertThat(navigator.isDocument(null), is(false));
+ assertThat(navigator.isDocument(null)).isFalse();
}
@Test
public void isElement() {
- assertThat(navigator.isElement(mock(AstNode.class)), is(true));
- assertThat(navigator.isElement(null), is(false));
+ assertThat(navigator.isElement(mock(AstNode.class))).isTrue();
+ assertThat(navigator.isElement(null)).isFalse();
}
@Test
public void isNamespace() {
- assertThat(navigator.isNamespace(null), is(false));
+ assertThat(navigator.isNamespace(null)).isFalse();
}
@Test
public void isProcessingInstruction() {
- assertThat(navigator.isProcessingInstruction(null), is(false));
+ assertThat(navigator.isProcessingInstruction(null)).isFalse();
}
@Test
public void isText() {
- assertThat(navigator.isText(null), is(false));
+ assertThat(navigator.isText(null)).isFalse();
}
/* Navigation */
@@ -203,13 +202,13 @@ public void getDocumentNode() {
Attribute attribute = mock(Attribute.class);
when(attribute.getAstNode()).thenReturn(astNode);
AstNode documentNode = (AstNode) navigator.getDocumentNode(attribute);
- assertThat(documentNode.getName(), is("[root]"));
+ assertThat(documentNode.getName()).isEqualTo("[root]");
}
@Test
public void getChildAxisIterator() {
Attribute attribute = mock(Attribute.class);
- assertThat(navigator.getChildAxisIterator(attribute).hasNext(), is(false));
+ assertThat(navigator.getChildAxisIterator(attribute).hasNext()).isFalse();
}
@Test
@@ -225,8 +224,8 @@ public void getParentNode() {
when(astNode.getParent()).thenReturn(rootAstNode);
Attribute attribute = mock(Attribute.class);
when(attribute.getAstNode()).thenReturn(astNode);
- assertThat(navigator.getParentNode(attribute), sameInstance((Object) astNode));
- assertThat(navigator.getParentNode(astNode), sameInstance((Object) rootAstNode));
+ assertThat(navigator.getParentNode(attribute)).isSameAs(astNode);
+ assertThat(navigator.getParentNode(astNode)).isSameAs(rootAstNode);
}
@Test
@@ -251,7 +250,7 @@ public void getAttributeAxisIterator() {
@Test
public void parseXPath() {
- assertThat(navigator.parseXPath(null), nullValue());
+ assertThat(navigator.parseXPath(null)).isNull();
}
}
View
33 sslr-xpath/src/test/java/com/sonar/sslr/xpath/AstNodeXPathQueryTest.java
@@ -24,8 +24,7 @@
import com.sonar.sslr.xpath.api.AstNodeXPathQuery;
import org.junit.Test;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.fest.assertions.Assertions.assertThat;
public class AstNodeXPathQueryTest {
@@ -38,15 +37,15 @@ public void selectSingleNodeTest() {
tree.addChild(branch);
branch.addChild(leaf);
- assertThat(expr.selectSingleNode(tree), is(leaf));
+ assertThat(expr.selectSingleNode(tree)).isEqualTo(leaf);
}
@Test
public void selectSingleNodeNoResultTest() {
AstNodeXPathQuery<AstNode> expr = AstNodeXPathQuery.create("branch");
AstNode tree = new AstNode(new NodeType(), "tree", null);
- assertThat(expr.selectSingleNode(tree), nullValue());
+ assertThat(expr.selectSingleNode(tree)).isNull();
}
@Test
@@ -60,15 +59,15 @@ public void selectNodesTest() {
branch.addChild(leaf1);
branch.addChild(leaf2);
- assertThat(expr.selectNodes(tree).size(), is(2));
+ assertThat(expr.selectNodes(tree).size()).isEqualTo(2);
}
@Test
public void selectNodesNoResultTest() {
AstNodeXPathQuery<AstNode> expr = AstNodeXPathQuery.create("//branch");
AstNode tree = new AstNode(new NodeType(), "tree", null);
- assertThat(expr.selectNodes(tree).size(), is(0));
+ assertThat(expr.selectNodes(tree).size()).isEqualTo(0);
}
@Test
@@ -81,7 +80,7 @@ public void relativePathTest() {
tree.addChild(branch);
branch.addChild(leaf);
- assertThat(expr.selectSingleNode(branch), is(leaf));
+ assertThat(expr.selectSingleNode(branch)).isEqualTo(leaf);
}
@Test
@@ -94,7 +93,7 @@ public void parentPathTest() {
tree.addChild(branch);
branch.addChild(leaf);
- assertThat(expr.selectSingleNode(branch), is(tree));
+ assertThat(expr.selectSingleNode(branch)).isEqualTo(tree);
}
@Test
@@ -112,7 +111,7 @@ public void parentAndDescendingPathTest() {
branch1.addChild(leaf);
- assertThat(expr.selectSingleNode(branch1), is(branch2));
+ assertThat(expr.selectSingleNode(branch1)).isEqualTo(branch2);
}
@Test
@@ -125,7 +124,7 @@ public void absolutePathTest() {
tree.addChild(branch);
branch.addChild(leaf);
- assertThat(expr.selectSingleNode(tree), is(tree));
+ assertThat(expr.selectSingleNode(tree)).isEqualTo(tree);
}
@Test
@@ -138,7 +137,7 @@ public void currentPathTest() {
tree.addChild(branch);
branch.addChild(leaf);
- assertThat(expr.selectSingleNode(branch), is(branch));
+ assertThat(expr.selectSingleNode(branch)).isEqualTo(branch);
}
@Test
@@ -151,7 +150,7 @@ public void currentPathWithDescendantTest() {
tree.addChild(branch);
branch.addChild(leaf);
- assertThat(expr.selectSingleNode(branch), is(leaf));
+ assertThat(expr.selectSingleNode(branch)).isEqualTo(leaf);
}
@Test
@@ -164,15 +163,15 @@ public void singleDocumentRoot() {
tree.addChild(branch);
branch.addChild(leaf);
- assertThat(expr.selectNodes(tree).size(), is(1));
+ assertThat(expr.selectNodes(tree).size()).isEqualTo(1);
}
@Test
public void relativeNamePredicate() {
AstNodeXPathQuery<AstNode> expr = AstNodeXPathQuery.create(".[name() = \"tree\"]");
AstNode tree = new AstNode(new NodeType(), "tree", null);
- assertThat(expr.selectSingleNode(tree), is(tree));
+ assertThat(expr.selectSingleNode(tree)).isEqualTo(tree);
}
@Test
@@ -188,7 +187,7 @@ public void relativeCountPredicate() {
tree.addChild(branch2);
tree.addChild(branch3);
- assertThat(expr.selectSingleNode(tree), is(tree));
+ assertThat(expr.selectSingleNode(tree)).isEqualTo(tree);
}
@Test
@@ -203,13 +202,13 @@ public void noCacheTest() {
tree1.addChild(branch12);
tree1.addChild(branch13);
- assertThat(expr.selectNodes(tree1).size(), is(3));
+ assertThat(expr.selectNodes(tree1).size()).isEqualTo(3);
AstNode tree2 = new AstNode(new NodeType(), "tree", null);
AstNode branch21 = new AstNode(new NodeType(), "branch", null);
tree2.addChild(branch21);
- assertThat(expr.selectNodes(tree2).size(), is(1));
+ assertThat(expr.selectNodes(tree2).size()).isEqualTo(1);
}
static class NodeType implements AstNodeType {
View
42 sslr-xpath/src/test/java/com/sonar/sslr/xpath/BasicQueriesTest.java
@@ -26,10 +26,10 @@
import java.util.List;
-import static com.sonar.sslr.api.GenericTokenType.*;
-import static com.sonar.sslr.test.miniC.MiniCParser.*;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static com.sonar.sslr.api.GenericTokenType.EOF;
+import static com.sonar.sslr.test.miniC.MiniCParser.getGrammar;
+import static com.sonar.sslr.test.miniC.MiniCParser.parseFile;
+import static org.fest.assertions.Assertions.assertThat;
public class BasicQueriesTest {
@@ -43,81 +43,81 @@ public void init() {
@Test
public void compilationUnitTest() {
AstNodeXPathQuery<AstNode> xpath = AstNodeXPathQuery.create("/compilationUnit");
- assertThat(xpath.selectSingleNode(fileNode), is(fileNode));
+ assertThat(xpath.selectSingleNode(fileNode)).isEqualTo(fileNode);
}
@Test
public void anyCompilationUnitTest() {
AstNodeXPathQuery<AstNode> xpath = AstNodeXPathQuery.create("//compilationUnit");
- assertThat(xpath.selectSingleNode(fileNode), is(fileNode));
+ assertThat(xpath.selectSingleNode(fileNode)).isEqualTo(fileNode);
}
@Test
public void compilationUnitWithPredicateWithEOFTest() {
AstNodeXPathQuery<AstNode> xpath = AstNodeXPathQuery.create("/compilationUnit[not(not(EOF))]");
- assertThat(xpath.selectSingleNode(fileNode), is(fileNode));
+ assertThat(xpath.selectSingleNode(fileNode)).isEqualTo(fileNode);
}
@Test
public void compilationUnitWithPredicateWithoutEOFTest() {
AstNodeXPathQuery<AstNode> xpath = AstNodeXPathQuery.create("/compilationUnit[not(EOF)]");
- assertThat(xpath.selectSingleNode(fileNode), nullValue());
+ assertThat(xpath.selectSingleNode(fileNode)).isNull();
}
@Test
public void EOFTest() {
AstNodeXPathQuery<AstNode> xpath = AstNodeXPathQuery.create("/compilationUnit/EOF");
- assertThat(xpath.selectSingleNode(fileNode), is(fileNode.findFirstChild(EOF)));
+ assertThat(xpath.selectSingleNode(fileNode)).isEqualTo(fileNode.findFirstChild(EOF));
}
@Test
public void anyEOFTest() {
AstNodeXPathQuery<AstNode> xpath = AstNodeXPathQuery.create("//EOF");
- assertThat(xpath.selectSingleNode(fileNode), is(fileNode.findFirstChild(EOF)));
+ assertThat(xpath.selectSingleNode(fileNode)).isEqualTo(fileNode.findFirstChild(EOF));
}
@Test
public void getTokenValueAttributeTest() {
AstNodeXPathQuery<String> xpath = AstNodeXPathQuery.create("string(/compilationUnit/@tokenValue)");
- assertThat(xpath.selectSingleNode(fileNode), is("int"));
+ assertThat(xpath.selectSingleNode(fileNode)).isEqualTo("int");
}
@Test
public void getTokenLineAttributeTest() {
AstNodeXPathQuery<String> xpath = AstNodeXPathQuery.create("string(/compilationUnit/@tokenLine)");
- assertThat(xpath.selectSingleNode(fileNode), is("2"));
+ assertThat(xpath.selectSingleNode(fileNode)).isEqualTo("2");
}
@Test
public void getTokenColumnAttributeTest() {
AstNodeXPathQuery<String> xpath = AstNodeXPathQuery.create("string(/compilationUnit/@tokenColumn)");
- assertThat(xpath.selectSingleNode(fileNode), is("0"));
+ assertThat(xpath.selectSingleNode(fileNode)).isEqualTo("0");
}
@Test
public void getSecondDeclarationTest() {
AstNodeXPathQuery<AstNode> xpath1 = AstNodeXPathQuery.create("/compilationUnit/definition[@tokenLine=4]");
AstNodeXPathQuery<AstNode> xpath2 = AstNodeXPathQuery.create("/compilationUnit/definition[2]");
AstNode declarationAtLineFour = fileNode.getChild(1);
- assertThat(declarationAtLineFour.is(getGrammar().definition), is(true));
- assertThat(declarationAtLineFour.getTokenLine(), is(4));
- assertThat(xpath1.selectSingleNode(fileNode), is(declarationAtLineFour));
- assertThat(xpath1.selectSingleNode(fileNode), is(xpath2.selectSingleNode(fileNode)));
+ assertThat(declarationAtLineFour.is(getGrammar().definition)).isTrue();
+ assertThat(declarationAtLineFour.getTokenLine()).isEqualTo(4);
+ assertThat(xpath1.selectSingleNode(fileNode)).isEqualTo(declarationAtLineFour);
+ assertThat(xpath1.selectSingleNode(fileNode)).isEqualTo(xpath2.selectSingleNode(fileNode));
}
@Test
public void identifiersCountTest() {
AstNodeXPathQuery<AstNode> xpath = AstNodeXPathQuery.create("/compilationUnit[count(//IDENTIFIER) = 2]");
- assertThat(xpath.selectSingleNode(fileNode), is(fileNode));
+ assertThat(xpath.selectSingleNode(fileNode)).isEqualTo(fileNode);
}
@Test
public void getIdentifiersTest() {
AstNodeXPathQuery<AstNode> xpath = AstNodeXPathQuery.create("//IDENTIFIER");
List<AstNode> nodes = xpath.selectNodes(fileNode);
- assertThat(nodes.size(), is(2));
- assertThat(nodes.get(0).getTokenValue(), is("a"));
- assertThat(nodes.get(1).getTokenValue(), is("b"));
+ assertThat(nodes.size()).isEqualTo(2);
+ assertThat(nodes.get(0).getTokenValue()).isEqualTo("a");
+ assertThat(nodes.get(1).getTokenValue()).isEqualTo("b");
}
}
View
30 sslr-xpath/src/test/java/com/sonar/sslr/xpath/IdentifiersTooLongTest.java
@@ -19,17 +19,15 @@
*/
package com.sonar.sslr.xpath;
-import static com.sonar.sslr.test.miniC.MiniCParser.*;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
-
-import java.util.List;
-
+import com.sonar.sslr.api.AstNode;
+import com.sonar.sslr.xpath.api.AstNodeXPathQuery;
import org.junit.Before;
import org.junit.Test;
-import com.sonar.sslr.api.AstNode;
-import com.sonar.sslr.xpath.api.AstNodeXPathQuery;
+import java.util.List;
+
+import static com.sonar.sslr.test.miniC.MiniCParser.parseFile;
+import static org.fest.assertions.Assertions.assertThat;
public class IdentifiersTooLongTest {
@@ -46,13 +44,13 @@ public void valuesTest() {
List<AstNode> nodes = xpath.selectNodes(fileNode);
- assertThat(nodes.size(), is(3));
- assertThat(nodes.get(0).getTokenValue(), is("aaaaaaaaa11"));
- assertThat(nodes.get(0).getTokenLine(), is(3));
- assertThat(nodes.get(1).getTokenValue(), is("bbbbbbbbbbbbb15"));
- assertThat(nodes.get(1).getTokenLine(), is(10));
- assertThat(nodes.get(2).getTokenValue(), is("ccccccccc11"));
- assertThat(nodes.get(2).getTokenLine(), is(12));
+ assertThat(nodes.size()).isEqualTo(3);
+ assertThat(nodes.get(0).getTokenValue()).isEqualTo("aaaaaaaaa11");
+ assertThat(nodes.get(0).getTokenLine()).isEqualTo(3);
+ assertThat(nodes.get(1).getTokenValue()).isEqualTo("bbbbbbbbbbbbb15");
+ assertThat(nodes.get(1).getTokenLine()).isEqualTo(10);
+ assertThat(nodes.get(2).getTokenValue()).isEqualTo("ccccccccc11");
+ assertThat(nodes.get(2).getTokenLine()).isEqualTo(12);
}
@Test
@@ -61,7 +59,7 @@ public void noResultValuesTest() {
List<AstNode> nodes = xpath.selectNodes(fileNode);
- assertThat(nodes.size(), is(0));
+ assertThat(nodes.size()).isEqualTo(0);
}
}
View
20 sslr-xpath/src/test/java/com/sonar/sslr/xpath/IfSMustUseBracesTest.java
@@ -26,9 +26,9 @@
import java.util.List;
-import static com.sonar.sslr.test.miniC.MiniCParser.*;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static com.sonar.sslr.test.miniC.MiniCParser.getGrammar;
+import static com.sonar.sslr.test.miniC.MiniCParser.parseFile;
+import static org.fest.assertions.Assertions.assertThat;
public class IfSMustUseBracesTest {
@@ -46,8 +46,8 @@ public void firstValueEqualsOnlyValueTest() {
List<AstNode> nodes = xpath.selectNodes(fileNode);
- assertThat(nodes.size(), is(2));
- assertThat(nodes.get(0), is(xpath.selectSingleNode(fileNode)));
+ assertThat(nodes.size()).isEqualTo(2);
+ assertThat(nodes.get(0)).isEqualTo(xpath.selectSingleNode(fileNode));
}
@Test
@@ -57,11 +57,11 @@ public void valuesTest() {
List<AstNode> nodes = xpath.selectNodes(fileNode);
- assertThat(nodes.size(), is(2));
- assertThat(nodes.get(0).is(getGrammar().ifStatement), is(true));
- assertThat(nodes.get(0).getTokenLine(), is(3));
- assertThat(nodes.get(1).is(getGrammar().elseClause), is(true));
- assertThat(nodes.get(1).getTokenLine(), is(16));
+ assertThat(nodes.size()).isEqualTo(2);
+ assertThat(nodes.get(0).is(getGrammar().ifStatement)).isTrue();
+ assertThat(nodes.get(0).getTokenLine()).isEqualTo(3);
+ assertThat(nodes.get(1).is(getGrammar().elseClause)).isTrue();
+ assertThat(nodes.get(1).getTokenLine()).isEqualTo(16);
}
}

0 comments on commit 1a91c86

Please sign in to comment.
Something went wrong with that request. Please try again.