package Hypotheek; import org.junit.* ; import static org.junit.Assert.* ; import static Hypotheek.Util.* ; public class InkomenBelasting2009_test { static float ACCURACY = 0.001f ; static InkomenBelasting2009 Bref = new InkomenBelasting2009() ; static int TAX_SCHIJF1 = toInt(calcPercentage(Bref.schijf1_taxrate, Bref.schijf1_max)) ; static int BIJD_ZGV_SCHIJF1 = toInt(calcPercentage(Bref.bijdrage_zorgverz_rate, Bref.schijf1_max)) ; static int TAX_SCHIJF2 = TAX_SCHIJF1 + toInt(calcPercentage(Bref.schijf2_taxrate, Bref.schijf2_max - Bref.schijf1_max)) ; static int BIJD_ZGV_SCHIJF2 = toInt(calcPercentage(Bref.bijdrage_zorgverz_rate, Bref.schijf2_max)) ; static int TAX_SCHIJF3 = TAX_SCHIJF2 + toInt(calcPercentage(Bref.schijf3_taxrate, Bref.schijf3_max - Bref.schijf2_max)) ; @Test public void test_tax_a10_S1() { System.out.println(">>> TESTING inkomensbelasting schijf-1, 10-year age ...") ; InkomenBelasting2009 B = new InkomenBelasting2009() ; int inkomen = 100 ; // 100 cent int age = 10 ; int bijdrage_zorgvz = toInt(calcPercentage(Bref.bijdrage_zorgverz_rate,inkomen)) ; //System.out.println(">>> bijdrage_zorgvz: " + bijdrage_zorgvz) ; int expected_tax = toInt(calcPercentage(Bref.schijf1_taxrate,inkomen + bijdrage_zorgvz)) - B.calcArbeidskorting(inkomen, age) ; int tax = B.calcInkomenBelasting(inkomen,age); System.out.println(">>> calculated tax: " + tax + ", expected: " + expected_tax) ; assertTrue(approxEq(tax,expected_tax,ACCURACY)) ; } @Test public void test_tax_a10_S2() { System.out.println(">>> TESTING inkomensbelasting schijf-2, 10-year age ...") ; InkomenBelasting2009 B = new InkomenBelasting2009() ; int D = 1000 ; int age = 10 ; int inkomen = Bref.schijf1_max + D ; // in cent int bijdrage_zorgvz = toInt(calcPercentage(Bref.bijdrage_zorgverz_rate,inkomen)) ; int expected_tax = TAX_SCHIJF1 + toInt(calcPercentage(Bref.schijf2_taxrate, D + bijdrage_zorgvz)) - B.calcArbeidskorting(inkomen, age) ; int tax = B.calcInkomenBelasting(inkomen,age); System.out.println(">>> calculated tax: " + tax + ", expected: " + expected_tax) ; assertTrue(approxEq(tax,expected_tax,ACCURACY)) ; } @Test public void test_tax_a10_S3() { System.out.println(">>> TESTING inkomensbelasting schijf-3, 10-year age ...") ; InkomenBelasting2009 B = new InkomenBelasting2009() ; int D = 2000 ; int age = 10 ; int inkomen = Bref.schijf2_max + D ; // in cent int bijdrage_zorgvz = toInt(calcPercentage(Bref.bijdrage_zorgverz_rate,inkomen)) ; int expected_tax = TAX_SCHIJF2 + toInt(calcPercentage(Bref.schijf3_taxrate, D + bijdrage_zorgvz)) - B.calcArbeidskorting(inkomen, age) ; int tax = B.calcInkomenBelasting(inkomen,age); System.out.println(">>> calculated tax: " + tax + ", expected: " + expected_tax) ; assertTrue(approxEq(tax,expected_tax,ACCURACY)) ; } @Test public void test_tax_a10_S4() { System.out.println(">>> TESTING inkomensbelasting schijf-4, 10-year age ...") ; InkomenBelasting2009 B = new InkomenBelasting2009() ; int D = 2000 ; int age = 10 ; int inkomen = Bref.schijf3_max + D ; // in cent // System.out.println(">>> S3 tax = " + TAX_SCHIJF3) ; int bijdrage_zorgvz = B.calcBijdrageZorgverzekering(inkomen, age) ; int expected_tax = TAX_SCHIJF3 + toInt(calcPercentage(Bref.schijf4_taxrate, D + bijdrage_zorgvz)) - B.calcArbeidskorting(inkomen, age) ; int tax = B.calcInkomenBelasting(inkomen,age); System.out.println(">>> calculated tax: " + tax + ", expected: " + expected_tax) ; assertTrue(approxEq(tax,expected_tax,ACCURACY)) ; } @Test public void test_tax_allAges_S4() { System.out.println(">>> TESTING inkomensbelasting schijf-4, various ages ...") ; InkomenBelasting2009 B = new InkomenBelasting2009() ; int D = 2000 ; int inkomen = Bref.schijf3_max + D ; // in cent for (int age=0; age<=70; age++) { int bijdrage_zorgvz = B.calcBijdrageZorgverzekering(inkomen, age) ; int expected_tax = TAX_SCHIJF3 + toInt(calcPercentage(Bref.schijf4_taxrate, D + bijdrage_zorgvz)) - B.calcArbeidskorting(inkomen, age) ; int tax = B.calcInkomenBelasting(inkomen,age); System.out.println(">>> age " + age + ", calculated tax: " + tax + ", expected: " + expected_tax) ; assertTrue(approxEq(tax,expected_tax,ACCURACY)) ; } } }