Ejemplo n.º 1
0
def __test__():
    from testing import __ok__, __report__
    print 'Testing geometrical constraint classes...'

    # trivial constraints
    a1 = Anywhere()
    n1 = Nowhere()
    c1 = Circular(V.O, V.X, 1)
    __ok__(isinstance(a1 * a1, Anywhere))
    __ok__(isinstance(a1 * n1, Nowhere))
    __ok__(isinstance(n1 * n1, Nowhere))
    __ok__(isinstance(a1 * c1, Circular))
    __ok__((a1 * c1) is c1)
    __ok__(isinstance(n1 * c1, Nowhere))

    # parametric constraints
    _linear_linear_test()
    _planar_linear_test()
    _planar_planar_test()
    _circular_linear_test()
    _circular_planar_test()
    _circular_circular_test()
    _spherical_linear_test()
    _spherical_planar_test()
    _spherical_circular_test()
    _spherical_spherical_test()

    __report__()
Ejemplo n.º 2
0
def __test__():
    from testing import __ok__, __report__
    import vectors ; from vectors import V,equal,zero

    print 'Testing interpolations...'

    __ok__( linear(0.5, 50, 60), 55 )
    __ok__( linear(1, 2, 1.5, 50, 60), 55 )
    __ok__( linear(1, 2, 1.5, V(50,500), V(60,600)), V(55,550) )

    __ok__( bezier3(0.0,  0.0, 1.0, 0.0), 0.0 )
    __ok__( bezier3(0.5,  0.0, 1.0, 0.0), 0.5 )
    __ok__( equal( bezier3(0.2,  0.0, 1.0, 0.0),
                   bezier3(0.8,  0.0, 1.0, 0.0) ) )
    __ok__( bezier3(1.0,  0.0, 1.0, 0.0), 0.0 )

    __ok__( bezier4(0.0,  0.0, 1.0, 1.0, 0.0), 0.0 )
    __ok__( bezier4(0.5,  0.0, 1.0, 1.0, 0.0), 0.75 )
    __ok__( equal( bezier4(0.2,  0.0, 1.0, 1.0, 0.0),
                   bezier4(0.8,  0.0, 1.0, 1.0, 0.0) ) )
    __ok__( bezier4(1.0,  0.0, 1.0, 1.0, 0.0), 0.0 )

    __ok__( bezier(0.0,  0.0, 1.0, 1.0, 1.0, 0.0), 0.0 )
    __ok__( bezier(0.5,  0.0, 1.0, 1.0, 1.0, 0.0), 0.875 )
    __ok__( equal( bezier(0.2,  0.0, 1.0, 1.0, 1.0, 0.0),
                   bezier(0.8,  0.0, 1.0, 1.0, 1.0, 0.0) ) )
    __ok__( bezier(1.0,  0.0, 1.0, 1.0, 1.0, 0.0), 0.0 )
    __ok__( bezier(1.0,  0.0, 1.0, 1.0, 1.0, 0.0), 0.0 )

    __report__()
