Ejemplo n.º 1
0
 def test_format_units_v_step_si(self):
     # Tests (input, step, result, 'Error String')
     tests = [
         (1, 100, 1, "format_units(1, 100, 'si') != 1"),
         (1.0, 100, 1.0, "format_units(1.0, 100, 'si') != 1.0"),
         (0.001, 100, 0.001, "format_units(0.001, 100, 'si') != 0.001"),
     ]
     for (t, s, r, e) in tests:
         self.assertEqual(glyph.format_units(t, s, "si"), (r, ""), e)
Ejemplo n.º 2
0
 def test_format_units_val_None_defaults(self):
     # Tests (input, result, 'Error String')
     tests = [
         (1, 1, "format_units(1, None) != 1"),
         (1.0, 1.0, "format_units(1.0, None) != 1.0"),
         (0.001, 0.001, "format_units(0.001, None) != 0.001"),
     ]
     for (t, r, e) in tests:
         self.assertEqual(glyph.format_units(t, None), (r, ""), e)
 def test_format_units_val_None_defaults(self):
     # Tests (input, result, prefix, 'Error String')
     tests = [
         (1, 1, '', 'format_units(1, None) != 1'),
         (1.0, 1.0, '', 'format_units(1.0, None) != 1.0'),
         (0.001, 0.001, '', 'format_units(0.001, None) != 0.001'),
         (1000, 1.0, 'k', 'format_units(1000, None) != 1.0 k'),
         (1000000, 1.0, 'M', 'format_units(1000000, None) != 1.0 M'),
     ]
     for (t, r, p, e) in tests:
         self.assertEqual(glyph.format_units(t, None), (r, p), e)
Ejemplo n.º 4
0
 def test_format_units_v_step_si_units(self):
   # Tests (input, step, result, prefix, 'Error String')
   tests = [
            (1, 100, 1, 'b', 'format_units(1, 100, \'si\', \'b\') != 1'),
            (1.0, 100, 1.0, 'b', 'format_units(1.0, 100, \'si\', \'b\') != 1.0'),
            (0.001, 100, 0.001, 'b', 'format_units(0.001, 100, \'si\', \'b\') != 0.001'),
            (1000, 100, 1000.0, 'b', 'format_units(1000, 100, \'si\', \'b\') != 1000.0'),
            (1000000, 100, 1000000.0, 'b', 'format_units(1000000, 100, \'si\', \'b\') != 1000000.0'),
           ]
   for (t,s,r,p,e) in tests:
       self.assertEqual(glyph.format_units(t, s, 'si', 'b'), (r, p), e)
Ejemplo n.º 5
0
 def test_format_units_v_None_si(self):
   # Tests (input, result, prefix, 'Error String')
   tests = [
            (1, 1, '', 'format_units(1, None, \'si\') != 1'),
            (1.0, 1.0, '', 'format_units(1.0, None, \'si\') != 1.0'),
            (0.001, 0.001, '', 'format_units(0.001, None, \'si\') != 0.001'),
            (1000, 1.0, 'k', 'format_units(1000, None, \'si\') != 1.0 k'),
            (1000000, 1.0, 'M', 'format_units(1000000, None, \'si\') != 1.0 M'),
           ]
   for (t,r,p,e) in tests:
       self.assertEqual(glyph.format_units(t, None, 'si'), (r, p), e)
Ejemplo n.º 6
0
 def test_format_units_defaults(self):
   # Tests (input, result, prefix, 'Error String')
   tests = [
            (1, 1, '', 'format_units(1) != 1'),
            (1.0, 1.0, '', 'format_units(1.0) != 1.0'),
            (0.001, 0.001, '', 'format_units(0.001) != 0.001'),
            (1000, 1.0, 'k', 'format_units(1000) != 1.0 k'),
            (1000000, 1.0, 'M', 'format_units(1000000) != 1.0 M'),
           ]
   for (t,r,p,e) in tests:
       self.assertEqual(glyph.format_units(t), (r, p), e)
 def test_format_units_v_step_si(self):
     # Tests (input, step, result, prefix, 'Error String')
     tests = [
         (1, 100, 1, '', 'format_units(1, 100, \'si\') != 1'),
         (1.0, 100, 1.0, '', 'format_units(1.0, 100, \'si\') != 1.0'),
         (0.001, 100, 0.001, '',
          'format_units(0.001, 100, \'si\') != 0.001'),
         (1000, 100, 1000.0, '',
          'format_units(1000, 100, \'si\') != 1000.0'),
         (1000000, 100, 1000000.0, '',
          'format_units(1000000, 100, \'si\') != 1000000.0'),
     ]
     for (t, s, r, p, e) in tests:
         self.assertEqual(glyph.format_units(t, s, 'si'), (r, p), e)
 def test_format_units_v_None_si_units(self):
     # Tests (input, result, prefix, 'Error String')
     tests = [
         (1, 1, 'b', 'format_units(1, None, \'si\', \'b\') != 1'),
         (1.0, 1.0, 'b', 'format_units(1.0, None, \'si\', \'b\') != 1.0'),
         (0.001, 0.001, 'b',
          'format_units(0.001, None, \'si\', \'b\') != 0.001'),
         (1000, 1.0, 'kb',
          'format_units(1000, None, \'si\', \'b\') != 1.0 kb'),
         (1000000, 1.0, 'Mb',
          'format_units(1000000, None, \'si\', \'b\') != 1.0 Mb'),
     ]
     for (t, r, p, e) in tests:
         self.assertEqual(glyph.format_units(t, None, 'si', 'b'), (r, p), e)