import logging

from testing_func import testing_func, test_logger
from unit_parse import logger, Unit, Q
from unit_parse.utils import *

test_logger.setLevel(logging.DEBUG)
logger.setLevel(logging.DEBUG)


test_split_list = [
    # positive control (changes)
    [["fish","pig", "cow"], ["f", "is", "h", "pig", "cow"], {"chunks": ["is"]}],
    [["fish", Unit("g"), "cow"], ["f", "is", "h", Unit("g"), "cow"], {"chunks": ["is"]}],
    [["fishpigcow"], ["f", "i", "shpigcow"], {"chunks": ["i"]}],
    [["fishpigcow"], ["f", "i", "shpig", "c", "ow"], {"chunks": ["i", "c"]}],

    # negative control (no changes)
    [["fish"], ["fish"], {"chunks": ["fish"]}],
    [["fishpigcow"], ["fishpigcow"], {"chunks": ["z"]}],
    [[Unit("g")], [Unit("g")], {"chunks": ["is"]}],
]
testing_func(split_list, test_split_list)


test_round_off = [  # [Input, Output]
    # positive control (works)
    [234.2342300000001, 234.23423, {"sig_digit": 15}],
    [234.2342399999999999, 234.23424, {"sig_digit": 15}],
    [234.2342300000001, 234.23, {"sig_digit": 5}],
    [234.2342399999999999, 234.23, {"sig_digit": 5}],
    [234.2342399999999999, 200, {"sig_digit": 1}],
    [-234.2342399999999999, -200, {"sig_digit": 1}],
    [-234.2342399999999999, -234.23424, {"sig_digit": 15}],
    # negative control (fails)

]
testing_func(sig_figs, test_round_off)


test_list_depth = [  # [Input, Output]
    # positive control (works)
    ["", 0],
    [[], 0],
    ["asds", 0],
    [1, 0],
    [["aaa"], 1],
    [[["aaa"]], 2],
    [[["aaa", "aaa", "aaa"], ["aaa"], ["aaa"]], 2],
    [[["aaa", "aaa", "aaa"], ["aaa"], ["aaa"]], 2],
    [[[["aaa"], ["aaa"], ["aaa"]]], 3],

    # negative control (fails)

]
testing_func(get_list_depth, test_list_depth)


test_remove_empty_cells = [  # [Input, Output]
    # positive control (works)
    [[], None],
    [[""], None],
    [["asds"], ["asds"]],
    [1, 1],
    [["aaa", ""], ["aaa"]],
    [["aaa", []], ["aaa"]],
    [[["aaa", []]], [["aaa"]]],
    [[["aaa", [""]]], [["aaa"]]],

    # negative control (fails)

]
testing_func(remove_empty_cells, test_remove_empty_cells)


examples_quantity_difference = [
    [Q("5 g"), Q("0.5"), {"quantity2": Q("10 g")}],

    [5, 1, {"quantity2": Q("10 g")}],
]
testing_func(quantity_difference, examples_quantity_difference)


[((138, 173), 'testing_func.test_logger.setLevel', 'test_logger.setLevel', (['logging.DEBUG'], {}), '(logging.DEBUG)\n', (158, 173), False, 'from testing_func import testing_func, test_logger\n'), ((174, 204), 'unit_parse.logger.setLevel', 'logger.setLevel', (['logging.DEBUG'], {}), '(logging.DEBUG)\n', (189, 204), False, 'from unit_parse import logger, Unit, Q\n'), ((770, 811), 'testing_func.testing_func', 'testing_func', (['split_list', 'test_split_list'], {}), '(split_list, test_split_list)\n', (782, 811), False, 'from testing_func import testing_func, test_logger\n'), ((1299, 1337), 'testing_func.testing_func', 'testing_func', (['sig_figs', 'test_round_off'], {}), '(sig_figs, test_round_off)\n', (1311, 1337), False, 'from testing_func import testing_func, test_logger\n'), ((1682, 1727), 'testing_func.testing_func', 'testing_func', (['get_list_depth', 'test_list_depth'], {}), '(get_list_depth, test_list_depth)\n', (1694, 1727), False, 'from testing_func import testing_func, test_logger\n'), ((2037, 2094), 'testing_func.testing_func', 'testing_func', (['remove_empty_cells', 'test_remove_empty_cells'], {}), '(remove_empty_cells, test_remove_empty_cells)\n', (2049, 2094), False, 'from testing_func import testing_func, test_logger\n'), ((2223, 2286), 'testing_func.testing_func', 'testing_func', (['quantity_difference', 'examples_quantity_difference'], {}), '(quantity_difference, examples_quantity_difference)\n', (2235, 2286), False, 'from testing_func import testing_func, test_logger\n'), ((2135, 2143), 'unit_parse.Q', 'Q', (['"""5 g"""'], {}), "('5 g')\n", (2136, 2143), False, 'from unit_parse import logger, Unit, Q\n'), ((2145, 2153), 'unit_parse.Q', 'Q', (['"""0.5"""'], {}), "('0.5')\n", (2146, 2153), False, 'from unit_parse import logger, Unit, Q\n'), ((355, 364), 'unit_parse.Unit', 'Unit', (['"""g"""'], {}), "('g')\n", (359, 364), False, 'from unit_parse import logger, Unit, Q\n'), ((391, 400), 'unit_parse.Unit', 'Unit', (['"""g"""'], {}), "('g')\n", (395, 400), False, 'from unit_parse import logger, Unit, Q\n'), ((722, 731), 'unit_parse.Unit', 'Unit', (['"""g"""'], {}), "('g')\n", (726, 731), False, 'from unit_parse import logger, Unit, Q\n'), ((735, 744), 'unit_parse.Unit', 'Unit', (['"""g"""'], {}), "('g')\n", (739, 744), False, 'from unit_parse import logger, Unit, Q\n'), ((2169, 2178), 'unit_parse.Q', 'Q', (['"""10 g"""'], {}), "('10 g')\n", (2170, 2178), False, 'from unit_parse import logger, Unit, Q\n'), ((2208, 2217), 'unit_parse.Q', 'Q', (['"""10 g"""'], {}), "('10 g')\n", (2209, 2217), False, 'from unit_parse import logger, Unit, Q\n')]