Ejemplo n.º 3
0
def __test__():
    import testing
    from testing import __ok__

    __ok__(kana("ko n ni chi ha"), u'\u3053\u3093\u306b\u3061\u306f')
    __ok__(roma(u'\u3053\u3093\u3070\u3093\u306f'), "konbanha")

    __ok__(kana('kyokararyujubyo'),
           u'\u304d\u3087\u304b\u3089\u308a\u3085\u3058\u3045\u3073\u3087')
    __ok__(kana('kyo kara ryu ju byo'), kana('kyokararyujubyo'))
    __ok__(kana('tamagotchi'), u'\u305f\u307e\u3054\u3063\u3061')
    __ok__(kana('tamagotchi'), kana('tamagocchi'))

    __ok__(gyou('wa') == ('wa', 'wo'))
    __ok__(gyou('wa', rare=True) == ('wa', 'wi', 'we', 'wo'))
    __ok__(gyou('chi') == ('ta', 'chi', 'tsu', 'te', 'to'))
    __ok__(gyou('SHI') == ('SA', 'SHI', 'SU', 'SE', 'SO'))

    __ok__(normalize('a'), 'a')
    __ok__(normalize('tsu'), 'ta')
    __ok__(normalize('SHI'), 'SA')
    __ok__(normalize('FU'), 'HA')
    __ok__(normalize('ji'), 'za')
    __ok__(normalize('SHI'), 'SA')
    __ok__(normalize('pa'), 'pa')
    __ok__(normalize('n'), 'n')
    __ok__(normalize(kana('SHI')), kana('SA'))

    __ok__(tenten('gi'), True)
    __ok__(tenten('bi'), True)
    __ok__(tenten('zi'), True)
    __ok__(tenten('GI'), True)
    __ok__(tenten(kana('di')), True)
    __ok__(tenten('ta'), False)
    __ok__(tenten('PI'), False)
    __ok__(tenten(kana('chi')), False)
    __ok__(maru('PU'), True)
    __ok__(maru(kana('pi')), True)
    __ok__(maru('bu'), False)
    __ok__(maru(kana('ji')), False)

    for x in range(3):
        __ok__(choice('hi') in ['ha', 'hi', 'fu', 'he', 'ho'])
        __ok__(choice('MU') in ['MA', 'MI', 'MU', 'ME', 'MO'])
        __ok__(choice(u'\u3072') in [u'\u306f', u'\u3072', u'\u3075',
                                     u'\u3078', u'\u307b'])
        y = choice(family='HIRAGANA')
        __ok__(y, y.lower())
        y = choice(family='katakana')
        __ok__(y, y.upper())

    __ok__(kana('tonbo'), kana('tombo'))
    __ok__(kana("ton'bo"), kana("tonbo"))
    __ok__(roma(kana("tom'bo")), "tonbo")
    __ok__(roma(kana("shitsumon'")), "shitsumon")

    __ok__(html(u'Konnichiwa: \u3053\u3093\u306b\u3061\u306f'),
           'Konnichiwa: こんにちは')

    testing.__report__()
Ejemplo n.º 4
0
def __test__():
    from testing import __ok__, __report__
    print('Testing geometrical constraint classes...')

    # trivial constraints
    a1 = Anywhere()
    n1 = Nowhere()
    c1 = Circular(V.O, V.X, 1)
    __ok__(isinstance(a1 * a1, Anywhere))
    __ok__(isinstance(a1 * n1, Nowhere))
    __ok__(isinstance(n1 * n1, Nowhere))
    __ok__(isinstance(a1 * c1, Circular))
    __ok__((a1 * c1) is c1)
    __ok__(isinstance(n1 * c1, Nowhere))

    # parametric constraints
    _linear_linear_test()
    _planar_linear_test()
    _planar_planar_test()
    _circular_linear_test()
    _circular_planar_test()
    _circular_circular_test()
    _spherical_linear_test()
    _spherical_planar_test()
    _spherical_circular_test()
    _spherical_spherical_test()

    __report__()
Ejemplo n.º 5
0
def __test__():
    '''Run all self-tests.
        % python -c "import octalplus ; octalplus.__test__()" 
    '''
    import testing ; from testing import __ok__
    if not testing.__fails__(): __testMemory()
    if not testing.__fails__(): __testRegisters()
    if not testing.__fails__(): __testAddressing()
    if not testing.__fails__(): __testStack()
    testing.__report__()
