Exemplo n.º 1
0
def test_complement():
    """Test function complement"""
    cunittest.assert_equals(colormodel.RGB(5, 255, 184), a3.complement_rgb(\
                                                        colormodel.RGB(250, 0, 71)))
    cunittest.assert_equals(colormodel.RGB(255, 184, 5), a3.complement_rgb(\
                                                        colormodel.RGB(0, 71, 250)))
    cunittest.assert_equals(colormodel.RGB(184, 5, 255), a3.complement_rgb(\
                                                        colormodel.RGB(71, 250, 0)))
    cunittest.assert_equals(colormodel.RGB(0, 0, 0), a3.complement_rgb(\
                                                        colormodel.RGB(255, 255, 255)))
    cunittest.assert_equals(colormodel.RGB(255, 255, 255), a3.complement_rgb(\
                                                        colormodel.RGB(0, 0, 0)))
Exemplo n.º 2
0
def test_cmyk_to_rgb():
    """Test translation function cmyk_to_rgb"""
    cunittest.assert_equals(colormodel.RGB(0, 0, 0), a3.cmyk_to_rgb(\
                                        colormodel.CMYK(100.0, 100.0, 100.0, 0.000)))
    cunittest.assert_equals(colormodel.RGB(0, 0, 0), a3.cmyk_to_rgb(\
                                        colormodel.CMYK(0.000, 0.000, 0.000, 100.0)))
    cunittest.assert_equals(colormodel.RGB(255, 255, 255), a3.cmyk_to_rgb(\
                                        colormodel.CMYK(0.000, 0.000, 0.000, 0.000)))
    cunittest.assert_equals(colormodel.RGB(89, 45, 134), a3.cmyk_to_rgb(\
                                        colormodel.CMYK(50.00, 75.00, 25.00, 30.00)))
Exemplo n.º 3
0
def test_matrix_vector_mul():
    """Tests the Matrix/Vector Multiplication"""
    m = a5.Matrix(1,2,3.0,4.5)
    v = a5.Vector(1, 2.0)
    n = m * v
    cunittest.assert_equals(5.0, n.x)
    cunittest.assert_equals(12.0, n.y)
    m2 = a5.Matrix()
    v2 = a5.Vector()
    n2 = m2 * v2
    cunittest.assert_equals(0.0, n2.x)
    cunittest.assert_equals(0.0, n2.y)
Exemplo n.º 4
0
def test_vector_addition():
    """Tests the vector addition method"""
    v = a5.Vector()
    w = a5.Vector(1,2)
    z = v+w
    cunittest.assert_equals(1.0, z.x)
    cunittest.assert_equals(2.0, z.y)
    v2 = a5.Vector(2.1, 8.3)
    w2 = a5.Vector(2.0, 6.7)
    z2 = v2+w2
    cunittest.assert_equals(4.1, z2.x)
    cunittest.assert_equals(15.0, z2.y)
Exemplo n.º 5
0
def test_to_strings():
    """Test toString methods"""
    #Test rgb_to_string:()
    cunittest.assert_equals("(30, 240, 230)",
                            a3.rgb_to_string(colormodel.RGB(30, 240, 230)));
    
    #Test cmyk_to_string()
    cunittest.assert_equals("(10.00, 11.00, 20.00, 12.00)",
                            a3.cmyk_to_string(colormodel.CMYK(10, 11, 20, 12)));
    #Test that cmyk_to_string() uses round5(), not `truncate5()`:
    cunittest.assert_equals("(10.01, 11.00, 20.01, 12.00)",
                            a3.cmyk_to_string(colormodel.CMYK(10.005, 11.0045,
                                                              20.009, 12.001)));

    #Test hsv_to_string()
    cunittest.assert_equals("(100.0, 1.000, 1.000)",
                            a3.hsv_to_string(colormodel.HSV(100, 1, 1)));
    #Test that hsv_to_string uses round5(), not `truncate5()`:
    cunittest.assert_equals("(100.0, 0.500, 0.499)",
                            a3.hsv_to_string(colormodel.HSV(99.999, .4996, .4994)));
Exemplo n.º 6
0
def test_to_strings():
    """Test toString methods"""
    #Test rgb_to_string:()
    cunittest.assert_equals("(30, 240, 230)",
                            a3.rgb_to_string(colormodel.RGB(30, 240, 230)))

    #Test cmyk_to_string()
    cunittest.assert_equals("(10.00, 11.00, 20.00, 12.00)",
                            a3.cmyk_to_string(colormodel.CMYK(10, 11, 20, 12)))
    #Test that cmyk_to_string() uses round5(), not `truncate5()`:
    cunittest.assert_equals(
        "(10.01, 11.00, 20.01, 12.00)",
        a3.cmyk_to_string(colormodel.CMYK(10.005, 11.0045, 20.009, 12.001)))

    #Test hsv_to_string()
    cunittest.assert_equals("(100.0, 1.000, 1.000)",
                            a3.hsv_to_string(colormodel.HSV(100, 1, 1)))
    #Test that hsv_to_string uses round5(), not `truncate5()`:
    cunittest.assert_equals(
        "(100.0, 0.500, 0.499)",
        a3.hsv_to_string(colormodel.HSV(99.999, .4996, .4994)))
Exemplo n.º 7
0
def test_complement():
    """Test function complement"""
    cunittest.assert_equals(colormodel.RGB(255 - 250, 255 - 0, 255 - 71), a3.complement_rgb(colormodel.RGB(250, 0, 71)))
    cunittest.assert_equals(colormodel.RGB(255 - 0, 255 - 0, 255 - 0), a3.complement_rgb(colormodel.RGB(0, 0, 0)))
    cunittest.assert_equals(
        colormodel.RGB(255 - 255, 255 - 255, 255 - 255), a3.complement_rgb(colormodel.RGB(255, 255, 255))
    )
