/* * Copyright (c) 2011 Denis Solonenko. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v2.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ package ru.orangesoftware.financisto2.test.export; import android.test.AndroidTestCase; import ru.orangesoftware.financisto2.test.builders.DateTime; import static ru.orangesoftware.financisto2.export.qif.QifUtils.*; import static ru.orangesoftware.financisto2.export.qif.QifDateFormat.*; /** * Created by IntelliJ IDEA. * User: Denis Solonenko * Date: 10/12/11 12:27 AM */ public class QifUtilsTest extends AndroidTestCase { public void test_should_trim_first_char() { assertEquals("My Cash Account", trimFirstChar("NMy Cash Account")); assertEquals("-10.5", trimFirstChar("X-10.5")); } public void test_should_parse_dates() { assertEquals(DateTime.date(2011, 2, 7).atMidnight().asDate(), parseDate("07/02/2011", EU_FORMAT)); assertEquals(DateTime.date(2011, 2, 7).atMidnight().asDate(), parseDate("07/02/2011", EU_FORMAT)); assertEquals(DateTime.date(2011, 2, 7).atMidnight().asDate(), parseDate("02/07/2011", US_FORMAT)); assertEquals(DateTime.date(2011, 2, 7).atMidnight().asDate(), parseDate("07.02.11", EU_FORMAT)); assertEquals(DateTime.date(2011, 2, 7).atMidnight().asDate(), parseDate("07.02'11", EU_FORMAT)); assertEquals(DateTime.date(2011, 1, 23).atMidnight().asDate(), parseDate("1.23'11", US_FORMAT)); } public void test_should_parse_money() { assertEquals(20, parseMoney(".2")); assertEquals(30, parseMoney(",3")); assertEquals(-40, parseMoney("-.4")); assertEquals(-50, parseMoney("-,5")); assertEquals(100, parseMoney("1.0")); assertEquals(-100, parseMoney("-1.")); assertEquals(101, parseMoney("1,01")); assertEquals(100250, parseMoney("1,002.5")); assertEquals(100250, parseMoney("1.002,5")); assertEquals(-200250, parseMoney("-2.002,5")); } }