Ejemplo n.º 6
0
def __test__():
    from testing import __ok__, __report__

    print('Testing basic math...')

    __ok__(equal(1.0, 1.0), True)
    __ok__(equal(1.0, 1.01), False)
    __ok__(equal(1.0, 1.0001), False)
    __ok__(equal(1.0, 0.9999), False)
    __ok__(equal(1.0, 1.0000001), False)
    __ok__(equal(1.0, 0.9999999), False)
    __ok__(equal(1.0, 1.0000000001), True)
    __ok__(equal(1.0, 0.9999999999), True)

    __ok__(equal(degrees(0), 0.0))
    __ok__(equal(degrees(math.pi/2), 90.0))
    __ok__(equal(degrees(math.pi), 180.0))
    __ok__(equal(radians(0.0), 0.0))
    __ok__(equal(radians(90.0), math.pi/2))
    __ok__(equal(radians(180.0), math.pi))

    print('Testing V vector class...')

    # structural construction
    __ok__(V.O is not None, True)
    __ok__(V.O._v is not None, True)
    __ok__(V.O._v, (0., 0., 0.)) ; __ok__(V.O._l, 0.)
    __ok__(V.X._v, (1., 0., 0.)) ; __ok__(V.X._l, 1.)
    __ok__(V.Y._v, (0., 1., 0.)) ; __ok__(V.Y._l, 1.)
    __ok__(V.Z._v, (0., 0., 1.)) ; __ok__(V.Z._l, 1.)
    a = V(3., 2., 1.) ; __ok__(a._v, [3., 2., 1.])
    a = V((1., 2., 3.)) ; __ok__(a._v, [1., 2., 3.])
    a = V([1., 1., 1.]) ; __ok__(a._v, [1., 1., 1.])
    a = V(0.) ; __ok__(a._v, [0.]) ; __ok__(a._l, 0.)
    a = V(3.) ; __ok__(a._v, [3.]) ; __ok__(a._l, 3.)

    # constants and direct comparisons
    __ok__(V.O, V(0.,0.,0.))
    __ok__(V.X, V(1.,0.,0.))
    __ok__(V.Y, V(0.,1.,0.))
    __ok__(V.Z, V(0.,0.,1.))

    # formatting and elements
    __ok__(repr(V.X), 'V(1.0, 0.0, 0.0)')
    __ok__(V.X[0], 1.)
    __ok__(V.X[1], 0.)
    __ok__(V.X[2], 0.)

    # simple addition
    __ok__(V.X + V.Y, V(1.,1.,0.))
    __ok__(V.Y + V.Z, V(0.,1.,1.))
    __ok__(V.X + V.Z, V(1.,0.,1.))

    # didn't overwrite our constants, did we?
    __ok__(V.X, V(1.,0.,0.))
    __ok__(V.Y, V(0.,1.,0.))
    __ok__(V.Z, V(0.,0.,1.))

    a = V(3.,2.,1.)
    b = a.normalize()
    __ok__(a != b)
    __ok__(a == V(3.,2.,1.))
    __ok__(b.magnitude(), 1)
    b = a.magnitude(5)
    __ok__(a == V(3.,2.,1.))
    __ok__(b.magnitude(), 5)
    __ok__(equal(b.dsquared(V.O), 25))

    a = V(3.,2.,1.).normalize()
    __ok__(equal(a[0], 0.80178372573727319))
    b = V(1.,3.,2.).normalize()
    __ok__(equal(b[2], 0.53452248382484879))
    d = a.dot(b)
    __ok__(equal(d, 0.785714285714), True)

    __ok__(V(2., 2., 1.) * 3, V(6, 6, 3))
    __ok__(3 * V(2., 2., 1.), V(6, 6, 3))
    __ok__(V(2., 2., 1.) / 2, V(1, 1, 0.5))

    v = V(1,2,3)
    w = V(4,5,6)
    __ok__(v.cross(w), V(-3,6,-3))
    __ok__(v.cross(w), v*w)
    __ok__(v*w, -(w*v))
    __ok__(v.dot(w), 32)
    __ok__(v.dot(w), w.dot(v))

    __ok__(zero(angle(V(1,1,1), V(2,2,2))), True)
    __ok__(equal(90.0, degrees(angle(V(1,0,0), V(0,1,0)))), True)
    __ok__(equal(180.0, degrees(angle(V(1,0,0), V(-1,0,0)))), True)

    __ok__(equal(  0.0, degrees(track(V( 1, 0)))), True)
    __ok__(equal( 90.0, degrees(track(V( 0, 1)))), True)
    __ok__(equal(180.0, degrees(track(V(-1, 0)))), True)
    __ok__(equal(270.0, degrees(track(V( 0,-1)))), True)

    __ok__(equal( 45.0, degrees(track(V( 1, 1)))), True)
    __ok__(equal(135.0, degrees(track(V(-1, 1)))), True)
    __ok__(equal(225.0, degrees(track(V(-1,-1)))), True)
    __ok__(equal(315.0, degrees(track(V( 1,-1)))), True)

    print('Testing C complex number class...')

    __ok__(C(1,2) is not None, True)
    __ok__(C(1,2)[0], 1.0)
    __ok__(C(1+2j)[0], 1.0)
    __ok__(C((1,2))[1], 2.0)
    __ok__(C(V([1,2]))[1], 2.0)

    __ok__(C(3+2j) * C(1+4j), C(-5+14j))

    try:
        __ok__(C(1,2,3) is not None, True)
    except TypeError: # takes exactly 2 elements
        __ok__(True, True)

    try:
        __ok__(C([1,2,3]) is not None, True)
    except TypeError: # takes exactly 2 elements
        __ok__(True, True)

    except TypeError: # takes exactly 2 elements
        __ok__(True, True)

    print('Testing Q quaternion class...')

    __ok__(Q(1,2,3,4) is not None, True)
    __ok__(Q(1,2,3,4)[1], 2.0)
    __ok__(Q((1,2,3,4))[2], 3.0)
    __ok__(Q(V(1,2,3,4))[3], 4.0)

    __ok__(Q(), Q(0,0,0,1))
    __ok__(Q(1,2,3,4).conjugate(), Q(-1,-2,-3,4))

    print('Testing M matrix class...')

    m = M()
    __ok__(V(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1), m)
    __ok__(m.row(0), V(1,0,0,0))
    __ok__(m.row(2), V(0,0,1,0))
    __ok__(m.col(1), V(0,1,0,0))
    __ok__(m.col(3), V(0,0,0,1))
    __ok__(m[5], 1.0)
    __ok__(m[1,1], 1.0)
    __ok__(m[6], 0.0)
    __ok__(m[1,2], 0.0)
    __ok__(m * V(1,2,3,4), V(1,2,3,4))
    __ok__(V(1,2,3,4) * m, V(1,2,3,4))
    mm = m * m
    __ok__(mm.__class__, M)
    __ok__(mm, M.I)
    mm = m * 2
    __ok__(mm.__class__, M)
    __ok__(mm, 2.0 * m)
    __ok__(mm[3,3], 2)
    __ok__(mm[3,2], 0)

    __ok__(M.rotate('X',radians(90)),
           M.twist(Q.rotate('X',radians(90))))
    __ok__(M.twist(Q(0,0,0,1)), M.I)
    __ok__(M.twist(Q(.5,0,0,1)),
           M.twist(Q(.5,0,0,1).normalize()))
    __ok__(V.O * M.translate(V(1,2,3)),
           V(1,2,3,1))
    __ok__((V.X+V.Y+V.Z) * M.translate(V(1,2,3)),
           V(2,3,4,1))

    # need some tests on m.determinant()

    m = M()
    m = m.translate(V(1,2,3))
    __ok__(m.inverse(), M().translate(-V(1,2,3)))
    m = m.rotate('Y', radians(30))
    __ok__(m * m.inverse(), M.I)

    __report__()