Exemplo n.º 8
0
def testC():
    #This function tests the function currency_repsponse()
    answer = currency_response(2.5, 'USD', 'EUR')
    cunittest.assert_equals('{lhs: "2.5 U.S. dollars",rhs: "2.0366598775 Euros",error: "",icc: true}',answer)
    
    answer = currency_response(800, 'CNY', 'TWD')
    cunittest.assert_equals('{lhs: "800 Chinese yuan",rhs: "3768.542893112 Taiwan dollars",error: "",icc: true}',answer)

    answer = currency_response(2.5, 'MERICA', 'SOVIETS')
    cunittest.assert_equals('{lhs: "",rhs: "",error: "4",icc: false}',answer)
Exemplo n.º 9
0
def testC():
    """Tests currency_response()"""
    
    cunittest.assert_equals(
        '{lhs: "1 U.S. dollar",rhs: "4.60600254 Argentine pesos",error: "",icc: true}',
        currency_response(1.0,"USD","ARS"))
    cunittest.assert_equals('{lhs: "",rhs: "",error: "4",icc: false}',
                            currency_response(1.0,"USA","ARS"))
    cunittest.assert_equals('{lhs: "",rhs: "",error: "4",icc: false}',
                            currency_response(1.0,"USD","TRI"))
Exemplo n.º 10
0
def testC():
    """Tests currency_response()"""

    cunittest.assert_equals(
        '{lhs: "1 U.S. dollar",rhs: "4.60600254 Argentine pesos",error: "",icc: true}',
        currency_response(1.0, "USD", "ARS"))
    cunittest.assert_equals('{lhs: "",rhs: "",error: "4",icc: false}',
                            currency_response(1.0, "USA", "ARS"))
    cunittest.assert_equals('{lhs: "",rhs: "",error: "4",icc: false}',
                            currency_response(1.0, "USD", "TRI"))
Exemplo n.º 11
0
def testD():
    #This function tests the functions iscurrency() and exchange()
    #These three test cases are for iscurrency()
    r = iscurrency("JPY")
    cunittest.assert_equals(True,r)
    r = iscurrency("UST")
    cunittest.assert_equals(False,r)
    r = iscurrency("Z Z")
    cunittest.assert_equals(False,r)
    #These three test cases are for exchange()
    r = exchange(100, "USD", "EUR")
    cunittest.assert_floats_equal(81.4663951,r)
    r = exchange(867.589, "CNY", "TWD")
    cunittest.assert_floats_equal(4086.9329501151,r)
    r = exchange(200, "JPY", "JPY")
    cunittest.assert_floats_equal(200,r)
Exemplo n.º 12
0
def test_round5():
    """Test function round5"""
    cunittest.assert_equals("130.6", a3.round5(130.59))
    cunittest.assert_equals("130.5", a3.round5(130.54))
    cunittest.assert_equals("100.0", a3.round5(100))
    cunittest.assert_equals("99.57", a3.round5(99.566))
    cunittest.assert_equals("99.99", a3.round5(99.99))
    cunittest.assert_equals("100.0", a3.round5(99.9951))
    cunittest.assert_equals("22.00", a3.round5(21.99575))
    cunittest.assert_equals("21.99", a3.round5(21.994))
    cunittest.assert_equals("10.01", a3.round5(10.013567))
    cunittest.assert_equals("10.00", a3.round5(10.000000005))
    cunittest.assert_equals("10.00", a3.round5(9.9999))
    cunittest.assert_equals("9.999", a3.round5(9.9993))
    cunittest.assert_equals("1.355", a3.round5(1.3546))
    cunittest.assert_equals("1.354", a3.round5(1.3544))
    cunittest.assert_equals("0.046", a3.round5(.0456))
    cunittest.assert_equals("0.045", a3.round5(.0453))
    cunittest.assert_equals("0.006", a3.round5(.0056))
    cunittest.assert_equals("0.001", a3.round5(.0013))
    cunittest.assert_equals("0.000", a3.round5(.0004))
    cunittest.assert_equals("0.001", a3.round5(.0009999))
Exemplo n.º 13
0
def test_rgb_to_hsv():
    """Test translation function rgb_to_hsv"""
    #Test rgb_to_hsv when MAX = MIN and MAX = 0:
    rgb = colormodel.RGB(0, 0, 0)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("0.000", a3.round5(hsv.hue))
    cunittest.assert_equals("0.000", a3.round5(hsv.saturation))
    cunittest.assert_equals("0.000", a3.round5(hsv.value))

    #Test rgb_to_hsv when MAX = MIN and MAX <> 0:
    rgb = colormodel.RGB(100, 100, 100)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("0.000", a3.round5(hsv.hue))
    cunittest.assert_equals("0.000", a3.round5(hsv.saturation))
    cunittest.assert_equals("0.392", a3.round5(hsv.value))

    #Test rgb_to_hsv when MAX = R and G >=B:
    rgb = colormodel.RGB(161, 42, 42)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("0.000", a3.round5(hsv.hue))
    cunittest.assert_equals("0.739", a3.round5(hsv.saturation))
    cunittest.assert_equals("0.631", a3.round5(hsv.value))

    rgb = colormodel.RGB(161, 72, 42)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("15.13", a3.round5(hsv.hue))
    cunittest.assert_equals("0.739", a3.round5(hsv.saturation))
    cunittest.assert_equals("0.631", a3.round5(hsv.value))

    #Test rgb_to_hsv when MAX = R and G < B:
    rgb = colormodel.RGB(161, 42, 72)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("344.9", a3.round5(hsv.hue))
    cunittest.assert_equals("0.739", a3.round5(hsv.saturation))
    cunittest.assert_equals("0.631", a3.round5(hsv.value))

    #Test rgb_to_hsv when MAX = G:
    rgb = colormodel.RGB(17, 101, 19)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("121.4", a3.round5(hsv.hue))
    cunittest.assert_equals("0.832", a3.round5(hsv.saturation))
    cunittest.assert_equals("0.396", a3.round5(hsv.value))

    #Test rgb_to_hsv when MAX = B:
    rgb = colormodel.RGB(21, 100, 255)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("219.7", a3.round5(hsv.hue))
    cunittest.assert_equals("0.918", a3.round5(hsv.saturation))
    cunittest.assert_equals("1.000", a3.round5(hsv.value))
