|
| 1 | +// Licensed to The Moov Authors under one or more contributor |
| 2 | +// license agreements. See the NOTICE file distributed with |
| 3 | +// this work for additional information regarding copyright |
| 4 | +// ownership. The Moov Authors licenses this file to you under |
| 5 | +// the Apache License, Version 2.0 (the "License"); you may |
| 6 | +// 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, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +package addenda |
| 19 | + |
| 20 | +import ( |
| 21 | + "testing" |
| 22 | + |
| 23 | + "github.com/stretchr/testify/require" |
| 24 | +) |
| 25 | + |
| 26 | +func FuzzParseTXP(f *testing.F) { |
| 27 | + examples := []string{ |
| 28 | + "123456789*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\", |
| 29 | + "TXP**941*250901*T*1000\\", |
| 30 | + "TXP*123#456*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\", |
| 31 | + "TXP*123-456*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\", |
| 32 | + "TXP*123.456*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\", |
| 33 | + "TXP*123456789**250901*T*1000\\", |
| 34 | + "TXP*123456789*606*960331*T*100000*P*12000*I*4567*SML2A\\", |
| 35 | + "TXP*123456789*941**T*1000\\", |
| 36 | + "TXP*123456789*941*2509*T*1000\\", |
| 37 | + "TXP*123456789*941*250901**1000\\", |
| 38 | + "TXP*123456789*941*250901*1*1000*2*500***VERIFIED\\", |
| 39 | + "TXP*123456789*941*250901*1*1000*2*500\\", |
| 40 | + "TXP*123456789*941*250901*T* 1000 \\", |
| 41 | + "TXP*123456789*941*250901*T*1000****VERIFIED\\", |
| 42 | + "TXP*123456789*941*250901*T*1000*VERIFIED\\", |
| 43 | + "TXP*123456789*941*250901*T*1000*\\", |
| 44 | + "TXP*123456789*941*250901*T*100000\\", |
| 45 | + "TXP*123456789*941*250901*T*\\", |
| 46 | + "TXP*123456789*941*2509011*T*1000\\", |
| 47 | + "TXP*123456789*941*ABCDEF*T*1000\\", |
| 48 | + "TXP*123456789*94105*960301*1*10000*2*5000*3*15000\\", |
| 49 | + "TXP*123456789*FEDERAL*20231231*500000*1*25000*VERIFIED\\", |
| 50 | + "TXP*123456789*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED", |
| 51 | + "TXP*123456789*FEDERAL*20231231*TAX2023Q4*500000*1*25000*2**VERIFIED\\", |
| 52 | + "TXP*123456789*FEDERAL*20231231*TAX2023Q4*500000*1*25000*2*10000*VERIFIED_WITH_VERY_LONG_VERIFICATION_STRING\\", |
| 53 | + "TXP*123456789*FEDERAL*20231231*TAX2023Q4\\", |
| 54 | + "TXP*123456789*STATE*20231231*TAX2023Q4*500000*S**VERIFIED\\", |
| 55 | + "TXP*12345678934*526*960930*T*100000***SML2A\\", |
| 56 | + "TXP*123:456*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\", |
| 57 | + "TXP*123@456*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\", |
| 58 | + "TXP*123\n456*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\", |
| 59 | + "TXP*123\t456*FEDERAL*20231231*TAX2023Q4*500000*1**VERIFIED\\", |
| 60 | + "TXP*888999000*STATE*20231231*S*200000*2*10000**CONFIRMED\\", |
| 61 | + "txp*123456789*941*250901*T*1000\\", |
| 62 | + } |
| 63 | + |
| 64 | + for i := range examples { |
| 65 | + f.Add(examples[i]) |
| 66 | + } |
| 67 | + |
| 68 | + f.Fuzz(func(t *testing.T, input string) { |
| 69 | + require.NotPanics(t, func() { |
| 70 | + rec, _ := ParseTXP(input) |
| 71 | + if rec != nil { |
| 72 | + rec.String() |
| 73 | + } |
| 74 | + }) |
| 75 | + }) |
| 76 | +} |
0 commit comments