Ejemplo n.º 7
0
def __test__():
    from testing import __ok__, __report__

    print 'Testing basic math...'

    __ok__(equal(1.0, 1.0), True)
    __ok__(equal(1.0, 1.01), False)
    __ok__(equal(1.0, 1.0001), False)
    __ok__(equal(1.0, 0.9999), False)
    __ok__(equal(1.0, 1.0000001), False)
    __ok__(equal(1.0, 0.9999999), False)
    __ok__(equal(1.0, 1.0000000001), True)
    __ok__(equal(1.0, 0.9999999999), True)

    __ok__(equal(degrees(0), 0.0))
    __ok__(equal(degrees(math.pi / 2), 90.0))
    __ok__(equal(degrees(math.pi), 180.0))
    __ok__(equal(radians(0.0), 0.0))
    __ok__(equal(radians(90.0), math.pi / 2))
    __ok__(equal(radians(180.0), math.pi))

    print 'Testing V vector class...'

    # structural construction
    __ok__(V.O is not None, True)
    __ok__(V.O._v is not None, True)
    __ok__(V.O._v, (0., 0., 0.))
    __ok__(V.O._l, 0.)
    __ok__(V.X._v, (1., 0., 0.))
    __ok__(V.X._l, 1.)
    __ok__(V.Y._v, (0., 1., 0.))
    __ok__(V.Y._l, 1.)
    __ok__(V.Z._v, (0., 0., 1.))
    __ok__(V.Z._l, 1.)
    a = V(3., 2., 1.)
    __ok__(a._v, [3., 2., 1.])
    a = V((1., 2., 3.))
    __ok__(a._v, [1., 2., 3.])
    a = V([1., 1., 1.])
    __ok__(a._v, [1., 1., 1.])
    a = V(0.)
    __ok__(a._v, [0.])
    __ok__(a._l, 0.)
    a = V(3.)
    __ok__(a._v, [3.])
    __ok__(a._l, 3.)

    # constants and direct comparisons
    __ok__(V.O, V(0., 0., 0.))
    __ok__(V.X, V(1., 0., 0.))
    __ok__(V.Y, V(0., 1., 0.))
    __ok__(V.Z, V(0., 0., 1.))

    # formatting and elements
    __ok__(repr(V.X), 'V(1.0, 0.0, 0.0)')
    __ok__(V.X[0], 1.)
    __ok__(V.X[1], 0.)
    __ok__(V.X[2], 0.)

    # simple addition
    __ok__(V.X + V.Y, V(1., 1., 0.))
    __ok__(V.Y + V.Z, V(0., 1., 1.))
    __ok__(V.X + V.Z, V(1., 0., 1.))

    # didn't overwrite our constants, did we?
    __ok__(V.X, V(1., 0., 0.))
    __ok__(V.Y, V(0., 1., 0.))
    __ok__(V.Z, V(0., 0., 1.))

    a = V(3., 2., 1.)
    b = a.normalize()
    __ok__(a != b)
    __ok__(a == V(3., 2., 1.))
    __ok__(b.magnitude(), 1)
    b = a.magnitude(5)
    __ok__(a == V(3., 2., 1.))
    __ok__(b.magnitude(), 5)
    __ok__(equal(b.dsquared(V.O), 25))

    a = V(3., 2., 1.).normalize()
    __ok__(equal(a[0], 0.80178372573727319))
    b = V(1., 3., 2.).normalize()
    __ok__(equal(b[2], 0.53452248382484879))
    d = a.dot(b)
    __ok__(equal(d, 0.785714285714), True)

    __ok__(V(2., 2., 1.) * 3, V(6, 6, 3))
    __ok__(3 * V(2., 2., 1.), V(6, 6, 3))
    __ok__(V(2., 2., 1.) / 2, V(1, 1, 0.5))

    v = V(1, 2, 3)
    w = V(4, 5, 6)
    __ok__(v.cross(w), V(-3, 6, -3))
    __ok__(v.cross(w), v * w)
    __ok__(v * w, -(w * v))
    __ok__(v.dot(w), 32)
    __ok__(v.dot(w), w.dot(v))

    __ok__(zero(angle(V(1, 1, 1), V(2, 2, 2))), True)
    __ok__(equal(90.0, degrees(angle(V(1, 0, 0), V(0, 1, 0)))), True)
    __ok__(equal(180.0, degrees(angle(V(1, 0, 0), V(-1, 0, 0)))), True)

    __ok__(equal(0.0, degrees(track(V(1, 0)))), True)
    __ok__(equal(90.0, degrees(track(V(0, 1)))), True)
    __ok__(equal(180.0, degrees(track(V(-1, 0)))), True)
    __ok__(equal(270.0, degrees(track(V(0, -1)))), True)

    __ok__(equal(45.0, degrees(track(V(1, 1)))), True)
    __ok__(equal(135.0, degrees(track(V(-1, 1)))), True)
    __ok__(equal(225.0, degrees(track(V(-1, -1)))), True)
    __ok__(equal(315.0, degrees(track(V(1, -1)))), True)

    print 'Testing C complex number class...'

    __ok__(C(1, 2) is not None, True)
    __ok__(C(1, 2)[0], 1.0)
    __ok__(C(1 + 2j)[0], 1.0)
    __ok__(C((1, 2))[1], 2.0)
    __ok__(C(V([1, 2]))[1], 2.0)

    __ok__(C(3 + 2j) * C(1 + 4j), C(-5 + 14j))

    try:
        __ok__(C(1, 2, 3) is not None, True)
    except TypeError:  # takes exactly 2 elements
        __ok__(True, True)

    try:
        __ok__(C([1, 2, 3]) is not None, True)
    except TypeError:  # takes exactly 2 elements
        __ok__(True, True)

    except TypeError:  # takes exactly 2 elements
        __ok__(True, True)

    print 'Testing Q quaternion class...'

    __ok__(Q(1, 2, 3, 4) is not None, True)
    __ok__(Q(1, 2, 3, 4)[1], 2.0)
    __ok__(Q((1, 2, 3, 4))[2], 3.0)
    __ok__(Q(V(1, 2, 3, 4))[3], 4.0)

    __ok__(Q(), Q(0, 0, 0, 1))
    __ok__(Q(1, 2, 3, 4).conjugate(), Q(-1, -2, -3, 4))

    print 'Testing M matrix class...'

    m = M()
    __ok__(V(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), m)
    __ok__(m.row(0), V(1, 0, 0, 0))
    __ok__(m.row(2), V(0, 0, 1, 0))
    __ok__(m.col(1), V(0, 1, 0, 0))
    __ok__(m.col(3), V(0, 0, 0, 1))
    __ok__(m[5], 1.0)
    __ok__(m[1, 1], 1.0)
    __ok__(m[6], 0.0)
    __ok__(m[1, 2], 0.0)
    __ok__(m * V(1, 2, 3, 4), V(1, 2, 3, 4))
    __ok__(V(1, 2, 3, 4) * m, V(1, 2, 3, 4))
    mm = m * m
    __ok__(mm.__class__, M)
    __ok__(mm, M.I)
    mm = m * 2
    __ok__(mm.__class__, M)
    __ok__(mm, 2.0 * m)
    __ok__(mm[3, 3], 2)
    __ok__(mm[3, 2], 0)

    __ok__(M.rotate('X', radians(90)), M.twist(Q.rotate('X', radians(90))))
    __ok__(M.twist(Q(0, 0, 0, 1)), M.I)
    __ok__(M.twist(Q(.5, 0, 0, 1)), M.twist(Q(.5, 0, 0, 1).normalize()))
    __ok__(V.O * M.translate(V(1, 2, 3)), V(1, 2, 3, 1))
    __ok__((V.X + V.Y + V.Z) * M.translate(V(1, 2, 3)), V(2, 3, 4, 1))

    # need some tests on m.determinant()

    m = M()
    m = m.translate(V(1, 2, 3))
    __ok__(m.inverse(), M().translate(-V(1, 2, 3)))
    m = m.rotate('Y', radians(30))
    __ok__(m * m.inverse(), M.I)

    __report__()
