How to use assertSame method of junit.framework.Assert class

Best junit code snippet using junit.framework.Assert.assertSame

Source:ComplexTest.java Github

copy

Full Screen

...269		org.apache.commons.math.TestUtils.assertEquals(expected, z.acos(), 1.0E-5);270		org.apache.commons.math.TestUtils.assertEquals(new org.apache.commons.math.complex.Complex(java.lang.Math.acos(0) , 0), org.apache.commons.math.complex.Complex.ZERO.acos(), 1.0E-12);271	}272	public void testAcosInf() {273		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, oneInf.acos());274		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, oneNegInf.acos());275		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infOne.acos());276		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfOne.acos());277		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infInf.acos());278		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infNegInf.acos());279		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfInf.acos());280		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfNegInf.acos());281	}282	public void testAcosNaN() {283		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.NaN.acos().isNaN());284	}285	public void testAsin() {286		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(3 , 4);287		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(0.633984 , 2.30551);288		org.apache.commons.math.TestUtils.assertEquals(expected, z.asin(), 1.0E-5);289	}290	public void testAsinNaN() {291		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.NaN.asin().isNaN());292	}293	public void testAsinInf() {294		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, oneInf.asin());295		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, oneNegInf.asin());296		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infOne.asin());297		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfOne.asin());298		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infInf.asin());299		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infNegInf.asin());300		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfInf.asin());301		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfNegInf.asin());302	}303	public void testAtan() {304		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(3 , 4);305		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(1.44831 , 0.158997);306		org.apache.commons.math.TestUtils.assertEquals(expected, z.atan(), 1.0E-5);307	}308	public void testAtanInf() {309		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, oneInf.atan());310		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, oneNegInf.atan());311		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infOne.atan());312		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfOne.atan());313		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infInf.atan());314		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infNegInf.atan());315		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfInf.atan());316		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfNegInf.atan());317	}318	public void testAtanNaN() {319		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.NaN.atan().isNaN());320		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.I.atan().isNaN());321	}322	public void testCos() {323		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(3 , 4);324		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(-27.03495 , -3.851153);325		org.apache.commons.math.TestUtils.assertEquals(expected, z.cos(), 1.0E-5);326	}327	public void testCosNaN() {328		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.NaN.cos().isNaN());329	}330	public void testCosInf() {331		org.apache.commons.math.TestUtils.assertSame(infNegInf, oneInf.cos());332		org.apache.commons.math.TestUtils.assertSame(infInf, oneNegInf.cos());333		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infOne.cos());334		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfOne.cos());335		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infInf.cos());336		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infNegInf.cos());337		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfInf.cos());338		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfNegInf.cos());339	}340	public void testCosh() {341		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(3 , 4);342		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(-6.58066 , -7.58155);343		org.apache.commons.math.TestUtils.assertEquals(expected, z.cosh(), 1.0E-5);344	}345	public void testCoshNaN() {346		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.NaN.cosh().isNaN());347	}348	public void testCoshInf() {349		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, oneInf.cosh());350		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, oneNegInf.cosh());351		org.apache.commons.math.TestUtils.assertSame(infInf, infOne.cosh());352		org.apache.commons.math.TestUtils.assertSame(infNegInf, negInfOne.cosh());353		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infInf.cosh());354		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infNegInf.cosh());355		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfInf.cosh());356		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfNegInf.cosh());357	}358	public void testExp() {359		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(3 , 4);360		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(-13.12878 , -15.20078);361		org.apache.commons.math.TestUtils.assertEquals(expected, z.exp(), 1.0E-5);362		org.apache.commons.math.TestUtils.assertEquals(org.apache.commons.math.complex.Complex.ONE, org.apache.commons.math.complex.Complex.ZERO.exp(), 1.0E-11);363		org.apache.commons.math.complex.Complex iPi = org.apache.commons.math.complex.Complex.I.multiply(new org.apache.commons.math.complex.Complex(pi , 0));364		org.apache.commons.math.TestUtils.assertEquals(org.apache.commons.math.complex.Complex.ONE.negate(), iPi.exp(), 1.0E-11);365	}366	public void testExpNaN() {367		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.NaN.exp().isNaN());368	}369	public void testExpInf() {370		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, oneInf.exp());371		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, oneNegInf.exp());372		org.apache.commons.math.TestUtils.assertSame(infInf, infOne.exp());373		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.ZERO, negInfOne.exp());374		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infInf.exp());375		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infNegInf.exp());376		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfInf.exp());377		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfNegInf.exp());378	}379	public void testLog() {380		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(3 , 4);381		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(1.60944 , 0.927295);382		org.apache.commons.math.TestUtils.assertEquals(expected, z.log(), 1.0E-5);383	}384	public void testLogNaN() {385		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.NaN.log().isNaN());386	}387	public void testLogInf() {388		org.apache.commons.math.TestUtils.assertEquals(new org.apache.commons.math.complex.Complex(inf , ((pi) / 2)), oneInf.log(), 1.0E-11);389		org.apache.commons.math.TestUtils.assertEquals(new org.apache.commons.math.complex.Complex(inf , ((-(pi)) / 2)), oneNegInf.log(), 1.0E-11);390		org.apache.commons.math.TestUtils.assertEquals(infZero, infOne.log(), 1.0E-11);391		org.apache.commons.math.TestUtils.assertEquals(new org.apache.commons.math.complex.Complex(inf , pi), negInfOne.log(), 1.0E-11);392		org.apache.commons.math.TestUtils.assertEquals(new org.apache.commons.math.complex.Complex(inf , ((pi) / 4)), infInf.log(), 1.0E-11);393		org.apache.commons.math.TestUtils.assertEquals(new org.apache.commons.math.complex.Complex(inf , ((-(pi)) / 4)), infNegInf.log(), 1.0E-11);394		org.apache.commons.math.TestUtils.assertEquals(new org.apache.commons.math.complex.Complex(inf , ((3.0 * (pi)) / 4)), negInfInf.log(), 1.0E-11);395		org.apache.commons.math.TestUtils.assertEquals(new org.apache.commons.math.complex.Complex(inf , (((-3.0) * (pi)) / 4)), negInfNegInf.log(), 1.0E-11);396	}397	public void testLogZero() {398		org.apache.commons.math.TestUtils.assertSame(negInfZero, org.apache.commons.math.complex.Complex.ZERO.log());399	}400	public void testPow() {401		org.apache.commons.math.complex.Complex x = new org.apache.commons.math.complex.Complex(3 , 4);402		org.apache.commons.math.complex.Complex y = new org.apache.commons.math.complex.Complex(5 , 6);403		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(-1.860893 , 11.83677);404		org.apache.commons.math.TestUtils.assertEquals(expected, x.pow(y), 1.0E-5);405	}406	public void testPowNaNBase() {407		org.apache.commons.math.complex.Complex x = new org.apache.commons.math.complex.Complex(3 , 4);408		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.NaN.pow(x).isNaN());409	}410	public void testPowNaNExponent() {411		org.apache.commons.math.complex.Complex x = new org.apache.commons.math.complex.Complex(3 , 4);412		junit.framework.Assert.assertTrue(x.pow(org.apache.commons.math.complex.Complex.NaN).isNaN());413	}414	public void testPowInf() {415		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, org.apache.commons.math.complex.Complex.ONE.pow(oneInf));416		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, org.apache.commons.math.complex.Complex.ONE.pow(oneNegInf));417		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, org.apache.commons.math.complex.Complex.ONE.pow(infOne));418		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, org.apache.commons.math.complex.Complex.ONE.pow(infInf));419		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, org.apache.commons.math.complex.Complex.ONE.pow(infNegInf));420		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, org.apache.commons.math.complex.Complex.ONE.pow(negInfInf));421		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, org.apache.commons.math.complex.Complex.ONE.pow(negInfNegInf));422		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infOne.pow(org.apache.commons.math.complex.Complex.ONE));423		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfOne.pow(org.apache.commons.math.complex.Complex.ONE));424		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infInf.pow(org.apache.commons.math.complex.Complex.ONE));425		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infNegInf.pow(org.apache.commons.math.complex.Complex.ONE));426		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfInf.pow(org.apache.commons.math.complex.Complex.ONE));427		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfNegInf.pow(org.apache.commons.math.complex.Complex.ONE));428		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfNegInf.pow(infNegInf));429		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfNegInf.pow(negInfNegInf));430		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfNegInf.pow(infInf));431		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infInf.pow(infNegInf));432		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infInf.pow(negInfNegInf));433		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infInf.pow(infInf));434		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infNegInf.pow(infNegInf));435		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infNegInf.pow(negInfNegInf));436		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infNegInf.pow(infInf));437	}438	public void testPowZero() {439		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, org.apache.commons.math.complex.Complex.ZERO.pow(org.apache.commons.math.complex.Complex.ONE));440		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, org.apache.commons.math.complex.Complex.ZERO.pow(org.apache.commons.math.complex.Complex.ZERO));441		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, org.apache.commons.math.complex.Complex.ZERO.pow(org.apache.commons.math.complex.Complex.I));442		org.apache.commons.math.TestUtils.assertEquals(org.apache.commons.math.complex.Complex.ONE, org.apache.commons.math.complex.Complex.ONE.pow(org.apache.commons.math.complex.Complex.ZERO), 1.0E-11);443		org.apache.commons.math.TestUtils.assertEquals(org.apache.commons.math.complex.Complex.ONE, org.apache.commons.math.complex.Complex.I.pow(org.apache.commons.math.complex.Complex.ZERO), 1.0E-11);444		org.apache.commons.math.TestUtils.assertEquals(org.apache.commons.math.complex.Complex.ONE, new org.apache.commons.math.complex.Complex(-1 , 3).pow(org.apache.commons.math.complex.Complex.ZERO), 1.0E-11);445	}446	public void testpowNull() {447		try {448			org.apache.commons.math.complex.Complex.ONE.pow(null);449			junit.framework.Assert.fail("Expecting NullPointerException");450		} catch (java.lang.NullPointerException ex) {451		}452	}453	public void testSin() {454		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(3 , 4);455		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(3.853738 , -27.01681);456		org.apache.commons.math.TestUtils.assertEquals(expected, z.sin(), 1.0E-5);457	}458	public void testSinInf() {459		org.apache.commons.math.TestUtils.assertSame(infInf, oneInf.sin());460		org.apache.commons.math.TestUtils.assertSame(infNegInf, oneNegInf.sin());461		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infOne.sin());462		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfOne.sin());463		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infInf.sin());464		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infNegInf.sin());465		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfInf.sin());466		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfNegInf.sin());467	}468	public void testSinNaN() {469		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.NaN.sin().isNaN());470	}471	public void testSinh() {472		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(3 , 4);473		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(-6.54812 , -7.61923);474		org.apache.commons.math.TestUtils.assertEquals(expected, z.sinh(), 1.0E-5);475	}476	public void testSinhNaN() {477		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.NaN.sinh().isNaN());478	}479	public void testSinhInf() {480		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, oneInf.sinh());481		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, oneNegInf.sinh());482		org.apache.commons.math.TestUtils.assertSame(infInf, infOne.sinh());483		org.apache.commons.math.TestUtils.assertSame(negInfInf, negInfOne.sinh());484		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infInf.sinh());485		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infNegInf.sinh());486		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfInf.sinh());487		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfNegInf.sinh());488	}489	public void testSqrtRealPositive() {490		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(3 , 4);491		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(2 , 1);492		org.apache.commons.math.TestUtils.assertEquals(expected, z.sqrt(), 1.0E-5);493	}494	public void testSqrtRealZero() {495		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(0.0 , 4);496		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(1.41421 , 1.41421);497		org.apache.commons.math.TestUtils.assertEquals(expected, z.sqrt(), 1.0E-5);498	}499	public void testSqrtRealNegative() {500		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(-3.0 , 4);501		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(1 , 2);502		org.apache.commons.math.TestUtils.assertEquals(expected, z.sqrt(), 1.0E-5);503	}504	public void testSqrtImaginaryZero() {505		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(-3.0 , 0.0);506		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(0.0 , 1.73205);507		org.apache.commons.math.TestUtils.assertEquals(expected, z.sqrt(), 1.0E-5);508	}509	public void testSqrtImaginaryNegative() {510		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(-3.0 , -4.0);511		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(1.0 , -2.0);512		org.apache.commons.math.TestUtils.assertEquals(expected, z.sqrt(), 1.0E-5);513	}514	public void testSqrtPolar() {515		double r = 1;516		for (int i = 0 ; i < 5 ; i++) {517			r += i;518			double theta = 0;519			for (int j = 0 ; j < 11 ; j++) {520				theta += (pi) / 12;521				org.apache.commons.math.complex.Complex z = org.apache.commons.math.complex.ComplexUtils.polar2Complex(r, theta);522				org.apache.commons.math.complex.Complex sqrtz = org.apache.commons.math.complex.ComplexUtils.polar2Complex(java.lang.Math.sqrt(r), (theta / 2));523				org.apache.commons.math.TestUtils.assertEquals(sqrtz, z.sqrt(), 1.0E-11);524			}525		}526	}527	public void testSqrtNaN() {528		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.NaN.sqrt().isNaN());529	}530	public void testSqrtInf() {531		org.apache.commons.math.TestUtils.assertSame(infNaN, oneInf.sqrt());532		org.apache.commons.math.TestUtils.assertSame(infNaN, oneNegInf.sqrt());533		org.apache.commons.math.TestUtils.assertSame(infZero, infOne.sqrt());534		org.apache.commons.math.TestUtils.assertSame(zeroInf, negInfOne.sqrt());535		org.apache.commons.math.TestUtils.assertSame(infNaN, infInf.sqrt());536		org.apache.commons.math.TestUtils.assertSame(infNaN, infNegInf.sqrt());537		org.apache.commons.math.TestUtils.assertSame(nanInf, negInfInf.sqrt());538		org.apache.commons.math.TestUtils.assertSame(nanNegInf, negInfNegInf.sqrt());539	}540	public void testSqrt1z() {541		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(3 , 4);542		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(4.08033 , -2.94094);543		org.apache.commons.math.TestUtils.assertEquals(expected, z.sqrt1z(), 1.0E-5);544	}545	public void testSqrt1zNaN() {546		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.NaN.sqrt1z().isNaN());547	}548	public void testTan() {549		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(3 , 4);550		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(-1.87346E-4 , 0.999356);551		org.apache.commons.math.TestUtils.assertEquals(expected, z.tan(), 1.0E-5);552	}553	public void testTanNaN() {554		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.NaN.tan().isNaN());555	}556	public void testTanInf() {557		org.apache.commons.math.TestUtils.assertSame(zeroNaN, oneInf.tan());558		org.apache.commons.math.TestUtils.assertSame(zeroNaN, oneNegInf.tan());559		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infOne.tan());560		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfOne.tan());561		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infInf.tan());562		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infNegInf.tan());563		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfInf.tan());564		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfNegInf.tan());565	}566	public void testTanCritical() {567		org.apache.commons.math.TestUtils.assertSame(infNaN, new org.apache.commons.math.complex.Complex(((pi) / 2) , 0).tan());568		org.apache.commons.math.TestUtils.assertSame(negInfNaN, new org.apache.commons.math.complex.Complex(((-(pi)) / 2) , 0).tan());569	}570	public void testTanh() {571		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(3 , 4);572		org.apache.commons.math.complex.Complex expected = new org.apache.commons.math.complex.Complex(1.00071 , 0.00490826);573		org.apache.commons.math.TestUtils.assertEquals(expected, z.tanh(), 1.0E-5);574	}575	public void testTanhNaN() {576		junit.framework.Assert.assertTrue(org.apache.commons.math.complex.Complex.NaN.tanh().isNaN());577	}578	public void testTanhInf() {579		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, oneInf.tanh());580		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, oneNegInf.tanh());581		org.apache.commons.math.TestUtils.assertSame(nanZero, infOne.tanh());582		org.apache.commons.math.TestUtils.assertSame(nanZero, negInfOne.tanh());583		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infInf.tanh());584		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, infNegInf.tanh());585		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfInf.tanh());586		org.apache.commons.math.TestUtils.assertSame(org.apache.commons.math.complex.Complex.NaN, negInfNegInf.tanh());587	}588	public void testTanhCritical() {589		org.apache.commons.math.TestUtils.assertSame(nanInf, new org.apache.commons.math.complex.Complex(0 , ((pi) / 2)).tanh());590	}591	public void testMath221() {592		junit.framework.Assert.assertEquals(new org.apache.commons.math.complex.Complex(0 , -1), new org.apache.commons.math.complex.Complex(0 , 1).multiply(new org.apache.commons.math.complex.Complex(-1 , 0)));593	}594	public void testNthRoot_normal_thirdRoot() {595		org.apache.commons.math.complex.Complex z = new org.apache.commons.math.complex.Complex(-2 , 2);596		org.apache.commons.math.complex.Complex[] thirdRootsOfZ = z.nthRoot(3).toArray(new org.apache.commons.math.complex.Complex[0]);597		junit.framework.Assert.assertEquals(3, thirdRootsOfZ.length);598		junit.framework.Assert.assertEquals(1.0, thirdRootsOfZ[0].getReal(), 1.0E-5);599		junit.framework.Assert.assertEquals(1.0, thirdRootsOfZ[0].getImaginary(), 1.0E-5);600		junit.framework.Assert.assertEquals(-1.3660254037844386, thirdRootsOfZ[1].getReal(), 1.0E-5);601		junit.framework.Assert.assertEquals(0.36602540378443843, thirdRootsOfZ[1].getImaginary(), 1.0E-5);602		junit.framework.Assert.assertEquals(0.366025403784439, thirdRootsOfZ[2].getReal(), 1.0E-5);603		junit.framework.Assert.assertEquals(-1.3660254037844384, thirdRootsOfZ[2].getImaginary(), 1.0E-5);...

Full Screen

Full Screen

Source:SuperDbDaoTest.java Github

copy

Full Screen

...141    @Test142    public void testGetSuperByIdSuccess() throws SuperPersistenceException {143        Super toGetOne = dao.getSuperById(1);144        Assert.assertNotNull(toGetOne);145        Assert.assertSame(1, toGetOne.getSuperId());146        Assert.assertEquals("Superman", toGetOne.getName());147        Assert.assertEquals("So super", toGetOne.getDescription());148        Assert.assertEquals("flight", toGetOne.getSuperpower());149        Super toGetThree = dao.getSuperById(3);150        Assert.assertNotNull(toGetThree);151        Assert.assertSame(3, toGetThree.getSuperId());152        Assert.assertEquals("Freeze", toGetThree.getName());153        Assert.assertEquals("cold", toGetThree.getDescription());154        Assert.assertEquals("icing", toGetThree.getSuperpower());155    }156    @Test157    public void testGetSuperByIdFailInvalidId() throws SuperPersistenceException {158        try {159            dao.getSuperById(5);160            junit.framework.Assert.fail("Expected SuperPersistenceException was not thrown.");161        } catch (SuperPersistenceException ex) {162        }163    }164    /**165     * Test of getAllSupers method, of class SuperDbDao.166     */167    @Test168    public void testGetAllSupers() throws SuperPersistenceException {169        List<Super> allSupers = dao.getAllSupers();170        Assert.assertNotNull(allSupers);171        Assert.assertEquals(3, allSupers.size());172        Super toGetOne = allSupers.get(0);173        Assert.assertNotNull(toGetOne);174        Assert.assertSame(1, toGetOne.getSuperId());175        Assert.assertEquals("Superman", toGetOne.getName());176        Assert.assertEquals("So super", toGetOne.getDescription());177        Assert.assertEquals("flight", toGetOne.getSuperpower());178        Super toGetThree = allSupers.get(allSupers.size() - 1);179        Assert.assertNotNull(toGetThree);180        Assert.assertSame(3, toGetThree.getSuperId());181        Assert.assertEquals("Freeze", toGetThree.getName());182        Assert.assertEquals("cold", toGetThree.getDescription());183        Assert.assertEquals("icing", toGetThree.getSuperpower());184    }185    /**186     * Test of addSuper method, of class SuperDbDao.187     */188    @Test189    public void testAddSuperSuccess() throws SuperPersistenceException {190        List<Super> allSupers = dao.getAllSupers();191        junit.framework.Assert.assertEquals(3, allSupers.size());192        junit.framework.Assert.assertNotNull(allSupers);193        Super toAdd = new Super();194        toAdd.setName("Best Super");195        toAdd.setDescription("The best");196        toAdd.setSuperpower("coolin");197        dao.addSuper(toAdd);198        List<Super> allSupersNew = dao.getAllSupers();199        junit.framework.Assert.assertEquals(4, allSupersNew.size());200        junit.framework.Assert.assertNotNull(allSupersNew);201        Super addedSuper = allSupersNew.get(allSupersNew.size() - 1);202        junit.framework.Assert.assertNotNull(addedSuper);203        junit.framework.Assert.assertSame(4, addedSuper.getSuperId());204        junit.framework.Assert.assertEquals("Best Super", addedSuper.getName());205        junit.framework.Assert.assertEquals("The best", addedSuper.getDescription());206        junit.framework.Assert.assertEquals("coolin", addedSuper.getSuperpower());207        Super toAddTwo = new Super();208        toAddTwo.setName("Best Super Two");209        toAddTwo.setDescription("The best Two");210        toAddTwo.setSuperpower("heatin");211        dao.addSuper(toAddTwo);212        List<Super> allSupersNewTwo = dao.getAllSupers();213        junit.framework.Assert.assertEquals(5, allSupersNewTwo.size());214        junit.framework.Assert.assertNotNull(allSupersNewTwo);215        Super addedSuperTwo = allSupersNewTwo.get(allSupersNewTwo.size() - 1);216        Assert.assertSame(5, addedSuperTwo.getSuperId());217        Assert.assertEquals("Best Super Two", addedSuperTwo.getName());218        Assert.assertEquals("The best Two", addedSuperTwo.getDescription());219        Assert.assertEquals("heatin", addedSuperTwo.getSuperpower());220    }221    @Test222    public void testAddSuperFailNoName() throws SuperPersistenceException {223        try {224            Super toAdd = new Super();225            toAdd.setDescription("The best Two");226            toAdd.setSuperpower("heatin");227            dao.addSuper(toAdd);228            junit.framework.Assert.fail("Expected SuperPersistenceException was not thrown.");229        } catch (SuperPersistenceException ex) {230        }231    }232    @Test233    public void testAddSuperFailMaxName() throws SuperPersistenceException {234        try {235            Super toAdd = new Super();236            toAdd.setName("llllllllllaaaaaaaaaaaalllllllll");237            toAdd.setDescription("The best Two");238            toAdd.setSuperpower("heatin");239            dao.addSuper(toAdd);240            junit.framework.Assert.fail("Expected SuperPersistenceException was not thrown.");241        } catch (SuperPersistenceException ex) {242        }243    }244    @Test245    public void testAddSuperFailNoDescription() throws SuperPersistenceException {246        try {247            Super toAdd = new Super();248            toAdd.setName("Best Super");249            toAdd.setSuperpower("coolin");250            dao.addSuper(toAdd);251            junit.framework.Assert.fail("Expected SuperPersistenceException was not thrown.");252        } catch (SuperPersistenceException ex) {253        }254    }255    @Test256    public void testAddSuperFailMaxDescription() throws OrganizationPersistenceException {257        try {258            Super toAdd = new Super();259            toAdd.setName("Best Super");260            toAdd.setDescription("dsdsdsddsssssjsjsjsjsjsjsjsjsjsjsjsjsjsjsjllllllllllllllllllljsjsjsjsjsjsjsjsjsjsjsjsjsjsjsjlllllllllllllllllll");261            toAdd.setSuperpower("coolin");262            dao.addSuper(toAdd);263            junit.framework.Assert.fail("Expected SuperPersistenceException was not thrown.");264        } catch (SuperPersistenceException ex) {265        }266    }267    @Test268    public void testAddSuperFailNoSuperpower() throws OrganizationPersistenceException {269        try {270            Super toAdd = new Super();271            toAdd.setName("Best Super");272            toAdd.setDescription("The best");273            dao.addSuper(toAdd);274            junit.framework.Assert.fail("Expected SuperPersistenceException was not thrown.");275        } catch (SuperPersistenceException ex) {276        }277    }278    @Test279    public void testAddSuperFailMaxSuperpower() throws SuperPersistenceException {280        try {281            Super toAdd = new Super();282            toAdd.setName("Best Super");283            toAdd.setDescription("The best");284            toAdd.setSuperpower("dsdsdsddsssssjsjsjsjsjsjsjsjsjsjsjsjsjsjsjllllllllllllllllllljsjsjsjsjsjsjsjsjsjsjsjsjsjsjsjlllllllllllllllllll");285            dao.addSuper(toAdd);286            junit.framework.Assert.fail("Expected SuperPersistenceException was not thrown.");287        } catch (SuperPersistenceException ex) {288        }289    }290    /**291     * Test of updateSuper method, of class SuperDbDao.292     */293    @Test294    public void testUpdateSuperSuccess() throws SuperPersistenceException {295        Organization orgOne = new Organization();296        orgOne.setOrganizationId(1);297        orgOne.setName("Marvel");298        orgOne.setDescription("Marveling");299        orgOne.setAddress("456 Test Avenue, Saint Paul, MN 55104");300        orgOne.setPhoneNumber("7702410271");301        orgOne.setEmail("marvel@marvel.com");302        Organization orgTwo = new Organization();303        orgTwo.setOrganizationId(2);304        orgTwo.setName("DC");305        orgTwo.setDescription("DC What");306        orgTwo.setAddress("456 Test Street, Saint Paul, MN 55104");307        orgTwo.setPhoneNumber("7705181492");308        orgTwo.setEmail("dc@dc.com");       309        310        Super toEdit = dao.getSuperById(1);311        Assert.assertNotNull(toEdit);312        Assert.assertSame(1, toEdit.getSuperId());313        Assert.assertEquals("Superman", toEdit.getName());314        Assert.assertEquals("So super", toEdit.getDescription());315        Assert.assertEquals("flight", toEdit.getSuperpower());316        toEdit.setName("Best Super");317        toEdit.setDescription("The best");318        toEdit.setSuperpower("coolin");319        dao.updateSuper(toEdit);320        321        Super editedOne = dao.getSuperById(1);322        Assert.assertNotNull(editedOne);323        Assert.assertSame(1, editedOne.getSuperId());324        Assert.assertEquals("Best Super", editedOne.getName());325        Assert.assertEquals("The best", editedOne.getDescription());326        Assert.assertEquals("coolin", editedOne.getSuperpower());327        Super toEditTwo = dao.getSuperById(3);328        Assert.assertNotNull(toEditTwo);329        Assert.assertSame(3, toEditTwo.getSuperId());330        Assert.assertEquals("Freeze", toEditTwo.getName());331        Assert.assertEquals("cold", toEditTwo.getDescription());332        Assert.assertEquals("icing", toEditTwo.getSuperpower());333        334        toEditTwo.setName("Okay Super");335        toEditTwo.setDescription("The okayest");336        toEditTwo.setSuperpower("warming");337        dao.updateSuper(toEditTwo);338        Super editedTwo = dao.getSuperById(3);339        Assert.assertNotNull(editedTwo);340        Assert.assertSame(3, editedTwo.getSuperId());341        Assert.assertEquals("Okay Super", editedTwo.getName());342        Assert.assertEquals("The okayest", editedTwo.getDescription());343        Assert.assertEquals("warming", editedTwo.getSuperpower());344    }345    @Test346    public void testUpdateSuperFailNoName() throws SuperPersistenceException {347        try {348            Super toEdit = dao.getSuperById(1);349            toEdit.setName(null);350            toEdit.setDescription("The best Two");351            toEdit.setSuperpower("heatin");352            dao.updateSuper(toEdit);353            junit.framework.Assert.fail("Expected SuperPersistenceException was not thrown.");354        } catch (SuperPersistenceException ex) {355        }356    }357    @Test358    public void testUpdateSuperFailMaxName() throws SuperPersistenceException {359        try {360            Super toEdit = dao.getSuperById(1);361            toEdit.setName("llllllllllaaaaaaaaaaaalllllllll");362            toEdit.setDescription("The best Two");363            toEdit.setSuperpower("heatin");364            dao.updateSuper(toEdit);365            junit.framework.Assert.fail("Expected SuperPersistenceException was not thrown.");366        } catch (SuperPersistenceException ex) {367        }368    }369    @Test370    public void testUpdateSuperFailNoDescription() throws SuperPersistenceException {371        try {372            Super toEdit = dao.getSuperById(1);373            toEdit.setName("llllllllllaaaaaaaaaaaalllllllll");374            toEdit.setDescription(null);375            toEdit.setSuperpower("heatin");376            dao.updateSuper(toEdit);377            junit.framework.Assert.fail("Expected SuperPersistenceException was not thrown.");378        } catch (SuperPersistenceException ex) {379        }380    }381    @Test382    public void testUpdateSuperFailMaxDescription() throws OrganizationPersistenceException {383        try {384            Super toEdit = dao.getSuperById(1);385            toEdit.setName("Best Super");386            toEdit.setDescription("dsdsdsddsssssjsjsjsjsjsjsjsjsjsjsjsjsjsjsjllllllllllllllllllljsjsjsjsjsjsjsjsjsjsjsjsjsjsjsjlllllllllllllllllll");387            toEdit.setSuperpower("coolin");388            dao.updateSuper(toEdit);389            junit.framework.Assert.fail("Expected SuperPersistenceException was not thrown.");390        } catch (SuperPersistenceException ex) {391        }392    }393    @Test394    public void testUpdateSuperFailNoSuperpower() throws OrganizationPersistenceException {395        try {396            Super toEdit = dao.getSuperById(1);397            toEdit.setName("Best Super");398            toEdit.setDescription("The best");399            toEdit.setSuperpower(null);400            dao.updateSuper(toEdit);401            junit.framework.Assert.fail("Expected SuperPersistenceException was not thrown.");402        } catch (SuperPersistenceException ex) {403        }404    }405    @Test406    public void testUpdateSuperFailMaxSuperpower() throws SuperPersistenceException {407        try {408            Super toEdit = dao.getSuperById(1);409            toEdit.setName("Best Super");410            toEdit.setDescription("The best");411            toEdit.setSuperpower("dsdsdsddsssssjsjsjsjsjsjsjsjsjsjsjsjsjsjsjllllllllllllllllllljsjsjsjsjsjsjsjsjsjsjsjsjsjsjsjlllllllllllllllllll");412            dao.updateSuper(toEdit);413            junit.framework.Assert.fail("Expected SuperPersistenceException was not thrown.");414        } catch (SuperPersistenceException ex) {415        }416    }417    /**418     * Test of deleteSuperById method, of class SuperDbDao.419     */420    @Test421    public void testDeleteSuperByIdSuccess() throws SuperPersistenceException {422        Super toDeleteOne = dao.getSuperById(1);423        List<Super> allSupers = dao.getAllSupers();424        junit.framework.Assert.assertEquals(3, allSupers.size());425        junit.framework.Assert.assertNotNull(toDeleteOne);426        junit.framework.Assert.assertSame(1, toDeleteOne.getSuperId());427        dao.deleteSuperById(1);428        List<Super> allSupersOneDeleted = dao.getAllSupers();429        junit.framework.Assert.assertEquals(2, allSupersOneDeleted.size());430        junit.framework.Assert.assertSame(2, allSupersOneDeleted.get(0).getSuperId());431        Super toDeleteTwo = dao.getSuperById(2);432        junit.framework.Assert.assertNotNull(toDeleteTwo);433        junit.framework.Assert.assertSame(2, toDeleteTwo.getSuperId());434        dao.deleteSuperById(2);435        List<Super> allSupersTwoDeleted = dao.getAllSupers();436        junit.framework.Assert.assertEquals(1, allSupersTwoDeleted.size());437        junit.framework.Assert.assertSame(3, allSupersTwoDeleted.get(0).getSuperId());438    }439    @Test440    public void testDeleteSuperByIdFail() throws SuperPersistenceException {441        try {442            dao.deleteSuperById(5);443            junit.framework.Assert.fail("Expected SuperPersistenceException was not thrown.");444        } catch (SuperPersistenceException ex) {445        }446    }447    /**448     * Test of getSupersByOrgId method, of class SuperDbDao.449     */450    @Test451    public void testGetSupersByOrgIdSuccess() throws SuperPersistenceException {...

Full Screen

Full Screen

Source:Matrix4Test.java Github

copy

Full Screen

...50                5., 6., 7., 8.,51                9., 10, 11, 12,52                13, 14, 15, 16);53        final Matrix4 r = m.assignZero();54        assertSame(r, m);//assert it return this55        //assert every value is 0.56        assertMatrixEquals(new double[]{57                    0., 0., 0., 0.,58                    0., 0., 0., 0.,59                    0., 0., 0., 0.,60                    0., 0., 0., 0.,}, m);61    }62    @Test63    public void testCtorD() {64        final Matrix4 m = new Matrix4(new double[]{65                    1., 2., 3., 4.,66                    5., 6., 7., 8.,67                    9., 10, 11, 12,68                    13, 14, 15, 16});69        assertMatrixEquals(new double[]{70                    1., 5., 9., 13,71                    2., 6., 10, 14,72                    3., 7., 11, 15,73                    4., 8., 12, 16}, m);74    }75    @Test76    public void testAssignD() {77        final Matrix4 m = new Matrix4();78        final Matrix4 r = m.assign(new double[]{79                    1., 2., 3., 4.,80                    5., 6., 7., 8.,81                    9., 10, 11, 12,82                    13, 14, 15, 16});83        assertSame(r, m);//assert it return this84        //assert every value is 0.85        assertMatrixEquals(new double[]{86                    1., 5., 9., 13,87                    2., 6., 10, 14,88                    3., 7., 11, 15,89                    4., 8., 12, 16}, m);90    }91    @Test92    public void testCtor() {93        final Matrix4 m = new Matrix4(94                1., 2., 3., 4.,95                5., 6., 7., 8.,96                9., 10, 11, 12,97                13, 14, 15, 16);98        assertMatrixEquals(new double[]{99                    1., 2., 3., 4.,100                    5., 6., 7., 8.,101                    9., 10, 11, 12,102                    13, 14, 15, 16}, m);103    }104    @Test105    public void testAssign() {106        final Matrix4 m = new Matrix4();107        final Matrix4 r = m.assign(108                1., 2., 3., 4.,109                5., 6., 7., 8.,110                9., 10, 11, 12,111                13, 14, 15, 16);112        assertSame(r, m);//assert it return this113        //assert every value is 0.114        assertMatrixEquals(new double[]{115                    1., 2., 3., 4.,116                    5., 6., 7., 8.,117                    9., 10, 11, 12,118                    13, 14, 15, 16}, m);119    }120    @Test121    public void testCtorMatrix() {122        final Matrix4 m = new Matrix4(new Matrix4(123                1., 2., 3., 4.,124                5., 6., 7., 8.,125                9., 10, 11, 12,126                13, 14, 15, 16));127        assertMatrixEquals(new double[]{128                    1., 2., 3., 4.,129                    5., 6., 7., 8.,130                    9., 10, 11, 12,131                    13, 14, 15, 16}, m);132    }133    @Test134    public void testAssignMatrix() {135        final Matrix4 m = new Matrix4();136        final Matrix4 r = m.assign(new Matrix4(137                1., 2., 3., 4.,138                5., 6., 7., 8.,139                9., 10, 11, 12,140                13, 14, 15, 16));141        assertSame(r, m);//assert it return this142        //assert every value is 0.143        assertMatrixEquals(new double[]{144                    1., 2., 3., 4.,145                    5., 6., 7., 8.,146                    9., 10, 11, 12,147                    13, 14, 15, 16}, m);148    }149    @Test150    public void testFtorIdentity() {151        final Matrix4 m = Matrix4.identity();152        final Matrix4 n = Matrix4.identity();153        assertNotSame(n, m);//create a new referene everytime like a ctor154        assertMatrixEquals(new double[]{155                    1., 0., 0., 0.,156                    0., 1., 0., 0.,157                    0., 0., 1., 0.,158                    0., 0., 0., 1.}, m);159    }160    @Test161    public void testAssignIdentity() {162        final Matrix4 m = new Matrix4(163                2., 2., 3., 4.,164                5., 6., 7., 8.,165                9., 10, 11, 12,166                13, 14, 15, 16);167        final Matrix4 r = m.assignIdentity();168        assertSame(r, m);//assert it return this169        assertMatrixEquals(new double[]{170                    1., 0., 0., 0.,171                    0., 1., 0., 0.,172                    0., 0., 1., 0.,173                    0., 0., 0., 1.}, m);174    }175    @Test176    public void testFtorScaleDouble() {177        final Matrix4 m = Matrix4.scaleMatrix(3.);178        final Matrix4 n = Matrix4.scaleMatrix(3.);179        assertNotSame(n, m);//create a new referene everytime like a ctor180        assertMatrixEquals(new double[]{181                    3., 0., 0., 0.,182                    0., 3., 0., 0.,183                    0., 0., 3., 0.,184                    0., 0., 0., 1.}, m);185    }186    @Test187    public void testAssignScaleDouble() {188        final Matrix4 m = new Matrix4(189                1., 0., 0., 0.,190                0., 1., 0., 0.,191                0., 0., 1., 0.,192                0., 0., 0., 1.);193        final Matrix4 r = m.assignScale(3.);194        assertSame(r, m);//assert it return this195        assertMatrixEquals(new double[]{196                    3., 0., 0., 0.,197                    0., 3., 0., 0.,198                    0., 0., 3., 0.,199                    0., 0., 0., 1.}, m);200    }201    @Test202    public void testFtorScale3Double() {203        final Matrix4 m = Matrix4.scaleMatrix(2., 3., 4.);204        final Matrix4 n = Matrix4.scaleMatrix(2., 3., 4.);205        assertNotSame(n, m);//create a new referene everytime like a ctor206        assertMatrixEquals(new double[]{207                    2., 0., 0., 0.,208                    0., 3., 0., 0.,209                    0., 0., 4., 0.,210                    0., 0., 0., 1.}, m);211    }212    @Test213    public void testAssign3Double() {214        final Matrix4 m = new Matrix4(215                1., 2., 3., 4.,216                5., 6., 7., 8.,217                9., 10, 11, 12,218                13, 14, 15, 16);219        final Matrix4 r = m.assignScale(2., 3., 4.);220        assertSame(r, m);//assert it return this221        assertMatrixEquals(new double[]{222                    2., 0., 0., 0.,223                    0., 3., 0., 0.,224                    0., 0., 4., 0.,225                    0., 0., 0., 1.}, m);226    }227    @Test228    public void testMultiply01() {229        final Matrix4 m = new Matrix4(230                1., 2., 3., 4.,231                5., 6., 7., 8.,232                9., 10, 11, 12,233                13, 14, 15, 16);234        final Matrix4 n = new Matrix4(235                10., 20., 30., 40.,236                50., 60., 70., 80.,237                90., 100, 110, 120,238                130, 140, 150, 160);239        final Matrix4 r = m.multiply(n);240        assertNotSame(m, r); // R is new241        assertNotSame(n, r); // R is new242        //Input is not changed243        assertMatrixEquals(new double[]{244                    1., 2., 3., 4.,245                    5., 6., 7., 8.,246                    9., 10, 11, 12,247                    13, 14, 15, 16}, m);248        //Input is not changed249        assertMatrixEquals(new double[]{250                    10., 20., 30., 40.,251                    50., 60., 70., 80.,252                    90., 100, 110, 120,253                    130, 140, 150, 160}, n);254        //Result is ok        255        assertMatrixEquals(new double[]{256                    900.0, 1000.0, 1100.0, 1200.0,257                    2020.0, 2280.0, 2540.0, 2800.0,258                    3140.0, 3560.0, 3980.0, 4400.0,259                    4260.0, 4840.0, 5420.0, 6000.0}, r);260    }261    @Test(expected = NullPointerException.class)262    public void testMultiply02() {263        new Matrix4().multiply((Matrix4) null);264    }265    @Test266    public void testAssignMultiply01() {267        final Matrix4 m = new Matrix4(268                1., 2., 3., 4.,269                5., 6., 7., 8.,270                9., 10, 11, 12,271                13, 14, 15, 16);272        final Matrix4 n = new Matrix4(273                10., 20., 30., 40.,274                50., 60., 70., 80.,275                90., 100, 110, 120,276                130, 140, 150, 160);277        final Matrix4 r = m.assignMultiply(n);278        assertSame(m, r); // r is m279        assertNotSame(n, r); // R is new        280        //Input is not changed281        assertMatrixEquals(new double[]{282                    10., 20., 30., 40.,283                    50., 60., 70., 80.,284                    90., 100, 110, 120,285                    130, 140, 150, 160}, n);286        //Result is ok        287        assertMatrixEquals(new double[]{288                    900.0, 1000.0, 1100.0, 1200.0,289                    2020.0, 2280.0, 2540.0, 2800.0,290                    3140.0, 3560.0, 3980.0, 4400.0,291                    4260.0, 4840.0, 5420.0, 6000.0,}, r);292    }...

Full Screen

Full Screen

Source:BooleanOrNullLiteralInAssertionsCheck.java Github

copy

Full Screen

...17    org.junit.jupiter.api.Assertions.assertFalse(true); // Noncompliant18    org.junit.jupiter.api.Assertions.assertTrue(getBool());19    org.junit.jupiter.api.Assertions.assertFalse(getBool());20    org.junit.jupiter.api.Assertions.assertEquals(true, getBool()); // Noncompliant [[sc=38;ec=50]] {{Use assertTrue instead.}}21    org.junit.jupiter.api.Assertions.assertSame(getBool(), false); // Noncompliant [[sc=38;ec=48]] {{Use assertFalse instead.}}22    org.junit.jupiter.api.Assertions.assertNotEquals(true, getBool()); // Noncompliant {{Use assertFalse instead.}}23    org.junit.jupiter.api.Assertions.assertNotEquals(false, getBool()); // Noncompliant {{Use assertTrue instead.}}24    junit.framework.Assert.assertTrue(true); // Noncompliant25    junit.framework.Assert.assertTrue("message", true); // Noncompliant26    junit.framework.Assert.assertNull("message", true); // Noncompliant27    junit.framework.Assert.assertNotNull(true); // Noncompliant28    junit.framework.Assert.assertTrue(1 > 2);29    junit.framework.Assert.assertFalse(true); // Noncompliant {{Remove or correct this assertion.}}30    org.fest.assertions.Assertions.assertThat(true).isTrue(); // Noncompliant {{Remove or correct this assertion.}}31    org.fest.assertions.Assertions.assertThat(1 > 2).isTrue();32    org.fest.assertions.Assertions.assertThat("foo").isNotNull();33    org.junit.Assert.assertTrue(true); // Noncompliant34    org.junit.Assert.assertThat(true, null); // Noncompliant35    org.junit.Assert.assertThat("", not(false)); // Compliant36    junit.framework.TestCase.assertTrue(true); // Noncompliant37  }38  boolean getBool() {39    return true;40  }41  void nulls() {42    org.junit.Assert.assertNull(null); // Noncompliant {{Remove or correct this assertion.}}43    org.junit.Assert.assertEquals(null, null); // Noncompliant {{Remove or correct this assertion.}}44    org.junit.Assert.assertEquals(null, getObject()); // Noncompliant {{Use assertNull instead.}}45    org.junit.Assert.assertEquals(getObject(), null); // Noncompliant {{Use assertNull instead.}}46    org.junit.Assert.assertNotEquals(null, getObject()); // Noncompliant {{Use assertNotNull instead.}}47    org.junit.Assert.assertNotEquals(getObject(), null); // Noncompliant {{Use assertNotNull instead.}}48    org.junit.Assert.assertSame(null, null); // Noncompliant {{Remove or correct this assertion.}}49    org.junit.Assert.assertSame(null, getObject()); // Noncompliant {{Use assertNull instead.}}50    org.junit.Assert.assertSame(getObject(), null); // Noncompliant {{Use assertNull instead.}}51    org.junit.Assert.assertNotSame(null, getObject()); // Noncompliant {{Use assertNotNull instead.}}52    org.junit.Assert.assertNotSame(getObject(), null); // Noncompliant {{Use assertNotNull instead.}}53    org.junit.Assert.assertNull(getObject()); // Compliant54    org.junit.Assert.assertNotNull(getObject()); // Compliant55    org.junit.Assert.assertEquals("message", getObject(), getObject()); // Compliant56    org.junit.jupiter.api.Assertions.assertNull(null); // Noncompliant {{Remove or correct this assertion.}}57    org.junit.jupiter.api.Assertions.assertEquals((Object) null, null); // Noncompliant {{Remove or correct this assertion.}}58    org.junit.jupiter.api.Assertions.assertEquals(null, getObject()); // Noncompliant {{Use assertNull instead.}}59    org.junit.jupiter.api.Assertions.assertEquals(getObject(), null); // Noncompliant {{Use assertNull instead.}}60    org.junit.jupiter.api.Assertions.assertNotEquals(null, getObject()); // Noncompliant {{Use assertNotNull instead.}}61    org.junit.jupiter.api.Assertions.assertNotEquals(getObject(), null); // Noncompliant {{Use assertNotNull instead.}}62    org.junit.jupiter.api.Assertions.assertSame(null, null); // Noncompliant {{Remove or correct this assertion.}}63    org.junit.jupiter.api.Assertions.assertSame(null, getObject()); // Noncompliant {{Use assertNull instead.}}64    org.junit.jupiter.api.Assertions.assertSame(getObject(), null); // Noncompliant {{Use assertNull instead.}}65    org.junit.jupiter.api.Assertions.assertNotSame(null, getObject()); // Noncompliant {{Use assertNotNull instead.}}66    org.junit.jupiter.api.Assertions.assertNotSame(getObject(), null); // Noncompliant {{Use assertNotNull instead.}}67    org.junit.jupiter.api.Assertions.assertNull(getObject()); // Compliant68    org.junit.jupiter.api.Assertions.assertNotNull(getObject()); // Compliant69    org.junit.jupiter.api.Assertions.assertEquals(getObject(), getObject(), "message"); // Compliant70    junit.framework.Assert.assertNull(null); // Noncompliant {{Remove or correct this assertion.}}71    junit.framework.Assert.assertEquals(null, null); // Noncompliant {{Remove or correct this assertion.}}72    junit.framework.Assert.assertEquals(null, getObject()); // Noncompliant {{Use assertNull instead.}}73    junit.framework.Assert.assertEquals(getObject(), null); // Noncompliant {{Use assertNull instead.}}74    junit.framework.Assert.assertSame(null, null); // Noncompliant {{Remove or correct this assertion.}}75    junit.framework.Assert.assertSame(null, getObject()); // Noncompliant {{Use assertNull instead.}}76    junit.framework.Assert.assertSame(getObject(), null); // Noncompliant {{Use assertNull instead.}}77    junit.framework.Assert.assertNotSame(null, getObject()); // Noncompliant {{Use assertNotNull instead.}}78    junit.framework.Assert.assertNotSame(getObject(), null); // Noncompliant {{Use assertNotNull instead.}}79    junit.framework.Assert.assertNull(getObject()); // Compliant80    junit.framework.Assert.assertNotNull(getObject()); // Compliant81    junit.framework.Assert.assertEquals("message", getObject(), getObject()); // Compliant82    org.fest.assertions.Assertions.assertThat((Object) null).isNull(); // Noncompliant {{Remove or correct this assertion.}}83    org.fest.assertions.Assertions.assertThat((Object) null).isEqualTo(null); // Noncompliant {{Remove or correct this assertion.}}84    org.fest.assertions.Assertions.assertThat((Object) null).isEqualTo(getObject()); // Noncompliant {{Use isNull instead.}}85    org.fest.assertions.Assertions.assertThat(getObject()).isNotEqualTo(null); // Noncompliant {{Use isNotNull instead.}}86    org.fest.assertions.Assertions.assertThat((Object) null).isNotEqualTo(getObject()); // Noncompliant {{Use isNotNull instead.}}87    org.fest.assertions.Assertions.assertThat(getObject()).isEqualTo(null); // Noncompliant {{Use isNull instead.}}88    org.fest.assertions.Assertions.assertThat((Object) null).isSameAs(null); // Noncompliant {{Remove or correct this assertion.}}89    org.fest.assertions.Assertions.assertThat((Object) null).as("description").isSameAs(getObject()); // Noncompliant {{Use isNull instead.}}90    org.fest.assertions.Assertions.assertThat(getObject()).isSameAs(null); // Noncompliant {{Use isNull instead.}}...

Full Screen

Full Screen

Source:AssertTest.java Github

copy

Full Screen

...10	private static final String[] AN_ARRAY = new String[] { "a", "b", "c" };11	private static final Object[] CONTEXT = new Object[0];12	@Test13	public void testAssertSameWhenSame() throws Exception {14		Assert.assertSame(this, this, "foo");15	}16	@Test(expected=AssertionError.class)17	public void testAssertSameWhenDifferent() throws Exception {18		Assert.assertSame("a", "b", "name");19	}20	@Test21	public void testAssertEqualWhenSame() {22		Assert.assertEqual(this, this, "name");23	}24	@Test25	public void testAssertEqualWhenEqual() {26		Assert.assertEqual("a", new String("a"), "name");27	}28	@Test(expected=AssertionError.class)29	public void testAssertEqualWhenNotEqual() {30		Assert.assertEqual("a", "b", "name");31	}32	@Test33	public void testAssertOneOfWhenValuesContainValue() {34		junit.framework.Assert.assertEquals("b", Assert.assertOneOf(AN_ARRAY, "b", "name"));35	}36	@Test(expected=AssertionError.class)37	public void testAssertOneOfWhenValuesDoNotContainValue() {38		Assert.assertOneOf(AN_ARRAY, "d", "name");39	}40	@Test41	public void testAssertTrueWhenTrue() {42		Assert.assertTrue(true, "name", CONTEXT);43	}44	@Test(expected=AssertionError.class)45	public void testAssertTrueWhenFalse() {46		Assert.assertTrue(false, "name", CONTEXT);47	}48	@Test49	public void testAssertNullWhenNull() {50		Assert.assertNull(null, "name");51	}52	@Test(expected=AssertionError.class)53	public void testAssertNullWhenNotNull() {54		Assert.assertNull("a", "name");55	}56	@Test57	public void testAssertStringNotNullOrEmpty() {58		String x = "a";59		junit.framework.Assert.assertSame(x, Assert.assertNotNullOrEmpty(x, "name"));60	}61	@Test(expected=AssertionError.class)62	public void testAssertStringNotNullOrEmptyWhenNull() {63		String c = null;64		Assert.assertNotNullOrEmpty(c, "name");65	}66	@Test(expected=AssertionError.class)67	public void testAssertStringNotNullOrEmptyWhenEmpty() {68		Assert.assertNotNullOrEmpty("", "name");69	}70	@Test71	public void testAssertCollectionNotNullOrEmpty() {72		junit.framework.Assert.assertSame(NON_EMPTY_COLLECTION, Assert.assertNotNullOrEmpty(NON_EMPTY_COLLECTION, "name"));73	}74	@Test(expected=AssertionError.class)75	public void testAssertCollectionNotNullOrEmptyWhenNull() {76		Collection<?> c = null;77		Assert.assertNotNullOrEmpty(c, "name");78	}79	@Test(expected=AssertionError.class)80	public void testAssertCollectionNotNullOrEmptyWhenEmpty() {81		Assert.assertNotNullOrEmpty(Collections.emptyList(), "name");82	}83	@Test84	public void testAssertArrayNotNullOrEmpty() {85		junit.framework.Assert.assertSame(AN_ARRAY, Assert.assertNotNullOrEmpty(AN_ARRAY, "name"));86	}87	@Test(expected=AssertionError.class)88	public void testAssertArrayNotNullOrEmptyWhenNull() {89		Object[] c = null;90		Assert.assertNotNullOrEmpty(c, "name");91	}92	@Test(expected=AssertionError.class)93	public void testAssertArrayNotNullOrEmptyWhenEmpty() {94		Assert.assertNotNullOrEmpty(AN_EMPTY_ARRAY, "name");95	}96	@Test97	public void testAssertGreaterThanOrEqualToWhenEqual() {98		String a = "a";99		String b = "a";100		junit.framework.Assert.assertSame(b, Assert.assertGreaterThanOrEqualTo(a, b, "name"));101	}102	@Test103	public void testAssertGreaterThanOrEqualToWhenGreaterThan() {104		String a = "a";105		String b = "b";106		junit.framework.Assert.assertSame(b, Assert.assertGreaterThanOrEqualTo(a, b, "name"));107	}108	@Test(expected=AssertionError.class)109	public void testAssertGreaterThanOrEqualToWhenLessThan() {110		String a = "b";111		String b = "a";112		Assert.assertGreaterThanOrEqualTo(a, b, "name");113	}114	@Test115	public void testAssertLessThanOrEqualToWhenEqual() {116		String a = "a";117		String b = "a";118		junit.framework.Assert.assertSame(b, Assert.assertLessThanOrEqualTo(a, b, "name"));119	}120	@Test121	public void testAssertLessThanOrEqualToWhenLessThan() {122		String a = "b";123		String b = "a";124		junit.framework.Assert.assertSame(b, Assert.assertLessThanOrEqualTo(a, b, "name"));125	}126	@Test(expected=AssertionError.class)127	public void testAssertLessThanOrEqualToWhenGreaterThan() {128		String a = "a";129		String b = "b";130		Assert.assertLessThanOrEqualTo(a, b, "name");131	}132	@Test(expected=AssertionError.class)133	public void testAssertWithinClosedRangeoWhenLessThanLowerValue() {134		String b = "b";135		String d = "d";136		Assert.assertWithinClosedRange(b, d, "a", "name");137	}138	@Test139	public void testAssertWithinClosedRangeoWhenEqualToLowerValue() {140		String b = "b";141		String d = "d";142		junit.framework.Assert.assertSame(b, Assert.assertWithinClosedRange(b, d, b, "name"));143	}144	@Test145	public void testAssertWithinClosedRangeoWhenInRange() {146		String b = "b";147		String c = "c";148		String d = "d";149		junit.framework.Assert.assertSame(c, Assert.assertWithinClosedRange(b, d, c, "name"));150	}151	@Test152	public void testAssertWithinClosedRangeoWhenEqualToUpperValue() {153		String b = "b";154		String d = "d";155		junit.framework.Assert.assertSame(d, Assert.assertWithinClosedRange(b, d, d, "name"));156	}157	@Test(expected=AssertionError.class)158	public void testAssertWithinClosedRangeoWhenGreaterThanUpoerValue() {159		String b = "b";160		String d = "d";161		Assert.assertWithinClosedRange(b, d, "e", "name");162	}163	@Test(expected=AssertionError.class)164	public void testFail() throws Exception {165		Assert.fail("fail", CONTEXT);166	}167	@Test168	public void testAssertFalseWhenFalse() {169		Assert.assertFalse(false, "name");...

Full Screen

Full Screen

Source:AssertionsWithoutMessageCheck.java Github

copy

Full Screen

...22    org.junit.Assert.assertThat("foo", "bar", null);23    org.junit.Assert.assertThat("foo", new Integer(1), null);24    junit.framework.Assert.assertNotSame("foo", "bar"); // Noncompliant25    junit.framework.Assert.assertNotSame("foo", "foo", "bar");26    junit.framework.Assert.assertSame("foo", "bar"); // Noncompliant27    junit.framework.Assert.assertSame("foo", "foo", "bar");28    org.junit.Assert.fail(); // Noncompliant29    org.junit.Assert.fail("Foo");30    junit.framework.Assert.fail(); // Noncompliant31    junit.framework.Assert.fail("Foo");32    org.fest.assertions.Fail.fail(); // Noncompliant33    org.fest.assertions.Fail.fail("foo");34    org.fest.assertions.Fail.fail("foo",  null);35    org.fest.assertions.Fail.failure("foo");36  }37}...

Full Screen

Full Screen

Source:MoveTest.java Github

copy

Full Screen

...16    public void testPass()17    {18        Move blackPass = Move.getPass(BLACK);19        assertNull(blackPass.getPoint());20        assertSame(blackPass.getColor(), BLACK);21        assertSame(Move.get(BLACK, null), blackPass);22        Move whitePass = Move.getPass(WHITE);23        assertNull(whitePass.getPoint());24        assertSame(whitePass.getColor(), WHITE);25        assertSame(Move.get(WHITE, null), whitePass);26    }27    public void testToString()28    {29        assertEquals("B A1", Move.get(BLACK, 0, 0).toString());30        assertEquals("W PASS", Move.getPass(WHITE).toString());31    }32}

Full Screen

Full Screen

assertSame

Using AI Code Generation

copy

Full Screen

1public void testAssertSame(){2    String str1 = new String("abc");3    String str2 = new String("abc");4    assertSame(str1,str2);5}6public void testAssertSame(){7    String str1 = new String("abc");8    String str2 = str1;9    assertSame(str1,str2);10}11public void testAssertSame(){12    String str1 = new String("abc");13    String str2 = new String("abc");14    assertSame("String objects are not same",str1,str2);15}16public void testAssertSame(){17    String str1 = new String("abc");18    String str2 = str1;19    assertSame("String objects are not same",str1,str2);20}21public void testAssertNotSame(){22    String str1 = new String("abc");23    String str2 = new String("abc");24    assertNotSame(str1,str2);25}26public void testAssertNotSame(){27    String str1 = new String("abc");28    String str2 = str1;29    assertNotSame(str1,str2);30}31public void testAssertNotSame(){32    String str1 = new String("abc");33    String str2 = new String("abc");34    assertNotSame("String objects are same",str1,str2);35}36public void testAssertNotSame(){37    String str1 = new String("abc");38    String str2 = str1;39    assertNotSame("String objects are same",str1,str2);40}41public void testFail(){42    fail();43}44public void testFail(){45    fail("Forced failure");46}47public void testAssertTrue(){48    assertTrue(1>0);49}50public void testAssertTrue(){51    assertTrue("1 is not greater

Full Screen

Full Screen

assertSame

Using AI Code Generation

copy

Full Screen

1package org.junit;2import org.junit.runner.JUnitCore;3import org.junit.runner.Result;4import org.junit.runner.notification.Failure;5public class TestRunner {6    public static void main(String[] args) {7        Result result = JUnitCore.runClasses(TestJunit.class);8        for (Failure failure : result.getFailures()) {9            System.out.println(failure.toString());10        }11        System.out.println(result.wasSuccessful());12    }13}14package org.junit;15import org.junit.Test;16import static org.junit.Assert.*;17public class TestJunit {18    public void testAdd() {19        String str = "Junit is working fine";20        assertEquals("Junit is working fine", str);21    }22    public void testAssertSame() {23        String str = "Junit is working fine";24        assertSame("Junit is working fine", str);25    }26    public void testAssertTrue() {27        String str = "Junit is working fine";28        assertTrue(str.equals("Junit is working fine"));29    }30    public void testAssertFalse() {31        String str = "Junit is working fine";32        assertFalse(str.equals("Junit is working"));33    }34}35at org.junit.Assert.assertEquals(Assert.java:115)36at org.junit.Assert.assertEquals(Assert.java:144)37at org.junit.TestJunit.testAdd(TestJunit.java:11)38at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)39at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)40at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)41at java.lang.reflect.Method.invoke(Method.java:498)42at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)43at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)44at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)45at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

