# coding=utf-8

import finparse
import pytest


@pytest.mark.parametrize('given, sign, expected', [
    ('$5.00', 1, '$5.00'),
    ('($5.00)', -1, '$5.00'),
    ('(($5.00))', 1, '$5.00'),
    ('($5.00))', -1, '$5.00)'),
    ('(($5.00)', -1, '($5.00'),
    ('$100,000', 1, '$100,000'),
    ('$100,000.', 1, '$100,000.'),
    ('$100,000.111', 1, '$100,000.111'),
    ('$100.000,', 1, '$100.000,'),
    ('-$5.00', -1, '-$5.00'),
    ('-$100,000', -1, '-$100,000'),
    ('-$100,000.', -1, '-$100,000.'),
    ('-$100,000.111', -1, '-$100,000.111'),
    ('-$100.000,', -1, '-$100.000,'),
    ('$-5.00', -1, '$-5.00'),
    ('$-100,000', -1, '$-100,000'),
    ('$-100,000.', -1, '$-100,000.'),
    ('$-100,000.111', -1, '$-100,000.111'),
    ('$-100.000,', -1, '$-100.000,')])
def test_sign(given, sign, expected):
    assert finparse.sign_string(given) == (sign, expected)


@pytest.mark.parametrize('given, decimal, expected', [
    ('$5.00', '.', '5.00'),
    ('($5.00)', '.', '5.00'),
    ('(($5.00))', '.', '5.00'),
    ('($5.00))', '.', '5.00'),
    ('(($5.00)', '.', '5.00'),
    ('$100,000', '.', '100000'),
    ('$100,000.', '.', '100000.'),
    ('$100,000.111', '.', '100000.111'),
    ('$100.000,', ',', '100000,'),
    ('-$5.00', '.', '5.00'),
    ('-$100,000', '.', '100000'),
    ('-$100,000.', '.', '100000.'),
    ('-$100,000.111', '.', '100000.111'),
    ('-$100.000,', ',', '100000,'),
    ('$-5.00', '.', '5.00'),
    ('$-100,000', '.', '100000'),
    ('$-100,000.', '.', '100000.'),
    ('$-100,000.111', '.', '100000.111'),
    ('$-100.000,', ',', '100000,')])
def test_strip(given, decimal, expected):
    assert finparse.strip(given, decimal) == expected


@pytest.mark.parametrize('given, decimal, expected', [
    ('$5.00', '.', 5.),
    ('($5.00)', '.', -5.),
    ('(($5.00))', '.', 5.),
    ('($5.00))', '.', -5.),
    ('(($5.00)', '.', -5.),
    ('$100,000', '.', 100000.),
    ('$100,000.', '.', 100000.),
    ('$100,000.111', '.', 100000.111),
    ('$100.000,', ',', 100000.),
    ('1,234,567.89', '.', 1234567.89),
    ('1234567.89', '.', 1234567.89),
    ('1234567,89', ',', 1234567.89),
    ('1,234,567·89', '·', 1234567.89),
    ('1.234.567,89', ',', 1234567.89),
    ('1˙234˙567,89', ',', 1234567.89),
    ('1\'234\'567.89', '.', 1234567.89),
    ('1\'234\'567,89', ',', 1234567.89),
    ('1.234.567’89', '’', 1234567.89),
    ('1.234.567,89', ',', 1234567.89),
    ('-$5.00', '.', -5.),
    ('-$100,000', '.', -100000.),
    ('-$100,000.', '.', -100000.),
    ('-$100,000.111', '.', -100000.111),
    ('-$100.000,', ',', -100000.),
    ('-1,234,567.89', '.', -1234567.89),
    ('-1234567.89', '.', -1234567.89),
    ('-1234567,89', ',', -1234567.89),
    ('-1,234,567·89', '·', -1234567.89),
    ('-1.234.567,89', ',', -1234567.89),
    ('-1˙234˙567,89', ',', -1234567.89),
    ('-1\'234\'567.89', '.', -1234567.89),
    ('-1\'234\'567,89', ',', -1234567.89),
    ('-1.234.567’89', '’', -1234567.89),
    ('-1.234.567,89', ',', -1234567.89),
    ('$-5.00', '.', -5.),
    ('$-100,000', '.', -100000.),
    ('$-100,000.', '.', -100000.),
    ('$-100,000.111', '.', -100000.111),
    ('$-100.000,', ',', -100000.)])
def test_parse(given, decimal, expected):
    assert finparse.parse(given, decimal) == expected