Exemplo n.º 14
0
def test_hsv_to_rgb():
    """Test translation function hsv_to_rgb"""
    #Test hsv_to_rgb() when H is in the interval [0,60):
    hsv = colormodel.HSV(42, .6, .7)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(179, rgb.red)
    cunittest.assert_equals(146, rgb.green)
    cunittest.assert_equals(71, rgb.blue)

    #Test hsv_to_rgb() when H is in the interval [60,120):
    hsv = colormodel.HSV(94, .5, .5)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(91, rgb.red)
    cunittest.assert_equals(128, rgb.green)
    cunittest.assert_equals(64, rgb.blue)

    #Test hsv_to_rgb() when H is in the interval [120,180):
    #Also tests that hsv_to_rgb() properly handles values at the borders of
    #each interval of H
    hsv = colormodel.HSV(120, .5, .5)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(64, rgb.red)
    cunittest.assert_equals(128, rgb.green)
    cunittest.assert_equals(64, rgb.blue)

    #Test hsv_to_rgb() when H is in the interval [180,240):
    hsv = colormodel.HSV(216, .6, .3)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(31, rgb.red)
    cunittest.assert_equals(49, rgb.green)
    cunittest.assert_equals(77, rgb.blue)

    #Test hsv_to_rgb() when H is in the interval [240,300):
    hsv = colormodel.HSV(256, .2, .8)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(174, rgb.red)
    cunittest.assert_equals(163, rgb.green)
    cunittest.assert_equals(204, rgb.blue)

    #Test hsv_to_rgb() when H is in the interval [300,360):
    hsv = colormodel.HSV(343, .7, .3)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(77, rgb.red)
    cunittest.assert_equals(23, rgb.green)
    cunittest.assert_equals(38, rgb.blue)
Exemplo n.º 15
0
def test_cmyk_to_rgb():
    """Test translation function cmyk_to_rgb"""
    #Test cmyk_to_rgb() when K = 1:
    cmyk = colormodel.CMYK(10, 11, 12, 100)
    rgb = a3.cmyk_to_rgb(cmyk)
    cunittest.assert_equals(0, rgb.red)
    cunittest.assert_equals(0, rgb.green)
    cunittest.assert_equals(0, rgb.blue)

    #Test cmyk_to_rgb() when C, M, or Y = 0:
    cmyk = colormodel.CMYK(0, 11, 12, 0)
    rgb = a3.cmyk_to_rgb(cmyk)
    cunittest.assert_equals(255, rgb.red)
    cunittest.assert_equals(227, rgb.green)
    cunittest.assert_equals(224, rgb.blue)

    cmyk = colormodel.CMYK(10, 0, 12, 0)
    rgb = a3.cmyk_to_rgb(cmyk)
    cunittest.assert_equals(230, rgb.red)
    cunittest.assert_equals(255, rgb.green)
    cunittest.assert_equals(224, rgb.blue)

    cmyk = colormodel.CMYK(10, 11, 0, 0)
    rgb = a3.cmyk_to_rgb(cmyk)
    cunittest.assert_equals(230, rgb.red)
    cunittest.assert_equals(227, rgb.green)
    cunittest.assert_equals(255, rgb.blue)

    #General Test Case
    cmyk = colormodel.CMYK(4, 20, 7, 18.63)
    rgb = a3.cmyk_to_rgb(cmyk)
    cunittest.assert_equals(199, rgb.red)
    cunittest.assert_equals(166, rgb.green)
    cunittest.assert_equals(193, rgb.blue)
Exemplo n.º 16
0
def test_truncate5():
    """Test function truncate5"""
    cunittest.assert_equals("130.5", a3.truncate5(130.59))
    cunittest.assert_equals("130.5", a3.truncate5(130.54))
    cunittest.assert_equals("100.0", a3.truncate5(100))
    cunittest.assert_equals("99.56", a3.truncate5(99.566))
    cunittest.assert_equals("99.99", a3.truncate5(99.99))
    cunittest.assert_equals("99.99", a3.truncate5(99.995))
    cunittest.assert_equals("21.99", a3.truncate5(21.99575))
    cunittest.assert_equals("21.99", a3.truncate5(21.994))
    cunittest.assert_equals("10.01", a3.truncate5(10.013567))
    cunittest.assert_equals("10.00", a3.truncate5(10.000000005))
    cunittest.assert_equals("9.999", a3.truncate5(9.9999))
    cunittest.assert_equals("9.999", a3.truncate5(9.9993))
    cunittest.assert_equals("1.354", a3.truncate5(1.3546))
    cunittest.assert_equals("1.354", a3.truncate5(1.3544))
    cunittest.assert_equals("0.045", a3.truncate5(.0456))
    cunittest.assert_equals("0.045", a3.truncate5(.0453))
    cunittest.assert_equals("0.005", a3.truncate5(.0056))
    cunittest.assert_equals("0.001", a3.truncate5(.0013))
    cunittest.assert_equals("0.000", a3.truncate5(.0004))
    cunittest.assert_equals("0.000", a3.truncate5(.0009999))
Exemplo n.º 17
0
def testA():
    #This function tests the functions before_space() and after_space()
    s = "before after"
    r = before_space(s)
    t = after_space(s)
    cunittest.assert_equals("before",r)
    cunittest.assert_equals("after",t)
    
    s = "123456 currency name"
    r = before_space(s)
    t = after_space(s)
    cunittest.assert_equals("123456",r)
    cunittest.assert_equals("currency name",t)
    
    s = "before    after"
    r = before_space(s)
    t = after_space(s)
    cunittest.assert_equals("before",r)
    cunittest.assert_equals("   after",t)
    
    s = " after"
    r = before_space(s)
    t = after_space(s)
    cunittest.assert_equals("",r)
    cunittest.assert_equals("after",t)