Full Screen

Full Screen

assertSame

Using AI Code Generation

copy

Full Screen

1public class AssertSameTest {2    public void testAssertSame() {3        String expected = "Same";4        String actual = "Same";5        assertSame(expected, actual);6    }7}8public void assertNotSame(Object expected, Object actual)9public class AssertNotSameTest {10    public void testAssertNotSame() {11        String expected = "Same";12        String actual = "Same";13        assertNotSame(expected, actual);14    }15}16testAssertNotSame(AssertNotSameTest)  Time elapsed: 0.001 sec  <<< FAILURE!17    at junit.framework.Assert.assertEquals(Assert.java:81)18    at junit.framework.Assert.assertEquals(Assert.java:87)19    at org.junit.Assert.assertEquals(Assert.java:118)20    at org.junit.Assert.assertEquals(Assert.java:144)21    at AssertNotSameTest.testAssertNotSame(AssertNotSameTest.java:12)

Full Screen

Full Screen

assertSame

Using AI Code Generation

copy

Full Screen

1import junit.framework.Assert;2import org.junit.Test;3import java.util.Arrays;4public class ArraysCompareTest {5   public void testArraysCompare() {6      int[] numbers = {12, 3, 4, 1};7      int[] expected = {12, 3, 4, 1};8      Arrays.sort(numbers);9      Assert.assertArrayEquals(expected, numbers);10   }11}12	at org.junit.Assert.fail(Assert.java:86)13	at org.junit.Assert.failNotEquals(Assert.java:743)14	at org.junit.Assert.assertArrayEquals(Assert.java:457)15	at org.junit.Assert.assertArrayEquals(Assert.java:466)16	at com.javacodegeeks.junit.ArraysCompareTest.testArraysCompare(ArraysCompareTest.java:15)17	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)18	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)19	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)20	at java.lang.reflect.Method.invoke(Method.java:606)21	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)22	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)23	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)24	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)25	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)26	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)27	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)28	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)29	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)30	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)31	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)32	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)33	at org.junit.runners.ParentRunner.run(ParentRunner.java:292)

