OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/payments/content/android/utility/fingerprint_parser.h" |
| 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 |
| 9 namespace payments { |
| 10 namespace { |
| 11 |
| 12 TEST(FingerprintParserTest, CheckInputSize) { |
| 13 // To short. |
| 14 EXPECT_TRUE(FingerprintStringToByteArray("00:01:02:03:04:05:06:07:08:09:" |
| 15 "A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:" |
| 16 "B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:" |
| 17 "C0:C") |
| 18 .empty()); |
| 19 EXPECT_TRUE(FingerprintStringToByteArray("00:01:02:03:04:05:06:07:08:09:" |
| 20 "A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:" |
| 21 "B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:" |
| 22 "C0:") |
| 23 .empty()); |
| 24 EXPECT_TRUE(FingerprintStringToByteArray("00:01:02:03:04:05:06:07:08:09:" |
| 25 "A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:" |
| 26 "B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:" |
| 27 "C0") |
| 28 .empty()); |
| 29 |
| 30 // To long. |
| 31 EXPECT_TRUE(FingerprintStringToByteArray("00:01:02:03:04:05:06:07:08:09:" |
| 32 "A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:" |
| 33 "B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:" |
| 34 "C0:C11") |
| 35 .empty()); |
| 36 EXPECT_TRUE(FingerprintStringToByteArray("00:01:02:03:04:05:06:07:08:09:" |
| 37 "A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:" |
| 38 "B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:" |
| 39 "C0:C1:") |
| 40 .empty()); |
| 41 EXPECT_TRUE(FingerprintStringToByteArray("00:01:02:03:04:05:06:07:08:09:" |
| 42 "A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:" |
| 43 "B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:" |
| 44 "C0:C1:C") |
| 45 .empty()); |
| 46 EXPECT_TRUE(FingerprintStringToByteArray("00:01:02:03:04:05:06:07:08:09:" |
| 47 "A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:" |
| 48 "B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:" |
| 49 "C0:C1:C2") |
| 50 .empty()); |
| 51 } |
| 52 |
| 53 TEST(FingerprintParserTest, CheckColonSeparator) { |
| 54 EXPECT_TRUE(FingerprintStringToByteArray("00-01-02-03-04-05-06-07-08-09-" |
| 55 "A0-A1-A2-A3-A4-A5-A6-A7-A8-A9-" |
| 56 "B0-B1-B2-B3-B4-B5-B6-B7-B8-B9-" |
| 57 "C0-C1") |
| 58 .empty()); |
| 59 } |
| 60 |
| 61 TEST(FingerprintParserTest, MustBeHex) { |
| 62 EXPECT_TRUE(FingerprintStringToByteArray("G0:G1:G2:G3:G4:G5:G6:G7:G8:G9:" |
| 63 "A0:A1:A2:A3:A4:A5:A6:A7:A8:A9:" |
| 64 "B0:B1:B2:B3:B4:B5:B6:B7:B8:B9:" |
| 65 "C0:C1") |
| 66 .empty()); |
| 67 } |
| 68 |
| 69 TEST(FingerprintParserTest, MustBeUpperCaseHex) { |
| 70 EXPECT_TRUE(FingerprintStringToByteArray("00:01:02:03:04:05:06:07:08:09:" |
| 71 "a0:a1:a2:a3:a4:a5:a6:a7:a8:a9:" |
| 72 "b0:b1:b2:b3:b4:b5:b6:b7:b8:b9:" |
| 73 "c0:c1") |
| 74 .empty()); |
| 75 } |
| 76 |
| 77 TEST(FingerprintParserTest, CorrectParsing) { |
| 78 std::vector<uint8_t> actual_output = FingerprintStringToByteArray( |
| 79 "00:01:02:03:04:05:06:07:08:09:A0:" |
| 80 "A1:A2:A3:A4:A5:A6:A7:A8:A9:B0:B1:" |
| 81 "B2:B3:B4:B5:B6:B7:B8:B9:FE:FF"); |
| 82 std::vector<uint8_t> expect_output = { |
| 83 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xA0, |
| 84 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xB0, 0xB1, |
| 85 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xFE, 0xFF}; |
| 86 EXPECT_EQ(expect_output, actual_output); |
| 87 } |
| 88 |
| 89 } // namespace |
| 90 } // namespace payments |
OLD | NEW |