Exemplo n.º 18
0
def test_rgb_to_cmyk():
    """Test rgb_to_cmyk"""
    rgb = colormodel.RGB(255, 255, 255);
    cmyk = a3.rgb_to_cmyk(rgb);
    cunittest.assert_equals("0.000", a3.round5(cmyk.cyan))
    cunittest.assert_equals("0.000", a3.round5(cmyk.magenta))
    cunittest.assert_equals("0.000", a3.round5(cmyk.yellow))
    cunittest.assert_equals("0.000", a3.round5(cmyk.black))
    
    rgb = colormodel.RGB(0, 0, 0); 
    cmyk = a3.rgb_to_cmyk(rgb);
    cunittest.assert_equals("0.000", a3.round5(cmyk.cyan))
    cunittest.assert_equals("0.000", a3.round5(cmyk.magenta))
    cunittest.assert_equals("0.000", a3.round5(cmyk.yellow))
    cunittest.assert_equals("100.0", a3.round5(cmyk.black))

    rgb = colormodel.RGB(217, 43, 164); #R is biggest
    cmyk = a3.rgb_to_cmyk(rgb);
    cunittest.assert_equals("0.000", a3.round5(cmyk.cyan))
    cunittest.assert_equals("80.18", a3.round5(cmyk.magenta))
    cunittest.assert_equals("24.42", a3.round5(cmyk.yellow))
    cunittest.assert_equals("14.90", a3.round5(cmyk.black))
    
    rgb = colormodel.RGB(0, 100, 200); #B is biggest
    cmyk = a3.rgb_to_cmyk(rgb);
    cunittest.assert_equals("100.0", a3.round5(cmyk.cyan))
    cunittest.assert_equals("50.00", a3.round5(cmyk.magenta))
    cunittest.assert_equals("0.000", a3.round5(cmyk.yellow))
    cunittest.assert_equals("21.57", a3.round5(cmyk.black))

    rgb = colormodel.RGB(27, 115, 30); #G is biggest
    cmyk = a3.rgb_to_cmyk(rgb);
    cunittest.assert_equals("76.52", a3.round5(cmyk.cyan))
    cunittest.assert_equals("0.000", a3.round5(cmyk.magenta))
    cunittest.assert_equals("73.91", a3.round5(cmyk.yellow))
    cunittest.assert_equals("54.90", a3.round5(cmyk.black))

    rgb = colormodel.RGB(112, 112, 112); #All equal
    cmyk = a3.rgb_to_cmyk(rgb);
    cunittest.assert_equals("0.000", a3.round5(cmyk.cyan))
    cunittest.assert_equals("0.000", a3.round5(cmyk.magenta))
    cunittest.assert_equals("0.000", a3.round5(cmyk.yellow))
    cunittest.assert_equals("56.08", a3.round5(cmyk.black))
Exemplo n.º 19
0
def test_hsv_to_rgb():
    """Test translation function hsv_to_rgb"""
    #Test hsv_to_rgb() when H is in the interval [0,60):
    hsv = colormodel.HSV(42, .6, .7)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(179, rgb.red)
    cunittest.assert_equals(146, rgb.green)
    cunittest.assert_equals(71, rgb.blue)
    
    #Test hsv_to_rgb() when H is in the interval [60,120):
    hsv = colormodel.HSV(94, .5, .5)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(91, rgb.red)
    cunittest.assert_equals(128, rgb.green)
    cunittest.assert_equals(64, rgb.blue)
    
    #Test hsv_to_rgb() when H is in the interval [120,180):
    #Also tests that hsv_to_rgb() properly handles values at the borders of
    #each interval of H
    hsv = colormodel.HSV(120, .5, .5)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(64, rgb.red)
    cunittest.assert_equals(128, rgb.green)
    cunittest.assert_equals(64, rgb.blue)
    
    #Test hsv_to_rgb() when H is in the interval [180,240):
    hsv = colormodel.HSV(216, .6, .3)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(31, rgb.red)
    cunittest.assert_equals(49, rgb.green)
    cunittest.assert_equals(77, rgb.blue)
    
    #Test hsv_to_rgb() when H is in the interval [240,300):
    hsv = colormodel.HSV(256, .2, .8)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(174, rgb.red)
    cunittest.assert_equals(163, rgb.green)
    cunittest.assert_equals(204, rgb.blue)
    
    #Test hsv_to_rgb() when H is in the interval [300,360):
    hsv = colormodel.HSV(343, .7, .3)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals(77, rgb.red)
    cunittest.assert_equals(23, rgb.green)
    cunittest.assert_equals(38, rgb.blue)
Exemplo n.º 20
0
def test_parse():
    p=parse("(1,2,3)")
    cunittest.assert_equals(1,p.x)
    cunittest.assert_equals(2,p.y)
    cunittest.assert_equals(3,p.z)
Exemplo n.º 21
0
def test_rgb_to_hsv():
    """Test translation function rgb_to_hsv"""
    rgb = colormodel.RGB(255, 255, 255)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("0.000", a3.round5(hsv.hue))
    cunittest.assert_equals("0.000", a3.round5(hsv.saturation))
    cunittest.assert_equals("1.000", a3.round5(hsv.value))

    rgb = colormodel.RGB(0, 0, 0)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("0.000", a3.round5(hsv.hue))
    cunittest.assert_equals("0.000", a3.round5(hsv.saturation))
    cunittest.assert_equals("0.000", a3.round5(hsv.value))

    rgb = colormodel.RGB(217, 43, 164)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("318.3", a3.round5(hsv.hue))
    cunittest.assert_equals("0.802", a3.round5(hsv.saturation))
    cunittest.assert_equals("0.851", a3.round5(hsv.value))