Full Screen

Full Screen

assertSame

Using AI Code Generation

copy

Full Screen

1import junit.framework.Assert;2import junit.framework.TestCase;3public class Test extends TestCase {4    public void testAssertSame() {5        String str1 = "Hello";6        String str2 = "Hello";7        Assert.assertSame(str1, str2);8    }9    public void testAssertEquals() {10        String str1 = "Hello";11        String str2 = "Hello";12        Assert.assertEquals(str1, str2);13    }14}15OK (1 test)16OK (1 test)

Full Screen

Full Screen

assertSame

Using AI Code Generation

copy

Full Screen

1package com.example.tests;2import junit.framework.Assert;3import org.junit.Test;4public class TestAssertSame {5    public void testAssertSame() {6        String expected = "test";7        String actual = "test";8        Assert.assertSame(expected, actual);9    }10}11Assert.assertSame() method in JUnit12Assert.assertSame() method in JUnit is used to

Full Screen

Full Screen

JUnit Tutorial:

LambdaTest also has a detailed JUnit tutorial explaining its features, importance, advanced use cases, best practices, and more to help you get started with running your automation testing scripts.

JUnit Tutorial Chapters:

Here are the detailed JUnit testing chapters to help you get started:

  • Importance of Unit testing - Learn why Unit testing is essential during the development phase to identify bugs and errors.
  • Top Java Unit testing frameworks - Here are the upcoming JUnit automation testing frameworks that you can use in 2023 to boost your unit testing.
  • What is the JUnit framework
  • Why is JUnit testing important - Learn the importance and numerous benefits of using the JUnit testing framework.
  • Features of JUnit - Learn about the numerous features of JUnit and why developers prefer it.
  • JUnit 5 vs. JUnit 4: Differences - Here is a complete comparison between JUnit 5 and JUnit 4 testing frameworks.
  • Setting up the JUnit environment - Learn how to set up your JUnit testing environment.
  • Getting started with JUnit testing - After successfully setting up your JUnit environment, this chapter will help you get started with JUnit testing in no time.
  • Parallel testing with JUnit - Parallel Testing can be used to reduce test execution time and improve test efficiency. Learn how to perform parallel testing with JUnit.
  • Annotations in JUnit - When writing automation scripts with JUnit, we can use JUnit annotations to specify the type of methods in our test code. This helps us identify those methods when we run JUnit tests using Selenium WebDriver. Learn in detail what annotations are in JUnit.
  • Assertions in JUnit - Assertions are used to validate or test that the result of an action/functionality is the same as expected. Learn in detail what assertions are and how to use them while performing JUnit testing.
  • Parameterization in JUnit - Parameterized Test enables you to run the same automated test scripts with different variables. By collecting data on each method's test parameters, you can minimize time spent on writing tests. Learn how to use parameterization in JUnit.
  • Nested Tests In JUnit 5 - A nested class is a non-static class contained within another class in a hierarchical structure. It can share the state and setup of the outer class. Learn about nested annotations in JUnit 5 with examples.
  • Best practices for JUnit testing - Learn about the best practices, such as always testing key methods and classes, integrating JUnit tests with your build, and more to get the best possible results.
  • Advanced Use Cases for JUnit testing - Take a deep dive into the advanced use cases, such as how to run JUnit tests in Jupiter, how to use JUnit 5 Mockito for Unit testing, and more for JUnit testing.

JUnit Certification:

You can also check out our JUnit certification if you wish to take your career in Selenium automation testing with JUnit to the next level.

Run junit automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful