| # Copyright 2018 Google Inc. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| from __future__ import absolute_import |
| import unittest |
| |
| import input_formatter |
| |
| |
| class TestInputFormatter(unittest.TestCase): |
| |
| def testConvertToString(self): |
| result = input_formatter.ConvertToString('test_str') |
| self.assertEqual(result, 'test_str') |
| result = input_formatter.ConvertToString(6) |
| self.assertEqual(result, '6') |
| result = input_formatter.ConvertToString(u'\xa0') |
| self.assertEqual(result, '\xc2\xa0') |
| |
| def testGetDeviceMajorVersion(self): |
| result = input_formatter.GetDeviceMajorVersion('test') |
| self.assertEqual(result, input_formatter._LARGEST_VERSION) |
| result = input_formatter.GetDeviceMajorVersion('1.2') |
| self.assertEqual(result, 1) |
| result = input_formatter.GetDeviceMajorVersion('109.0') |
| self.assertEqual(result, 109) |
| result = input_formatter.GetDeviceMajorVersion('1.2.3') |
| self.assertEqual(result, 1) |
| |
| |
| if __name__ == '__main__': |
| unittest.main() |