Exemplo n.º 22
0
def test_rgb_to_cmyk():
    """Test rgb_to_cmyk"""
    #Test rgb_to_cmyk() when C = M = Y = 0:
    rgb = colormodel.RGB(255, 255, 255);
    cmyk = a3.rgb_to_cmyk(rgb);
    cunittest.assert_equals("0.000", a3.round5(cmyk.cyan))
    cunittest.assert_equals("0.000", a3.round5(cmyk.magenta))
    cunittest.assert_equals("0.000", a3.round5(cmyk.yellow))
    cunittest.assert_equals("0.000", a3.round5(cmyk.black))
    
    #Test rgb_to_cmyk() when C' = M' = Y' = 1:
    rgb = colormodel.RGB(0, 0, 0);
    cmyk = a3.rgb_to_cmyk(rgb);
    cunittest.assert_equals("0.000", a3.round5(cmyk.cyan))
    cunittest.assert_equals("0.000", a3.round5(cmyk.magenta))
    cunittest.assert_equals("0.000", a3.round5(cmyk.yellow))
    cunittest.assert_equals("100.0", a3.round5(cmyk.black))
    
    #Test rgb_to_cmyk() when C' = K (=> C = 0):
    rgb = colormodel.RGB(217, 43, 164);
    cmyk = a3.rgb_to_cmyk(rgb);
    cunittest.assert_equals("0.000", a3.round5(cmyk.cyan))
    cunittest.assert_equals("80.18", a3.round5(cmyk.magenta))
    cunittest.assert_equals("24.42", a3.round5(cmyk.yellow))
    cunittest.assert_equals("14.90", a3.round5(cmyk.black))
    
    #Test rgb_to_cmyk() when M' = K (=> M = 0):
    rgb = colormodel.RGB(1, 100, 1);
    cmyk = a3.rgb_to_cmyk(rgb);
    cunittest.assert_equals("99.00", a3.round5(cmyk.cyan))
    cunittest.assert_equals("0.000", a3.round5(cmyk.magenta))
    cunittest.assert_equals("99.00", a3.round5(cmyk.yellow))
    cunittest.assert_equals("60.78", a3.round5(cmyk.black))
    
    #Test rgb_to_cmyk() when Y' = K (=> Y = 0):
    rgb = colormodel.RGB(101, 40, 141);
    cmyk = a3.rgb_to_cmyk(rgb);
    cunittest.assert_equals("28.37", a3.round5(cmyk.cyan))
    cunittest.assert_equals("71.63", a3.round5(cmyk.magenta))
    cunittest.assert_equals("0.000", a3.round5(cmyk.yellow))
    cunittest.assert_equals("44.71", a3.round5(cmyk.black))
Exemplo n.º 23
0
def test_complement():
    """Test function complement"""
    cunittest.assert_equals(colormodel.RGB(255 - 250, 255 - 0, 255 - 71),
                            a3.complement_rgb(colormodel.RGB(250, 0, 71)))
Exemplo n.º 24
0
def testA():
    """Tests the functions before_space() and after_space()"""
    
    cunittest.assert_equals("0.814663951",before_space("0.814663951 Euros"))
    cunittest.assert_equals("Euros",after_space("0.814663951 Euros"))
Exemplo n.º 25
0
def testB():
    #This function tests the functions get_lhs() and get_rhs() as well as first_inside_quotes()
    query = '{lhs: "2.5 U.S. dollars",rhs: "2.0366598775 Euros",error: "",icc: true}'
    g = get_lhs(query)
    r = get_rhs(query)
    cunittest.assert_equals('2.5 U.S. dollars',g)
    cunittest.assert_equals('2.0366598775 Euros',r)
    
    query = '{lhs: "500 U.S. dollars",rhs: "39578.8807 Japanese yen",error: "",icc: true}'
    g = get_lhs(query)
    r = get_rhs(query)
    cunittest.assert_equals('500 U.S. dollars',g)
    cunittest.assert_equals('39578.8807 Japanese yen',r)
    
    query = '{lhs: "",rhs: "",error: "4",icc: false}'
    g = get_lhs(query)
    r = get_rhs(query)
    cunittest.assert_equals('',g)
    cunittest.assert_equals('',r)
    
    #This is a test case for first_inside_quotes() only
    s = 'The string "over nine thousand" is in the middle'
    t=first_inside_quotes(s)
    cunittest.assert_equals("over nine thousand",t)
Exemplo n.º 26
0
def test_rgb_to_hsv():
    """Test translation function rgb_to_hsv"""
    #Test rgb_to_hsv when MAX = MIN and MAX = 0:
    rgb = colormodel.RGB(0, 0, 0)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("0.000", a3.round5(hsv.hue))
    cunittest.assert_equals("0.000", a3.round5(hsv.saturation))
    cunittest.assert_equals("0.000", a3.round5(hsv.value))
    
    #Test rgb_to_hsv when MAX = MIN and MAX <> 0:
    rgb = colormodel.RGB(100, 100, 100)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("0.000", a3.round5(hsv.hue))
    cunittest.assert_equals("0.000", a3.round5(hsv.saturation))
    cunittest.assert_equals("0.392", a3.round5(hsv.value))
    
    #Test rgb_to_hsv when MAX = R and G >=B:
    rgb = colormodel.RGB(161, 42, 42)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("0.000", a3.round5(hsv.hue))
    cunittest.assert_equals("0.739", a3.round5(hsv.saturation))
    cunittest.assert_equals("0.631", a3.round5(hsv.value))
    
    rgb = colormodel.RGB(161, 72, 42)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("15.13", a3.round5(hsv.hue))
    cunittest.assert_equals("0.739", a3.round5(hsv.saturation))
    cunittest.assert_equals("0.631", a3.round5(hsv.value))
    
    #Test rgb_to_hsv when MAX = R and G < B:
    rgb = colormodel.RGB(161, 42, 72)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("344.9", a3.round5(hsv.hue))
    cunittest.assert_equals("0.739", a3.round5(hsv.saturation))
    cunittest.assert_equals("0.631", a3.round5(hsv.value))
    
    #Test rgb_to_hsv when MAX = G:
    rgb = colormodel.RGB(17, 101, 19)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("121.4", a3.round5(hsv.hue))
    cunittest.assert_equals("0.832", a3.round5(hsv.saturation))
    cunittest.assert_equals("0.396", a3.round5(hsv.value))
    
    #Test rgb_to_hsv when MAX = B:
    rgb = colormodel.RGB(21, 100, 255)
    hsv = a3.rgb_to_hsv(rgb)
    cunittest.assert_equals("219.7", a3.round5(hsv.hue))
    cunittest.assert_equals("0.918", a3.round5(hsv.saturation))
    cunittest.assert_equals("1.000", a3.round5(hsv.value))
