Fix false-positive in unique_ptr presubmit check with mismatched <>

Presubmit was preventing upload of crrev.com/c/5534806 due to changed
line:
` std::unique_ptr<WebAppInstallInfo>>(`
being interpreted as a call to the unique_ptr constructor. IIUC this was
because the check only looks at the changed lines and missed the extra
">" indicating this was really part of a larger template expression.

Added a condition that suppresses the check when selected brackets are
mismatching (ie. number of < and > are not equal). Added tests for these
cases.

Change-Id: I260b7826eb1f55764a8a93b3402888afa5032eed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5538411
Reviewed-by: Dirk Pranke <[email protected]>
Auto-Submit: Glen Robertson <[email protected]>
Commit-Queue: Glen Robertson <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1301700}
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index f6f9573..9c13acf 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -3164,6 +3164,9 @@
       ]),
       MockFile('dir/nested.cc', ['set<std::unique_ptr<T>>();']),
       MockFile('dir/nested2.cc', ['map<U, std::unique_ptr<T>>();']),
+      # Changed line is inside a multiline template block.
+      MockFile('dir/template.cc', [' std::unique_ptr<T>>(']),
+      MockFile('dir/template2.cc', [' std::unique_ptr<T>>()']),
 
       # Two-argument invocation of std::unique_ptr is exempt because there is
       # no equivalent using std::make_unique.
@@ -3172,7 +3175,7 @@
     ]
 
     results = PRESUBMIT.CheckUniquePtrOnUpload(mock_input_api, MockOutputApi())
-    self.assertEqual(0, len(results))
+    self.assertEqual([], results)
 
 class CheckNoDirectIncludesHeadersWhichRedefineStrCat(unittest.TestCase):
   def testBlocksDirectIncludes(self):