xref: /aosp_15_r20/external/angle/build/util/lib/proto/count_unittests.py (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1#!/usr/bin/env vpython3
2
3# Copyright 2024 The Chromium Authors
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6"""File for testing count.py."""
7
8import unittest
9from count import Count
10
11
12class CountTest(unittest.TestCase):
13  """Test count.py."""
14
15  def test_no_record(self) -> None:
16    count = Count("a")
17    self.assertEqual(count.dump().name, "a")
18    self.assertEqual(count.dump().value, 0)
19
20  def test_one_record(self) -> None:
21    count = Count("b")
22    count.record()
23    self.assertEqual(count.dump().name, "b")
24    self.assertEqual(count.dump().value, 1)
25
26  def test_more_records(self) -> None:
27    count = Count("c")
28    count.record()
29    count.record()
30    self.assertEqual(count.dump().name, "c")
31    self.assertEqual(count.dump().value, 2)
32
33
34if __name__ == '__main__':
35  unittest.main()
36