Exemplo n.º 27
0
def testB():
    """Tests first_inside_quotes(), get_lhs(), and get_rhs()"""

    #Test first_inside_quotes():
    cunittest.assert_equals("cake",
                            first_inside_quotes("The \"cake\" is a lie"))
    cunittest.assert_equals("cake",
                            first_inside_quotes("The \"cake\" is a \"lie\""))

    #Test get_lhs():
    cunittest.assert_equals(
        "42 Euros",
        get_lhs(
            '{lhs: "42 Euros",rhs: "171.43569717129 Polish zloty",error: "",icc: true}'
        ))
    cunittest.assert_equals(
        "0.7734 Canadian dollars",
        get_lhs(
            '{lhs: "0.7734 Canadian dollars",rhs: "0.78231730165439 U.S. dollars",error: "",icc: true}'
        ))
    cunittest.assert_equals("",
                            get_lhs('{lhs: "",rhs: "",error: "4",icc: false}'))

    #Test get_rhs():
    cunittest.assert_equals(
        "171.43569717129 Polish zloty",
        get_rhs(
            '{lhs: "42 Euros",rhs: "171.43569717129 Polish zloty",error: "",icc: true}'
        ))
    cunittest.assert_equals(
        "0.78231730165439 U.S. dollars",
        get_rhs(
            '{lhs: "0.7734 Canadian dollars",rhs: "0.78231730165439 U.S. dollars",error: "",icc: true}'
        ))
    cunittest.assert_equals("",
                            get_rhs('{lhs: "",rhs: "",error: "4",icc: false}'))
Exemplo n.º 28
0
def test_rgb_to_cmyk():
    """Test rgb_to_cmyk"""
    #Test rgb_to_cmyk() when C = M = Y = 0:
    rgb = colormodel.RGB(255, 255, 255)
    cmyk = a3.rgb_to_cmyk(rgb)
    cunittest.assert_equals("0.000", a3.round5(cmyk.cyan))
    cunittest.assert_equals("0.000", a3.round5(cmyk.magenta))
    cunittest.assert_equals("0.000", a3.round5(cmyk.yellow))
    cunittest.assert_equals("0.000", a3.round5(cmyk.black))

    #Test rgb_to_cmyk() when C' = M' = Y' = 1:
    rgb = colormodel.RGB(0, 0, 0)
    cmyk = a3.rgb_to_cmyk(rgb)
    cunittest.assert_equals("0.000", a3.round5(cmyk.cyan))
    cunittest.assert_equals("0.000", a3.round5(cmyk.magenta))
    cunittest.assert_equals("0.000", a3.round5(cmyk.yellow))
    cunittest.assert_equals("100.0", a3.round5(cmyk.black))

    #Test rgb_to_cmyk() when C' = K (=> C = 0):
    rgb = colormodel.RGB(217, 43, 164)
    cmyk = a3.rgb_to_cmyk(rgb)
    cunittest.assert_equals("0.000", a3.round5(cmyk.cyan))
    cunittest.assert_equals("80.18", a3.round5(cmyk.magenta))
    cunittest.assert_equals("24.42", a3.round5(cmyk.yellow))
    cunittest.assert_equals("14.90", a3.round5(cmyk.black))

    #Test rgb_to_cmyk() when M' = K (=> M = 0):
    rgb = colormodel.RGB(1, 100, 1)
    cmyk = a3.rgb_to_cmyk(rgb)
    cunittest.assert_equals("99.00", a3.round5(cmyk.cyan))
    cunittest.assert_equals("0.000", a3.round5(cmyk.magenta))
    cunittest.assert_equals("99.00", a3.round5(cmyk.yellow))
    cunittest.assert_equals("60.78", a3.round5(cmyk.black))

    #Test rgb_to_cmyk() when Y' = K (=> Y = 0):
    rgb = colormodel.RGB(101, 40, 141)
    cmyk = a3.rgb_to_cmyk(rgb)
    cunittest.assert_equals("28.37", a3.round5(cmyk.cyan))
    cunittest.assert_equals("71.63", a3.round5(cmyk.magenta))
    cunittest.assert_equals("0.000", a3.round5(cmyk.yellow))
    cunittest.assert_equals("44.71", a3.round5(cmyk.black))
Exemplo n.º 29
0
def testB():
    """Tests first_inside_quotes(), get_lhs(), and get_rhs()"""
    
    #Test first_inside_quotes():
    cunittest.assert_equals("cake",first_inside_quotes("The \"cake\" is a lie"))
    cunittest.assert_equals("cake",
                            first_inside_quotes("The \"cake\" is a \"lie\""))

    #Test get_lhs():
    cunittest.assert_equals("42 Euros",get_lhs(
        '{lhs: "42 Euros",rhs: "171.43569717129 Polish zloty",error: "",icc: true}'))
    cunittest.assert_equals("0.7734 Canadian dollars",
                            get_lhs('{lhs: "0.7734 Canadian dollars",rhs: "0.78231730165439 U.S. dollars",error: "",icc: true}'))
    cunittest.assert_equals("",get_lhs('{lhs: "",rhs: "",error: "4",icc: false}'))
    
    #Test get_rhs():
    cunittest.assert_equals("171.43569717129 Polish zloty",
                            get_rhs('{lhs: "42 Euros",rhs: "171.43569717129 Polish zloty",error: "",icc: true}'))
    cunittest.assert_equals("0.78231730165439 U.S. dollars",
                            get_rhs('{lhs: "0.7734 Canadian dollars",rhs: "0.78231730165439 U.S. dollars",error: "",icc: true}'))
    cunittest.assert_equals("",get_rhs('{lhs: "",rhs: "",error: "4",icc: false}'))
