コード例 #1
0
 def testParseMemoryInterval(self):
   self.assertEqual(
       command_parser.Interval(1024, True, 2048, True),
       command_parser.parse_memory_interval("[1k, 2k]"))
   self.assertEqual(
       command_parser.Interval(1024, False, 2048, False),
       command_parser.parse_memory_interval("(1kB, 2kB)"))
   self.assertEqual(
       command_parser.Interval(1024, False, 2048, True),
       command_parser.parse_memory_interval("(1k, 2k]"))
   self.assertEqual(
       command_parser.Interval(1024, True, 2048, False),
       command_parser.parse_memory_interval("[1k, 2k)"))
   self.assertEqual(
       command_parser.Interval(0, False, 2048, True),
       command_parser.parse_memory_interval("<=2k"))
   self.assertEqual(
       command_parser.Interval(11, True, float("inf"), False),
       command_parser.parse_memory_interval(">=11"))
   self.assertEqual(
       command_parser.Interval(0, False, 2048, False),
       command_parser.parse_memory_interval("<2k"))
   self.assertEqual(
       command_parser.Interval(11, False, float("inf"), False),
       command_parser.parse_memory_interval(">11"))
コード例 #2
0
 def testParseTimeInterval(self):
   self.assertEqual(
       command_parser.Interval(10, True, 1e3, True),
       command_parser.parse_time_interval("[10us, 1ms]"))
   self.assertEqual(
       command_parser.Interval(10, False, 1e3, False),
       command_parser.parse_time_interval("(10us, 1ms)"))
   self.assertEqual(
       command_parser.Interval(10, False, 1e3, True),
       command_parser.parse_time_interval("(10us, 1ms]"))
   self.assertEqual(
       command_parser.Interval(10, True, 1e3, False),
       command_parser.parse_time_interval("[10us, 1ms)"))
   self.assertEqual(
       command_parser.Interval(0, False, 1e3, True),
       command_parser.parse_time_interval("<=1ms"))
   self.assertEqual(
       command_parser.Interval(1e3, True, float("inf"), False),
       command_parser.parse_time_interval(">=1ms"))
   self.assertEqual(
       command_parser.Interval(0, False, 1e3, False),
       command_parser.parse_time_interval("<1ms"))
   self.assertEqual(
       command_parser.Interval(1e3, False, float("inf"), False),
       command_parser.parse_time_interval(">1ms"))
コード例 #3
0
  def testIntervalContains(self):
    interval = command_parser.Interval(
        start=1, start_included=True, end=10, end_included=True)
    self.assertTrue(interval.contains(1))
    self.assertTrue(interval.contains(10))
    self.assertTrue(interval.contains(5))

    interval.start_included = False
    self.assertFalse(interval.contains(1))
    self.assertTrue(interval.contains(10))

    interval.end_included = False
    self.assertFalse(interval.contains(1))
    self.assertFalse(interval.contains(10))

    interval.start_included = True
    self.assertTrue(interval.contains(1))
    self.assertFalse(interval.contains(10))