d9278f256e
- Batch 6 (100): EN 1870 saws, EN 81 lift sub-parts, hearing/glove PPE, EN 50126 railway, EN 60974 welding, EN 60335-2-x cleaning appliances - Batch 7 (71): IEC 60601 medical family, EN ISO 19085 woodworking, safety footwear (ASTM F2413), fitness (ASTM F2276), chainsaws (OPEI B175.1), ISO 4254 agri remainder, acoustics ISO 3743/3745/3747 671 of 671 norms now have at least DIN mapping; ~80% have a US (ANSI/NFPA/ UL/OSHA/ASME/ASTM/SAE/NIOSH) mapping; ~40% have CN-GB and/or JP-JIS. Added TestCrossRef_SpotChecks with 15 manually vetted region mappings (IEC 60601 → ANSI/AAMI ES60601, EN 13445 → ASME BPVC, EN 60204 → NFPA 79, ISO 10218 → RIA R15.06, etc.). Next steps for follow-up work: - Add OpenAPI snapshot for new /norms-library/crossref endpoints - Front-end: render crossref panel on /sdk/iace norm detail page - Tech file: auto-emit "this requirement also satisfies X in market Y" hints Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
112 lines
2.8 KiB
Go
112 lines
2.8 KiB
Go
package iace
|
||
|
||
import (
|
||
"testing"
|
||
)
|
||
|
||
// expectedCrossRefCount must be updated as batches are added.
|
||
// Batches 1-6 × 100 + Batch 7 × 71 = 671 (full library coverage).
|
||
const expectedCrossRefCount = 671
|
||
|
||
func TestCrossRef_BatchCoverage(t *testing.T) {
|
||
all := ListNormCrossRefs()
|
||
if len(all) != expectedCrossRefCount {
|
||
t.Fatalf("expected %d cross-ref entries, got %d", expectedCrossRefCount, len(all))
|
||
}
|
||
}
|
||
|
||
func TestCrossRef_EN8120_HasASME(t *testing.T) {
|
||
cr := GetNormCrossRef("EN-81-20")
|
||
hasASME := false
|
||
for _, m := range cr.Mappings {
|
||
if m.Region == "US-ASME" {
|
||
hasASME = true
|
||
break
|
||
}
|
||
}
|
||
if !hasASME {
|
||
t.Error("EN-81-20 (lifts) should map to ASME A17.1 in US-ASME region")
|
||
}
|
||
}
|
||
|
||
func TestCrossRef_EN13445_HasMultipleRegions(t *testing.T) {
|
||
cr := GetNormCrossRef("EN-13445-1")
|
||
if len(cr.Mappings) < 4 {
|
||
t.Errorf("EN-13445-1 (pressure vessels) should have 4+ regional mappings, got %d", len(cr.Mappings))
|
||
}
|
||
}
|
||
|
||
func TestCrossRef_ISO12100_HasAllRegions(t *testing.T) {
|
||
cr := GetNormCrossRef("ISO-12100")
|
||
if cr.NormID != "ISO-12100" {
|
||
t.Fatalf("expected NormID ISO-12100, got %q", cr.NormID)
|
||
}
|
||
wantRegions := map[string]bool{
|
||
"EU-DIN": false,
|
||
"US-ANSI": false,
|
||
"CN-GB": false,
|
||
"JP-JIS": false,
|
||
}
|
||
for _, m := range cr.Mappings {
|
||
if _, ok := wantRegions[m.Region]; ok {
|
||
wantRegions[m.Region] = true
|
||
}
|
||
}
|
||
for region, found := range wantRegions {
|
||
if !found {
|
||
t.Errorf("ISO-12100 missing mapping for region %q", region)
|
||
}
|
||
}
|
||
}
|
||
|
||
func TestCrossRef_EN60204_HasNFPA79(t *testing.T) {
|
||
cr := GetNormCrossRef("EN-60204-1")
|
||
hasNFPA := false
|
||
for _, m := range cr.Mappings {
|
||
if m.Region == "US-NFPA" && m.Identifier != "" {
|
||
hasNFPA = true
|
||
break
|
||
}
|
||
}
|
||
if !hasNFPA {
|
||
t.Error("EN-60204-1 should map to NFPA 79 in US-NFPA region")
|
||
}
|
||
}
|
||
|
||
func TestCrossRef_UnknownID_ReturnsEmpty(t *testing.T) {
|
||
cr := GetNormCrossRef("ISO-NOT-IN-REGISTRY")
|
||
if len(cr.Mappings) != 0 {
|
||
t.Errorf("expected empty mappings for unknown ID, got %d", len(cr.Mappings))
|
||
}
|
||
if cr.NormID != "ISO-NOT-IN-REGISTRY" {
|
||
t.Errorf("expected NormID preserved, got %q", cr.NormID)
|
||
}
|
||
}
|
||
|
||
func TestCrossRef_AllEntries_HaveValidRelation(t *testing.T) {
|
||
valid := map[string]bool{
|
||
"identical": true, "equivalent": true, "partial": true,
|
||
"supersedes": true, "superseded_by": true,
|
||
}
|
||
for _, cr := range ListNormCrossRefs() {
|
||
for _, m := range cr.Mappings {
|
||
if !valid[m.Relation] {
|
||
t.Errorf("%s region %s: invalid relation %q", cr.NormID, m.Region, m.Relation)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
func TestCrossRef_AllEntries_HaveValidConfidence(t *testing.T) {
|
||
valid := map[string]bool{
|
||
"verified": true, "high": true, "medium": true, "low": true,
|
||
}
|
||
for _, cr := range ListNormCrossRefs() {
|
||
for _, m := range cr.Mappings {
|
||
if !valid[m.Confidence] {
|
||
t.Errorf("%s region %s: invalid confidence %q", cr.NormID, m.Region, m.Confidence)
|
||
}
|
||
}
|
||
}
|
||
}
|