Exemplo n.º 30
0
def test_cmyk_to_rgb():
    """Test translation function cmyk_to_rgb"""
    cmyk = colormodel.CMYK(0.0, 0.0, 0.0, 0.0)
    rgb = a3.cmyk_to_rgb(cmyk)
    cunittest.assert_equals("255.0", a3.round5(rgb.red))
    cunittest.assert_equals("255.0", a3.round5(rgb.green))
    cunittest.assert_equals("255.0", a3.round5(rgb.blue))

    cmyk = colormodel.CMYK(0.0, 0.0, 0.0, 100.0)
    rgb = a3.cmyk_to_rgb(cmyk)
    cunittest.assert_equals("0.000", a3.round5(rgb.red))
    cunittest.assert_equals("0.000", a3.round5(rgb.green))
    cunittest.assert_equals("0.000", a3.round5(rgb.blue))

    cmyk = colormodel.CMYK(35.0, 80.18, 24.42, 14.90)
    rgb = a3.cmyk_to_rgb(cmyk)
    cunittest.assert_equals("141.0", a3.round5(rgb.red))
    cunittest.assert_equals("43.00", a3.round5(rgb.green))
    cunittest.assert_equals("164.0", a3.round5(rgb.blue))
Exemplo n.º 31
0
def test_truncate5():
    """Test function truncate5"""
    cunittest.assert_equals("130.5", a3.truncate5(130.59))
    cunittest.assert_equals("130.5", a3.truncate5(130.54))
    cunittest.assert_equals("100.0", a3.truncate5(100))
    cunittest.assert_equals("99.56", a3.truncate5(99.566))
    cunittest.assert_equals("99.99", a3.truncate5(99.99))
    cunittest.assert_equals("99.99", a3.truncate5(99.995))
    cunittest.assert_equals("21.99", a3.truncate5(21.99575))
    cunittest.assert_equals("21.99", a3.truncate5(21.994))
    cunittest.assert_equals("10.01", a3.truncate5(10.013567))
    cunittest.assert_equals("10.00", a3.truncate5(10.000000005))
    cunittest.assert_equals("9.999", a3.truncate5(9.9999))
    cunittest.assert_equals("9.999", a3.truncate5(9.9993))
    cunittest.assert_equals("1.354", a3.truncate5(1.3546))
    cunittest.assert_equals("1.354", a3.truncate5(1.3544))
    cunittest.assert_equals("0.045", a3.truncate5(0.0456))
    cunittest.assert_equals("0.045", a3.truncate5(0.0453))
    cunittest.assert_equals("0.005", a3.truncate5(0.0056))
    cunittest.assert_equals("0.001", a3.truncate5(0.0013))
    cunittest.assert_equals("0.000", a3.truncate5(0.0004))
    cunittest.assert_equals("0.000", a3.truncate5(0.0009999))
Exemplo n.º 32
0
def test_hsv_to_rgb():
    """Test translation function hsv_to_rgb"""
    hsv = colormodel.HSV(0.0, 0.0, 0.0)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals("0.000", a3.round5(rgb.red))
    cunittest.assert_equals("0.000", a3.round5(rgb.green))
    cunittest.assert_equals("0.000", a3.round5(rgb.blue))

    hsv = colormodel.HSV(0.0, 0.0, 1.0)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals("255.0", a3.round5(rgb.red))
    cunittest.assert_equals("255.0", a3.round5(rgb.green))
    cunittest.assert_equals("255.0", a3.round5(rgb.blue))

    hsv = colormodel.HSV(217.9, 0.567, 0.23)
    rgb = a3.hsv_to_rgb(hsv)
    cunittest.assert_equals("25.00", a3.round5(rgb.red))
    cunittest.assert_equals("38.00", a3.round5(rgb.green))
    cunittest.assert_equals("59.00", a3.round5(rgb.blue))
Exemplo n.º 33
0
def test_to_strings():
    """Test toString methods"""
    cunittest.assert_equals("(30, 240, 230)", a3.rgb_to_string(colormodel.RGB(30, 240, 230)))
    cunittest.assert_equals("(0, 0, 0)", a3.rgb_to_string(colormodel.RGB(0, 0, 0)))
    cunittest.assert_equals("(255, 255, 255)", a3.rgb_to_string(colormodel.RGB(255, 255, 255)))
    cunittest.assert_equals("(0.000, 0.000, 0.000, 0.000)", a3.cmyk_to_string(colormodel.CMYK(0.0, 0.0, 0.0, 0.0)))
    cunittest.assert_equals(
        "(100.0, 100.0, 100.0, 100.0)", a3.cmyk_to_string(colormodel.CMYK(100.0, 100.0, 100.0, 100.0))
    )
    cunittest.assert_equals("(5.000, 56.50, 100.0, 11.60)", a3.cmyk_to_string(colormodel.CMYK(5, 56.5, 100.00, 11.598)))
    cunittest.assert_equals("(359.9, 1.000, 1.000)", a3.hsv_to_string(colormodel.HSV(359.9, 1.0, 1.0)))
    cunittest.assert_equals("(0.000, 0.000, 0.000)", a3.hsv_to_string(colormodel.HSV(0.0, 0.0, 0.0)))
    cunittest.assert_equals("(157.0, 0.568, 0.400)", a3.hsv_to_string(colormodel.HSV(157, 0.56789, 0.4)))
Exemplo n.º 34
0
def test_round5():
    """Test function round5"""
    cunittest.assert_equals("130.6", a3.round5(130.59))
    cunittest.assert_equals("130.5", a3.round5(130.54))
    cunittest.assert_equals("100.0", a3.round5(100))
    cunittest.assert_equals("99.57", a3.round5(99.566))
    cunittest.assert_equals("99.99", a3.round5(99.99))
    cunittest.assert_equals("100.0", a3.round5(99.9951))
    cunittest.assert_equals("22.00", a3.round5(21.99575))
    cunittest.assert_equals("21.99", a3.round5(21.994))
    cunittest.assert_equals("10.01", a3.round5(10.013567))
    cunittest.assert_equals("10.00", a3.round5(10.000000005))
    cunittest.assert_equals("10.00", a3.round5(9.9999))
    cunittest.assert_equals("9.999", a3.round5(9.9993))
    cunittest.assert_equals("1.355", a3.round5(1.3546))
    cunittest.assert_equals("1.354", a3.round5(1.3544))
    cunittest.assert_equals("0.046", a3.round5(0.0456))
    cunittest.assert_equals("0.045", a3.round5(0.0453))
    cunittest.assert_equals("0.006", a3.round5(0.0056))
    cunittest.assert_equals("0.001", a3.round5(0.0013))
    cunittest.assert_equals("0.000", a3.round5(0.0004))
    cunittest.assert_equals("0.001", a3.round5(0.0009999))
