Exemplo n.º 1
0
 def testSerialize(self):
     names = related_name_map.RelatedNameMap()
     names.Set('a', 'x')
     names.Set('b', 'y')
     names.Set('c', 'z')
     s = histogram_serializer.HistogramSerializer()
     self.assertEqual(names.Serialize(s), [6, 0, 1, 2])
Exemplo n.º 2
0
 def testSerialize(self):
     s = histogram_serializer.HistogramSerializer()
     b = breakdown.Breakdown.FromEntries({'a': 10, 'b': 20})
     self.assertEqual(b.Serialize(s), [0, 3, 10, 20])
     self.assertEqual(s.GetOrAllocateId(''), 0)
     self.assertEqual(s.GetOrAllocateId('a'), 1)
     self.assertEqual(s.GetOrAllocateId('b'), 2)
     self.assertEqual(s.GetOrAllocateId([1, 2]), 3)
 def testDiagnostics(self):
   serializer = histogram_serializer.HistogramSerializer()
   self.assertEqual(0, serializer.GetOrAllocateDiagnosticId(
       'a', generic_set.GenericSet(['b'])))
   self.assertEqual(1, serializer.GetOrAllocateDiagnosticId(
       'a', generic_set.GenericSet(['c'])))
   self.assertEqual(0, serializer.GetOrAllocateDiagnosticId(
       'a', generic_set.GenericSet(['b'])))
   self.assertEqual(1, serializer.GetOrAllocateDiagnosticId(
       'a', generic_set.GenericSet(['c'])))
Exemplo n.º 4
0
 def testSerialize(self):
   s = histogram_serializer.HistogramSerializer()
   g = generic_set.GenericSet(['a', 'b'])
   self.assertEqual(g.Serialize(s), [0, 1])
   g = generic_set.GenericSet(['a'])
   self.assertEqual(g.Serialize(s), 0)
 def testObjects(self):
   serializer = histogram_serializer.HistogramSerializer()
   self.assertEqual(0, serializer.GetOrAllocateId('a'))
   self.assertEqual(1, serializer.GetOrAllocateId(['b']))
   self.assertEqual(0, serializer.GetOrAllocateId('a'))
   self.assertEqual(1, serializer.GetOrAllocateId(['b']))