Ejemplo n.º 8
0
def __test__():
    import testing
    from testing import __ok__

    __ok__(kana("ko n ni chi ha"), u'\u3053\u3093\u306b\u3061\u306f')
    __ok__(roma(u'\u3053\u3093\u3070\u3093\u306f'), "konbanha")

    __ok__(kana('kyokararyujubyo'),
           u'\u304d\u3087\u304b\u3089\u308a\u3085\u3058\u3045\u3073\u3087')
    __ok__(kana('kyo kara ryu ju byo'), kana('kyokararyujubyo'))
    __ok__(kana('tamagotchi'), u'\u305f\u307e\u3054\u3063\u3061')
    __ok__(kana('tamagotchi'), kana('tamagocchi'))

    __ok__(gyou('wa') == ('wa', 'wo'))
    __ok__(gyou('wa', rare=True) == ('wa', 'wi', 'we', 'wo'))
    __ok__(gyou('chi') == ('ta', 'chi', 'tsu', 'te', 'to'))
    __ok__(gyou('SHI') == ('SA', 'SHI', 'SU', 'SE', 'SO'))

    __ok__(normalize('a'), 'a')
    __ok__(normalize('tsu'), 'ta')
    __ok__(normalize('SHI'), 'SA')
    __ok__(normalize('FU'), 'HA')
    __ok__(normalize('ji'), 'za')
    __ok__(normalize('SHI'), 'SA')
    __ok__(normalize('pa'), 'pa')
    __ok__(normalize('n'), 'n')
    __ok__(normalize(kana('SHI')), kana('SA'))

    __ok__(tenten('gi'), True)
    __ok__(tenten('bi'), True)
    __ok__(tenten('zi'), True)
    __ok__(tenten('GI'), True)
    __ok__(tenten(kana('di')), True)
    __ok__(tenten('ta'), False)
    __ok__(tenten('PI'), False)
    __ok__(tenten(kana('chi')), False)
    __ok__(maru('PU'), True)
    __ok__(maru(kana('pi')), True)
    __ok__(maru('bu'), False)
    __ok__(maru(kana('ji')), False)

    for x in range(3):
        __ok__(choice('hi') in ['ha', 'hi', 'fu', 'he', 'ho'])
        __ok__(choice('MU') in ['MA', 'MI', 'MU', 'ME', 'MO'])
        __ok__(
            choice(u'\u3072') in
            [u'\u306f', u'\u3072', u'\u3075', u'\u3078', u'\u307b'])
        y = choice(family='HIRAGANA')
        __ok__(y, y.lower())
        y = choice(family='katakana')
        __ok__(y, y.upper())

    __ok__(kana('tonbo'), kana('tombo'))
    __ok__(kana("ton'bo"), kana("tonbo"))
    __ok__(roma(kana("tom'bo")), "tonbo")
    __ok__(roma(kana("shitsumon'")), "shitsumon")

    __ok__(html(u'Konnichiwa: \u3053\u3093\u306b\u3061\u306f'),
           'Konnichiwa: こんにちは')

    testing.__report__()
Ejemplo n.º 9
0
    p.destroy(id)
    y = fetch(id)
    __ok__(y, None)

    ids = set([])
    timing.start()
    for n in range(1, count+1):
        y = X()
        y.number = n
        id = p.add(y)
        if n < 5:
            __ok__(id in ids, False)
        else:
            if id in ids: __ok__(False, 'id collision on #%d' % n)
        ids.add(id)
    timing.finish()
    print('%g created per second' % (float(n)/(timing.t1-timing.t0)))
    p.close()

    p = DbmStore(name)
    for id in ids:
        p.destroy(id)
    p.close()

    os.unlink(name + '.db')

if __name__ == '__main__':
    from testing import __report__
    __test__()
    __report__()