commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1306828 - /commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/Utils.java
Date Thu, 29 Mar 2012 13:02:27 GMT
Author: sebb
Date: Thu Mar 29 13:02:27 2012
New Revision: 1306828

URL: http://svn.apache.org/viewvc?rev=1306828&view=rev
Log:
CSV-69 Utility methods for comparing results

Added:
    commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/Utils.java   (with props)

Added: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/Utils.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/Utils.java?rev=1306828&view=auto
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/Utils.java (added)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/Utils.java Thu Mar 29 13:02:27
2012
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+package org.apache.commons.csv;
+
+import java.util.List;
+
+import org.junit.Assert;
+
+/**
+ * Utility methods for test cases
+ */
+public class Utils {
+
+    private Utils() {
+    }
+    
+    /**
+     * Checks if the two 2d arrays have identical contents.
+     * 
+     * @param message the message to be displayed
+     * @param expected the 2d array of expected results
+     * @param actual the 2d array of actual results
+     */
+    public static void compare(String message, String[][] expected, String[][] actual) {
+        Assert.assertEquals(message+"  - outer array size", expected.length, actual.length);
+        for(int i = 0; i < expected.length; i++) {
+            Assert.assertArrayEquals(message+" (entry "+i+")",expected[i], actual[i]);
+        }
+    }
+    
+    /**
+     * Checks if the 2d array has the same contents as the list of records.
+     * 
+     * @param message the message to be displayed
+     * @param expected the 2d array of expected results
+     * @param actual the List of {@link CSVRecord} entries, each containing an array of values
+     */
+    public static void compare(String message, String[][] expected, List<CSVRecord>
actual) {
+        Assert.assertEquals(message+"  - outer array size", expected.length, actual.size());
+        for(int i = 0; i < expected.length; i++) {
+            Assert.assertArrayEquals(message+" (entry "+i+")",expected[i], actual.get(i).values());
+        }
+    }
+}

Propchange: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/Utils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/Utils.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message