Files
NB-076 94400d50d4 feat: add benchmark-programs — 58 telecom COBOL test programs
作为子目录纳入系统,与核心测试管道协同

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-25 09:53:21 +08:00

63 lines
2.3 KiB
Markdown

# 13-validation-nodup: Field Validation (No Duplicates)
## 电信业务场景
CDR字段校验。对CDR记录进行字段值校验,检查通话类型代码是否为有效值(01/02/03),有效记录输出到GOOD文件,无效记录输出到BAD文件。
## Description
Reads FILE-IN and validates FIELD1 against an allowed-value list
('A', 'B', 'C', 'D', 'E'). Records with valid FIELD1 values are
written to FILE-OUT-GOOD. Invalid records are written to
FILE-OUT-BAD with an error code appended.
## Record Layout
### Input / Good Output (31 bytes)
| Field | Type | Length | Description |
|--------|----------|--------|---------------------------|
| FIELD1 | PIC X | 1 | Validation field |
| FIELD2 | PIC X | 30 | Description / payload |
### Bad Output (33 bytes)
| Field | Type | Length | Description |
|----------|----------|--------|---------------------------|
| FIELD1 | PIC X | 1 | Original invalid value |
| FIELD2 | PIC X | 30 | Original description |
| ERR-CODE | PIC X | 2 | Error code ('01') |
## Files
| File | Purpose |
|---------------------------|----------------------------------|
| main-13-validation-nodup.cbl | Main COBOL program |
| data-gen.sh | Generate test data |
| run.sh | Compile, run, verify |
| README.md | This file |
## Tests
| Test Case | Description |
|----------------------------|-----------------------------------------|
| Valid values A-E | All 5 allowed values pass to GOOD |
| Invalid values X,Y,Z | Non-allowed alpha values go to BAD |
| Invalid values 1,9 | Numeric values go to BAD |
| Empty FIELD1 (space) | Treated as invalid, goes to BAD |
| Error code in BAD output | '01' appended to each bad record |
## Usage
```bash
cd 13-validation-nodup
bash data-gen.sh
bash run.sh
```
## Expected Behavior
- 5 valid records in FILE-OUT-GOOD (31 bytes each = 155 bytes)
- 6 invalid records in FILE-OUT-BAD (33 bytes each = 198 bytes)
- Invalid records contain the original data plus '01' error code