def testPrimitives(self): googletest.TestCase.assertEqual(self, 0, compare.Proto2Cmp('a', 'a')) googletest.TestCase.assertLess(self, 0, compare.Proto2Cmp('b', 'a')) pb = compare_test_pb2.Large() googletest.TestCase.assertEquals(self, cmp('a', pb), compare.Proto2Cmp('a', pb)) googletest.TestCase.assertEqual(self, cmp(pb, 'a'), compare.Proto2Cmp(pb, 'a'))
def _AssertProtoEquals(self, a, b): """Asserts that a and b are the same proto. Uses Proto2Cmp() first, as it returns correct results for floating point attributes, and then use assertProto2Equal() in case of failure as it provides good error messages. Args: a: a proto. b: another proto. """ if compare.Proto2Cmp(a, b) != 0: compare.assertProto2Equal(self, a, b, normalize_numbers=True)
def assertEquals(self, a, b): """Asserts that Proto2Cmp says a == b.""" a, b = LargePbs(a, b) googletest.TestCase.assertEquals(self, compare.Proto2Cmp(a, b), 0)
def assertGreater(self, a, b): """Asserts that Proto2Cmp says a > b.""" a, b = LargePbs(a, b) googletest.TestCase.assertGreater(self, compare.Proto2Cmp(a, b), 0) googletest.TestCase.assertLess(self, compare.Proto2Cmp(b, a), 0)