import os
import sys

root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
sys.path.append(root)

# ----------------------------------------------------------------------------

# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code

# ----------------------------------------------------------------------------
# -*- coding: utf-8 -*-

from ccxt.base.precise import Precise  # noqa E402

def test_precise():
    w = '-1.123e-6'
    x = '0.00000002'
    y = '69696900000'
    z = '0'
    a = '1e8'
    assert Precise.string_mul(x, y) == '1393.938'
    assert Precise.string_mul(y, x) == '1393.938'
    assert Precise.string_add(x, y) == '69696900000.00000002'
    assert Precise.string_add(y, x) == '69696900000.00000002'
    assert Precise.string_sub(x, y) == '-69696899999.99999998'
    assert Precise.string_sub(y, x) == '69696899999.99999998'
    assert Precise.string_div(x, y, 1) == '0'
    assert Precise.string_div(x, y) == '0'
    assert Precise.string_div(x, y, 19) == '0.0000000000000000002'
    assert Precise.string_div(x, y, 20) == '0.00000000000000000028'
    assert Precise.string_div(x, y, 21) == '0.000000000000000000286'
    assert Precise.string_div(x, y, 22) == '0.0000000000000000002869'
    assert Precise.string_div(y, x) == '3484845000000000000'
    assert Precise.string_mul(x, w) == '-0.00000000000002246'
    assert Precise.string_mul(w, x) == '-0.00000000000002246'
    assert Precise.string_add(x, w) == '-0.000001103'
    assert Precise.string_add(w, x) == '-0.000001103'
    assert Precise.string_sub(x, w) == '0.000001143'
    assert Precise.string_sub(w, x) == '-0.000001143'
    assert Precise.string_div(x, w) == '-0.017809439002671415'
    assert Precise.string_div(w, x) == '-56.15'
    assert Precise.string_mul(z, w) == '0'
    assert Precise.string_mul(z, x) == '0'
    assert Precise.string_mul(z, y) == '0'
    assert Precise.string_mul(w, z) == '0'
    assert Precise.string_mul(x, z) == '0'
    assert Precise.string_mul(y, z) == '0'
    assert Precise.string_add(z, w) == '-0.000001123'
    assert Precise.string_add(z, x) == '0.00000002'
    assert Precise.string_add(z, y) == '69696900000'
    assert Precise.string_add(w, z) == '-0.000001123'
    assert Precise.string_add(x, z) == '0.00000002'
    assert Precise.string_add(y, z) == '69696900000'
    assert Precise.string_mul(x, a) == '2'
    assert Precise.string_mul(a, x) == '2'
    assert Precise.string_mul(y, a) == '6969690000000000000'
    assert Precise.string_mul(a, y) == '6969690000000000000'
    assert Precise.string_div(y, a) == '696.969'
    assert Precise.string_div(y, a, -1) == '690'
    assert Precise.string_div(y, a, 0) == '696'
    assert Precise.string_div(y, a, 1) == '696.9'
    assert Precise.string_div(y, a, 2) == '696.96'
    assert Precise.string_div(a, y) == '0.001434784043479695'
    assert Precise.string_abs('0') == '0'
    assert Precise.string_abs('-0') == '0'
    assert Precise.string_abs('-500.1') == '500.1'
    assert Precise.string_abs('213') == '213'
    assert Precise.string_neg('0') == '0'
    assert Precise.string_neg('-0') == '0'
    assert Precise.string_neg('-500.1') == '500.1'
    assert Precise.string_neg('213') == '-213'
    assert Precise.string_mod('57.123', '10') == '7.123'
    assert Precise.string_mod('18', '6') == '0'
    assert Precise.string_mod('10.1', '0.5') == '0.1'
    assert Precise.string_mod('10000000', '5555') == '1000'
    assert Precise.string_mod('5550', '120') == '30'
    assert Precise.string_equals('1.0000', '1')
    assert Precise.string_equals('-0.0', '0')
    assert Precise.string_equals('-0.0', '0.0')
    assert Precise.string_equals('5.534000', '5.5340')
    assert Precise.string_min('1.0000', '2') == '1'
    assert Precise.string_min('2', '1.2345') == '1.2345'
    assert Precise.string_min('3.1415', '-2') == '-2'
    assert Precise.string_min('-3.1415', '-2') == '-3.1415'
    assert Precise.string_min('0.000', '-0.0') == '0'
    assert Precise.string_max('1.0000', '2') == '2'
    assert Precise.string_max('2', '1.2345') == '2'
    assert Precise.string_max('3.1415', '-2') == '3.1415'
    assert Precise.string_max('-3.1415', '-2') == '-2'
    assert Precise.string_max('0.000', '-0.0') == '0'
    assert not Precise.string_gt('1.0000', '2')
    assert Precise.string_gt('2', '1.2345')
    assert Precise.string_gt('3.1415', '-2')
    assert not Precise.string_gt('-3.1415', '-2')
    assert not Precise.string_gt('3.1415', '3.1415')
    assert Precise.string_gt('3.14150000000000000000001', '3.1415')
    assert not Precise.string_ge('1.0000', '2')
    assert Precise.string_ge('2', '1.2345')
    assert Precise.string_ge('3.1415', '-2')
    assert not Precise.string_ge('-3.1415', '-2')
    assert Precise.string_ge('3.1415', '3.1415')
    assert Precise.string_ge('3.14150000000000000000001', '3.1415')
    assert Precise.string_lt('1.0000', '2')
    assert not Precise.string_lt('2', '1.2345')
    assert not Precise.string_lt('3.1415', '-2')
    assert Precise.string_lt('-3.1415', '-2')
    assert not Precise.string_lt('3.1415', '3.1415')
    assert Precise.string_lt('3.1415', '3.14150000000000000000001')
    assert Precise.string_le('1.0000', '2')
    assert not Precise.string_le('2', '1.2345')
    assert not Precise.string_le('3.1415', '-2')
    assert Precise.string_le('-3.1415', '-2')
    assert Precise.string_le('3.1415', '3.1415')
    assert Precise.string_le('3.1415', '3.14150000000000000000001')
