[Schmitzm-commits] r1560 - trunk/schmitzm-core/src/test/java/de/schmitzm/testing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Apr 22 14:21:56 CEST 2011


Author: alfonx
Date: 2011-04-22 14:21:56 +0200 (Fri, 22 Apr 2011)
New Revision: 1560

Modified:
   trunk/schmitzm-core/src/test/java/de/schmitzm/testing/TestingUtil.java
Log:
New Test helpers for euqals

Modified: trunk/schmitzm-core/src/test/java/de/schmitzm/testing/TestingUtil.java
===================================================================
--- trunk/schmitzm-core/src/test/java/de/schmitzm/testing/TestingUtil.java	2011-04-19 17:45:09 UTC (rev 1559)
+++ trunk/schmitzm-core/src/test/java/de/schmitzm/testing/TestingUtil.java	2011-04-22 12:21:56 UTC (rev 1560)
@@ -1,5 +1,6 @@
 package de.schmitzm.testing;
 
+import static org.junit.Assert.*;
 import static org.junit.Assert.assertTrue;
 
 import java.awt.Color;
@@ -26,6 +27,7 @@
 
 import org.apache.log4j.Level;
 import org.junit.Ignore;
+import org.junit.Test;
 
 import de.schmitzm.io.IOUtil;
 import de.schmitzm.lang.LangUtil;
@@ -266,4 +268,48 @@
 			Desktop.getDesktop().open(file);
 		}
 	}
+
+	/**
+	 * Wie assert assertEuqals, aber null == null ohne NPE
+	 */
+	public static void assertEqualsN(String msg, Double soll, Double ist) {
+		if (soll == null) {
+			assertNull(msg, ist);
+			return;
+		} else {
+			assertNotNull(msg,ist);
+			assertEquals(msg, soll, ist, 0.);
+		}
+	}
+	
+	/**
+	 * Wie assert assertEuqals, aber null == null ohne NPE
+	 */
+	public static void assertEqualsN(String msg, Integer soll, Integer ist) {
+		if (soll == null) {
+			assertNull(msg, ist);
+			return;
+		} else {
+			assertNotNull(msg,ist);
+			assertEquals(msg, soll, ist, 0.);
+		}
+	}
+
+	public static void assertEqualsN(String msg, Boolean SOLL,
+			Boolean IST) {
+		if (SOLL == null) {
+			assertNull(msg, SOLL);
+			return;
+		}
+		if (IST == null) {
+			fail(msg, SOLL);
+		}
+		assertEquals(msg, SOLL, IST);
+	}
+
+	private static void fail(String msg, Boolean sOLL) {
+		// TODO Auto-generated method stub
+		
+	}
+
 }



More information about the Schmitzm-commits mailing list