0dbd7b4e45
- Batch 2: C-norms (woodworking, food, conveyors, lifts, agri, packaging) - Batch 3: machining, escalators, piping, boilers, wind/PV, refrigeration - Batch 4: paper sub-parts, playground (ASTM F1487), aircraft ground support, scaffolds, wire ropes, crane design EN 13001 - Batch 5: glass (EN 13035), ladders (ANSI A14), pools (APSP), explosives (DOT 49 CFR), amusement rides (ASTM F2291), drilling/foundation, eye protection (ANSI Z87.1), fire-fighting vehicles (NFPA 1901) 500 of 671 norms now have international identifier mappings. 171 remaining will be covered in batches 6-7 (alphabetically: EN-1870-x remainder onward plus ISO-x specials). Tests: TestCrossRef_BatchCoverage expects 500. All 8 cross-ref tests pass. 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-5 × 100 = 500.
|
||
const expectedCrossRefCount = 500
|
||
|
||
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)
|
||
}
|
||
}
|
||
}
|
||
}
|