def TestCommon(o, is_generated):
    progress('Getting counter')
    counter = o.GetSimpleCounter()
    TestCounter(counter, is_generated)
    progress('Checking default args')
    rc = o.TestOptionals()
    if ((rc[:(- 1)] != ('def', 0, 1)) or (abs((rc[(- 1)] - 3.14)) > 0.01)):
        print(rc)
        raise error('Did not get the optional values correctly')
    rc = o.TestOptionals('Hi', 2, 3, 1.1)
    if ((rc[:(- 1)] != ('Hi', 2, 3)) or (abs((rc[(- 1)] - 1.1)) > 0.01)):
        print(rc)
        raise error('Did not get the specified optional values correctly')
    rc = o.TestOptionals2(0)
    if (rc != (0, '', 1)):
        print(rc)
        raise error('Did not get the optional2 values correctly')
    rc = o.TestOptionals2(1.1, 'Hi', 2)
    if ((rc[1:] != ('Hi', 2)) or (abs((rc[0] - 1.1)) > 0.01)):
        print(rc)
        raise error('Did not get the specified optional2 values correctly')
    progress('Checking getting/passing IUnknown')
    check_get_set(o.GetSetUnknown, o)
    progress('Checking getting/passing IDispatch')
    expected_class = o.__class__
    expected_class = getattr(expected_class, 'default_interface', expected_class)
    if (not isinstance(o.GetSetDispatch(o), expected_class)):
        raise error(('GetSetDispatch failed: %r' % (o.GetSetDispatch(o),)))
    progress('Checking getting/passing IDispatch of known type')
    expected_class = o.__class__
    expected_class = getattr(expected_class, 'default_interface', expected_class)
    if (o.GetSetInterface(o).__class__ != expected_class):
        raise error('GetSetDispatch failed')
    progress('Checking misc args')
    check_get_set(o.GetSetVariant, 4)
    check_get_set(o.GetSetVariant, 'foo')
    check_get_set(o.GetSetVariant, o)
    check_get_set(o.GetSetInt, 0)
    check_get_set(o.GetSetInt, (- 1))
    check_get_set(o.GetSetInt, 1)
    check_get_set(o.GetSetUnsignedInt, 0)
    check_get_set(o.GetSetUnsignedInt, 1)
    check_get_set(o.GetSetUnsignedInt, 2147483648)
    if (o.GetSetUnsignedInt((- 1)) != 4294967295):
        raise error('unsigned -1 failed')
    check_get_set(o.GetSetLong, 0)
    check_get_set(o.GetSetLong, (- 1))
    check_get_set(o.GetSetLong, 1)
    check_get_set(o.GetSetUnsignedLong, 0)
    check_get_set(o.GetSetUnsignedLong, 1)
    check_get_set(o.GetSetUnsignedLong, 2147483648)
    if (o.GetSetUnsignedLong((- 1)) != 4294967295):
        raise error('unsigned -1 failed')
    big = 2147483647
    for l in (big, (big + 1), (1 << 65)):
        check_get_set(o.GetSetVariant, l)
    progress('Checking structs')
    r = o.GetStruct()
    assert ((r.int_value == 99) and (str(r.str_value) == 'Hello from C++'))
    assert (o.DoubleString('foo') == 'foofoo')
    progress('Checking var args')
    o.SetVarArgs('Hi', 'There', 'From', 'Python', 1)
    if (o.GetLastVarArgs() != ('Hi', 'There', 'From', 'Python', 1)):
        raise error(('VarArgs failed -' + str(o.GetLastVarArgs())))
    progress('Checking arrays')
    l = []
    TestApplyResult(o.SetVariantSafeArray, (l,), len(l))
    l = [1, 2, 3, 4]
    TestApplyResult(o.SetVariantSafeArray, (l,), len(l))
    TestApplyResult(o.CheckVariantSafeArray, ((1, 2, 3, 4),), 1)
    TestApplyResult(o.SetBinSafeArray, (str2memory('foo\x00bar'),), 7)
    progress('Checking properties')
    o.LongProp = 3
    if ((o.LongProp != 3) or (o.IntProp != 3)):
        raise error(('Property value wrong - got %d/%d' % (o.LongProp, o.IntProp)))
    o.LongProp = o.IntProp = (- 3)
    if ((o.LongProp != (- 3)) or (o.IntProp != (- 3))):
        raise error(('Property value wrong - got %d/%d' % (o.LongProp, o.IntProp)))
    check = (3 * (10 ** 9))
    o.ULongProp = check
    if (o.ULongProp != check):
        raise error(('Property value wrong - got %d (expected %d)' % (o.ULongProp, check)))
    TestApplyResult(o.Test, ('Unused', 99), 1)
    TestApplyResult(o.Test, ('Unused', (- 1)), 1)
    TestApplyResult(o.Test, ('Unused', (1 == 1)), 1)
    TestApplyResult(o.Test, ('Unused', 0), 0)
    TestApplyResult(o.Test, ('Unused', (1 == 0)), 0)
    assert (o.DoubleString('foo') == 'foofoo')
    TestConstant('ULongTest1', ensure_long(4294967295))
    TestConstant('ULongTest2', ensure_long(2147483647))
    TestConstant('LongTest1', ensure_long((- 2147483647)))
    TestConstant('LongTest2', ensure_long(2147483647))
    TestConstant('UCharTest', 255)
    TestConstant('CharTest', (- 1))
    TestConstant('StringTest', 'Hello Wo®ld')
    progress('Checking dates and times')
    now = win32timezone.now()
    now = now.replace(microsecond=0)
    later = (now + datetime.timedelta(seconds=1))
    TestApplyResult(o.EarliestDate, (now, later), now)
    assert (o.MakeDate(18712.308206013888) == datetime.datetime.fromisoformat('1951-03-25 07:23:49+00:00'))
    progress('Checking currency')
    pythoncom.__future_currency__ = 1
    if (o.CurrencyProp != 0):
        raise error(('Expecting 0, got %r' % (o.CurrencyProp,)))
    for val in ('1234.5678', '1234.56', '1234'):
        o.CurrencyProp = decimal.Decimal(val)
        if (o.CurrencyProp != decimal.Decimal(val)):
            raise error(('%s got %r' % (val, o.CurrencyProp)))
    v1 = decimal.Decimal('1234.5678')
    TestApplyResult(o.DoubleCurrency, (v1,), (v1 * 2))
    v2 = decimal.Decimal('9012.3456')
    TestApplyResult(o.AddCurrencies, (v1, v2), (v1 + v2))
    TestTrickyTypesWithVariants(o, is_generated)
    progress('Checking win32com.client.VARIANT')
    TestPyVariant(o, is_generated)
