def TestCounter(counter, bIsGenerated):
    progress('Testing counter', repr(counter))
    import random
    for i in range(50):
        num = int((random.random() * len(counter)))
        try:
            if bIsGenerated:
                ret = counter.Item((num + 1))
            else:
                ret = counter[num]
            if (ret != (num + 1)):
                raise error(('Random access into element %d failed - return was %s' % (num, repr(ret))))
        except IndexError:
            raise error(('** IndexError accessing collection element %d' % num))
    num = 0
    if bIsGenerated:
        counter.SetTestProperty(1)
        counter.TestProperty = 1
        counter.SetTestProperty(1, 2)
        if (counter.TestPropertyWithDef != 0):
            raise error('Unexpected property set value!')
        if (counter.TestPropertyNoDef(1) != 1):
            raise error('Unexpected property set value!')
    else:
        pass
    counter.LBound = 1
    counter.UBound = 10
    if ((counter.LBound != 1) or (counter.UBound != 10)):
        print('** Error - counter did not keep its properties')
    if bIsGenerated:
        bounds = counter.GetBounds()
        if ((bounds[0] != 1) or (bounds[1] != 10)):
            raise error('** Error - counter did not give the same properties back')
        counter.SetBounds(bounds[0], bounds[1])
    for item in counter:
        num = (num + 1)
    if (num != len(counter)):
        raise error('*** Length of counter and loop iterations dont match ***')
    if (num != 10):
        raise error('*** Unexpected number of loop iterations ***')
    try:
        counter = iter(counter)._iter_.Clone()
    except AttributeError:
        progress('Finished testing counter (but skipped the iterator stuff')
        return
    counter.Reset()
    num = 0
    for item in counter:
        num = (num + 1)
    if (num != 10):
        raise error(('*** Unexpected number of loop iterations - got %d ***' % num))
    progress('Finished testing counter')
def TestCounter(counter, bIsGenerated):
    progress('Testing counter', repr(counter))
    import random
    for i in range(50):
        num = int((random.random() * len(counter)))
        try:
            if bIsGenerated:
                ret = counter.Item((num + 1))
            else:
                ret = counter[num]
            if (ret != (num + 1)):
                raise error(('Random access into element %d failed - return was %s' % (num, repr(ret))))
        except IndexError:
            raise error(('** IndexError accessing collection element %d' % num))
    num = 0
    if bIsGenerated:
        counter.SetTestProperty(1)
        counter.TestProperty = 1
        counter.SetTestProperty(1, 2)
        if (counter.TestPropertyWithDef != 0):
            raise error('Unexpected property set value!')
        if (counter.TestPropertyNoDef(1) != 1):
            raise error('Unexpected property set value!')
    else:
        pass
    counter.LBound = 1
    counter.UBound = 10
    if ((counter.LBound != 1) or (counter.UBound != 10)):
        print('** Error - counter did not keep its properties')
    if bIsGenerated:
        bounds = counter.GetBounds()
        if ((bounds[0] != 1) or (bounds[1] != 10)):
            raise error('** Error - counter did not give the same properties back')
        counter.SetBounds(bounds[0], bounds[1])
    for item in counter:
        num = (num + 1)
    if (num != len(counter)):
        raise error('*** Length of counter and loop iterations dont match ***')
    if (num != 10):
        raise error('*** Unexpected number of loop iterations ***')
    try:
        counter = iter(counter)._iter_.Clone()
    except AttributeError:
        progress('Finished testing counter (but skipped the iterator stuff')
        return
    counter.Reset()
    num = 0
    for item in counter:
        num = (num + 1)
    if (num != 10):
        raise error(('*** Unexpected number of loop iterations - got %d ***' % num))
    progress('Finished testing counter')