blob: 83c9db29c1eb47b19697c3ea02ef1b14d1fbc29c [file] [log] [blame]
Paul Duffin67b9d612021-07-21 17:38:47 +01001#!/usr/bin/env python
2#
3# Copyright (C) 2021 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the 'License');
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an 'AS IS' BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17"""Unit tests for signature_patterns.py."""
18import io
19import unittest
20
21from signature_patterns import *
22
23class TestGeneratedPatterns(unittest.TestCase):
24
25 def produce_patterns_from_string(self, csv):
26 with io.StringIO(csv) as f:
27 return produce_patterns_from_stream(f)
28
29 def test_generate(self):
30 patterns = self.produce_patterns_from_string('''
31Ljava/lang/Object;->hashCode()I,public-api,system-api,test-api
32Ljava/lang/Object;->toString()Ljava/lang/String;,blocked
33''')
34 expected = [
35 "Ljava/lang/Object;->hashCode()I",
36 "Ljava/lang/Object;->toString()Ljava/lang/String;",
37 ]
38 self.assertEqual(expected, patterns)
39
40if __name__ == '__main__':
41 unittest.main(verbosity=2)