def TestCommon(o, is_generated):
    progress('Getting counter')
    counter = o.GetSimpleCounter()
    TestCounter(counter, is_generated)
    progress('Checking default args')
    rc = o.TestOptionals()
    if ((rc[:(- 1)] != ('def', 0, 1)) or (abs((rc[(- 1)] - 3.14)) > 0.01)):
        print(rc)
        raise error('Did not get the optional values correctly')
    rc = o.TestOptionals('Hi', 2, 3, 1.1)
    if ((rc[:(- 1)] != ('Hi', 2, 3)) or (abs((rc[(- 1)] - 1.1)) > 0.01)):
        print(rc)
        raise error('Did not get the specified optional values correctly')
    rc = o.TestOptionals2(0)
    if (rc != (0, , 1)):
        print(rc)
        raise error('Did not get the optional2 values correctly')
    rc = o.TestOptionals2(1.1, 'Hi', 2)
    if ((rc[1:] != ('Hi', 2)) or (abs((rc[0] - 1.1)) > 0.01)):
        print(rc)
        raise error('Did not get the specified optional2 values correctly')
    progress('Checking getting/passing IUnknown')
    check_get_set(o.GetSetUnknown, o)
    progress('Checking getting/passing IDispatch')
    expected_class = o.__class__
    expected_class = getattr(expected_class, 'default_interface', expected_class)
    if (not isinstance(o.GetSetDispatch(o), expected_class)):
        raise error(('GetSetDispatch failed: %r' % (o.GetSetDispatch(o),)))
    progress('Checking getting/passing IDispatch of known type')
    expected_class = o.__class__
    expected_class = getattr(expected_class, 'default_interface', expected_class)
    if (o.GetSetInterface(o).__class__ != expected_class):
        raise error('GetSetDispatch failed')
    progress('Checking misc args')
    check_get_set(o.GetSetVariant, 4)
    check_get_set(o.GetSetVariant, 'foo')
    check_get_set(o.GetSetVariant, o)
    check_get_set(o.GetSetInt, 0)
    check_get_set(o.GetSetInt, (- 1))
    check_get_set(o.GetSetInt, 1)
    check_get_set(o.GetSetUnsignedInt, 0)
    check_get_set(o.GetSetUnsignedInt, 1)
    check_get_set(o.GetSetUnsignedInt, 2147483648)
    if (o.GetSetUnsignedInt((- 1)) != 4294967295):
        raise error('unsigned -1 failed')
    check_get_set(o.GetSetLong, 0)
    check_get_set(o.GetSetLong, (- 1))
    check_get_set(o.GetSetLong, 1)
    check_get_set(o.GetSetUnsignedLong, 0)
    check_get_set(o.GetSetUnsignedLong, 1)
    check_get_set(o.GetSetUnsignedLong, 2147483648)
    if (o.GetSetUnsignedLong((- 1)) != 4294967295):
        raise error('unsigned -1 failed')
    big = 2147483647
    for l in (big, (big + 1), (1 << 65)):
        check_get_set(o.GetSetVariant, l)
    progress('Checking structs')
    r = o.GetStruct()
    assert ((r.int_value == 99) and (str(r.str_value) == 'Hello from C++'))
    assert (o.DoubleString('foo') == 'foofoo')
    progress('Checking var args')
    o.SetVarArgs('Hi', 'There', 'From', 'Python', 1)
    if (o.GetLastVarArgs() != ('Hi', 'There', 'From', 'Python', 1)):
        raise error(('VarArgs failed -' + str(o.GetLastVarArgs())))
    progress('Checking arrays')
    l = []
    TestApplyResult(o.SetVariantSafeArray, (l,), len(l))
    l = [1, 2, 3, 4]
    TestApplyResult(o.SetVariantSafeArray, (l,), len(l))
    TestApplyResult(o.CheckVariantSafeArray, ((1, 2, 3, 4),), 1)
    TestApplyResult(o.SetBinSafeArray, (str2memory('foo\x00bar'),), 7)
    progress('Checking properties')
    o.LongProp = 3
    if ((o.LongProp != 3) or (o.IntProp != 3)):
        raise error(('Property value wrong - got %d/%d' % (o.LongProp, o.IntProp)))
    o.LongProp = o.IntProp = (- 3)
    if ((o.LongProp != (- 3)) or (o.IntProp != (- 3))):
        raise error(('Property value wrong - got %d/%d' % (o.LongProp, o.IntProp)))
    check = (3 * (10 ** 9))
    o.ULongProp = check
    if (o.ULongProp != check):
        raise error(('Property value wrong - got %d (expected %d)' % (o.ULongProp, check)))
    TestApplyResult(o.Test, ('Unused', 99), 1)
    TestApplyResult(o.Test, ('Unused', (- 1)), 1)
    TestApplyResult(o.Test, ('Unused', (1 == 1)), 1)
    TestApplyResult(o.Test, ('Unused', 0), 0)
    TestApplyResult(o.Test, ('Unused', (1 == 0)), 0)
    assert (o.DoubleString('foo') == 'foofoo')
    TestConstant('ULongTest1', ensure_long(4294967295))
    TestConstant('ULongTest2', ensure_long(2147483647))
    TestConstant('LongTest1', ensure_long((- 2147483647)))
    TestConstant('LongTest2', ensure_long(2147483647))
    TestConstant('UCharTest', 255)
    TestConstant('CharTest', (- 1))
    TestConstant('StringTest', 'Hello Wo®ld')
    progress('Checking dates and times')
    now = win32timezone.now()
    now = now.replace(microsecond=0)
    later = (now + datetime.timedelta(seconds=1))
    TestApplyResult(o.EarliestDate, (now, later), now)
    assert (o.MakeDate(18712.308206013888) == datetime.datetime.fromisoformat('1951-03-25 07:23:49+00:00'))
    progress('Checking currency')
    pythoncom.__future_currency__ = 1
    if (o.CurrencyProp != 0):
        raise error(('Expecting 0, got %r' % (o.CurrencyProp,)))
    for val in ('1234.5678', '1234.56', '1234'):
        o.CurrencyProp = decimal.Decimal(val)
        if (o.CurrencyProp != decimal.Decimal(val)):
            raise error(('%s got %r' % (val, o.CurrencyProp)))
    v1 = decimal.Decimal('1234.5678')
    TestApplyResult(o.DoubleCurrency, (v1,), (v1 * 2))
    v2 = decimal.Decimal('9012.3456')
    TestApplyResult(o.AddCurrencies, (v1, v2), (v1 + v2))
    TestTrickyTypesWithVariants(o, is_generated)
    progress('Checking win32com.client.VARIANT')
    TestPyVariant(o, is_generated)