# coding=utf-8

import finparse
import pytest


@pytest.mark.parametrize('given, sign, expected', [
    ('$5.00', 1, '$5.00'),
    ('($5.00)', -1, '$5.00'),
    ('(($5.00))', 1, '$5.00'),
    ('($5.00))', -1, '$5.00)'),
    ('(($5.00)', -1, '($5.00'),
    ('$100,000', 1, '$100,000'),
    ('$100,000.', 1, '$100,000.'),
    ('$100,000.111', 1, '$100,000.111'),
    ('$100.000,', 1, '$100.000,'),
    ('-$5.00', -1, '-$5.00'),
    ('-$100,000', -1, '-$100,000'),
    ('-$100,000.', -1, '-$100,000.'),
    ('-$100,000.111', -1, '-$100,000.111'),
    ('-$100.000,', -1, '-$100.000,'),
    ('$-5.00', -1, '$-5.00'),
    ('$-100,000', -1, '$-100,000'),
    ('$-100,000.', -1, '$-100,000.'),
    ('$-100,000.111', -1, '$-100,000.111'),
    ('$-100.000,', -1, '$-100.000,')])
def test_sign(given, sign, expected):
    assert finparse.sign_string(given) == (sign, expected)


@pytest.mark.parametrize('given, decimal, expected', [
    ('$5.00', '.', '5.00'),
    ('($5.00)', '.', '5.00'),
    ('(($5.00))', '.', '5.00'),
    ('($5.00))', '.', '5.00'),
    ('(($5.00)', '.', '5.00'),
    ('$100,000', '.', '100000'),
    ('$100,000.', '.', '100000.'),
    ('$100,000.111', '.', '100000.111'),
    ('$100.000,', ',', '100000,'),
    ('-$5.00', '.', '5.00'),
    ('-$100,000', '.', '100000'),
    ('-$100,000.', '.', '100000.'),
    ('-$100,000.111', '.', '100000.111'),
    ('-$100.000,', ',', '100000,'),
    ('$-5.00', '.', '5.00'),
    ('$-100,000', '.', '100000'),
    ('$-100,000.', '.', '100000.'),
    ('$-100,000.111', '.', '100000.111'),
    ('$-100.000,', ',', '100000,')])
def test_strip(given, decimal, expected):
    assert finparse.strip(given, decimal) == expected


@pytest.mark.parametrize('given, decimal, expected', [
    ('$5.00', '.', 5.),
    ('($5.00)', '.', -5.),
    ('(($5.00))', '.', 5.),
    ('($5.00))', '.', -5.),
    ('(($5.00)', '.', -5.),
    ('$100,000', '.', 100000.),
    ('$100,000.', '.', 100000.),
    ('$100,000.111', '.', 100000.111),
    ('$100.000,', ',', 100000.),
    ('1,234,567.89', '.', 1234567.89),
    ('1234567.89', '.', 1234567.89),
    ('1234567,89', ',', 1234567.89),
    ('1,234,567·89', '·', 1234567.89),
    ('1.234.567,89', ',', 1234567.89),
    ('1˙234˙567,89', ',', 1234567.89),
    ('1\'234\'567.89', '.', 1234567.89),
    ('1\'234\'567,89', ',', 1234567.89),
    ('1.234.567’89', '’', 1234567.89),
    ('1.234.567,89', ',', 1234567.89),
    ('-$5.00', '.', -5.),
    ('-$100,000', '.', -100000.),
    ('-$100,000.', '.', -100000.),
    ('-$100,000.111', '.', -100000.111),
    ('-$100.000,', ',', -100000.),
    ('-1,234,567.89', '.', -1234567.89),
    ('-1234567.89', '.', -1234567.89),
    ('-1234567,89', ',', -1234567.89),
    ('-1,234,567·89', '·', -1234567.89),
    ('-1.234.567,89', ',', -1234567.89),
    ('-1˙234˙567,89', ',', -1234567.89),
    ('-1\'234\'567.89', '.', -1234567.89),
    ('-1\'234\'567,89', ',', -1234567.89),
    ('-1.234.567’89', '’', -1234567.89),
    ('-1.234.567,89', ',', -1234567.89),
    ('$-5.00', '.', -5.),
    ('$-100,000', '.', -100000.),
    ('$-100,000.', '.', -100000.),
    ('$-100,000.111', '.', -100000.111),
    ('$-100.000,', ',', -100000.)])
def test_parse(given, decimal, expected):
    assert finparse.parse(given, decimal) == expected

# coding=utf-8