Exemplo n.º 35
0
def test_rgb_to_hsv():
    """Test translation function rgb_to_hsv"""
    cunittest.assert_equals(colormodel.HSV(0.000, 0.000, 0.471), a3.rgb_to_hsv(\
                                        colormodel.RGB(120,120,120))) #All equal
    cunittest.assert_equals(colormodel.HSV(10.94, 0.795, 0.784), a3.rgb_to_hsv(\
                                        colormodel.RGB(200,70,41)))   #R > G > B
    cunittest.assert_equals(colormodel.HSV(356.3, 0.696, 0.902), a3.rgb_to_hsv(\
                                        colormodel.RGB(230,70,80)))   #R > G < B
    cunittest.assert_equals(colormodel.HSV(110.7, 0.794, 0.953), a3.rgb_to_hsv(\
                                        colormodel.RGB(80, 243, 50))) #G is highest
    cunittest.assert_equals(colormodel.HSV(229.0, 0.600, 0.784), a3.rgb_to_hsv(\
                                        colormodel.RGB(80, 102, 200)))#B is highest
    cunittest.assert_equals(colormodel.HSV(0.000, 0.000, 0.000), a3.rgb_to_hsv(\
                                        colormodel.RGB(0, 0, 0)))     #All low
    cunittest.assert_equals(colormodel.HSV(0.000, 0.000, 1.000), a3.rgb_to_hsv(\
                                        colormodel.RGB(255, 255, 255))) #All high
Exemplo n.º 36
0
def test_rgb_to_cmyk():
    """Test rgb_to_cmyk"""
    rgb = colormodel.RGB(255, 255, 255)
    cmyk = a3.rgb_to_cmyk(rgb)
    cunittest.assert_equals("0.000", a3.round5(cmyk.cyan))
    cunittest.assert_equals("0.000", a3.round5(cmyk.magenta))
    cunittest.assert_equals("0.000", a3.round5(cmyk.yellow))
    cunittest.assert_equals("0.000", a3.round5(cmyk.black))

    rgb = colormodel.RGB(0, 0, 0)
    cmyk = a3.rgb_to_cmyk(rgb)
    cunittest.assert_equals("0.000", a3.round5(cmyk.cyan))
    cunittest.assert_equals("0.000", a3.round5(cmyk.magenta))
    cunittest.assert_equals("0.000", a3.round5(cmyk.yellow))
    cunittest.assert_equals("100.0", a3.round5(cmyk.black))

    rgb = colormodel.RGB(217, 43, 164)
    cmyk = a3.rgb_to_cmyk(rgb)
    cunittest.assert_equals("0.000", a3.round5(cmyk.cyan))
    cunittest.assert_equals("80.18", a3.round5(cmyk.magenta))
    cunittest.assert_equals("24.42", a3.round5(cmyk.yellow))
    cunittest.assert_equals("14.90", a3.round5(cmyk.black))
Exemplo n.º 37
0
def test_hsv_to_rgb():
    """Test translation function hsv_to_rgb"""
    cunittest.assert_equals(colormodel.RGB(128, 122, 64), a3.hsv_to_rgb(\
                                colormodel.HSV(55, .5, .5)))      #math.floor(H/60) = 0
    cunittest.assert_equals(colormodel.RGB(82, 102, 71), a3.hsv_to_rgb(\
                                colormodel.HSV(100, .3, .4)))      #math.floor(H/60) = 1
    cunittest.assert_equals(colormodel.RGB(96, 145, 100), a3.hsv_to_rgb(\
                                colormodel.HSV(125, .34, .57)))   #math.floor(H/60) = 2
    cunittest.assert_equals(colormodel.RGB(102, 204, 255), a3.hsv_to_rgb(\
                                colormodel.HSV(200, .6, 1.0)))   #math.floor(H/60) = 3
    cunittest.assert_equals(colormodel.RGB(30, 30, 227), a3.hsv_to_rgb(\
                                colormodel.HSV(240, .87, .89)))    #math.floor(H/60) = 4
    cunittest.assert_equals(colormodel.RGB(252, 177, 189), a3.hsv_to_rgb(\
                                colormodel.HSV(350, .3, .99)))   #math.floor(H/60) = 5
Exemplo n.º 38
0
def test_shift():
    p=Point(1,2,3)
    shift(p)
    cunittest.assert_equals(2,p.x)
    cunittest.assert_equals(3,p.y)
    cunittest.assert_equals(1,p.z)
Exemplo n.º 39
0
def test_to_strings():
    """Test toString methods"""
    cunittest.assert_equals("(30, 240, 230)",  a3.rgb_to_string(\
                                        colormodel.RGB(30, 240, 230)))
    cunittest.assert_equals("(0, 0, 0)",  a3.rgb_to_string(\
                                        colormodel.RGB(0, 0, 0)))
    cunittest.assert_equals("(30.00, 80.00, 59.00, 2.000)",  a3.cmyk_to_string(\
                                        colormodel.CMYK(30, 80, 59, 2)))
    cunittest.assert_equals("(30.99, 20.01, 9.256, 40.00)",  a3.cmyk_to_string(\
                                        colormodel.CMYK(30.98795, 20.00976, 9.2563, 40)))
    cunittest.assert_equals("(90.00, 0.280, 0.800)",  a3.hsv_to_string(\
                                        colormodel.HSV(90, .28, .8)))
    cunittest.assert_equals("(90.37, 0.289, 0.995)",  a3.hsv_to_string(\
                                        colormodel.HSV(90.368, .289303, .99508)))
Exemplo n.º 40
0
def test_first_inside_quotes():
    s='The phrase I am trying to extract is "Hello World"'
    substring=first_inside_quotes(s)
    cunittest.assert_equals("Hello World",substring)
Exemplo n.º 41
0
def testA():
    """Tests the functions before_space() and after_space()"""

    cunittest.assert_equals("0.814663951", before_space("0.814663951 Euros"))
    cunittest.assert_equals("Euros", after_space("0.814663951 Euros"))