From 66cb5937cc01401f42b7671d280175c64b686ca4 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 17 Sep 2026 15:51:38 +0200 Subject: [PATCH] Test the cell alternatives the family fence must still refuse: the format beside a cell, two columns of one row, a whole read beside a path, and a cell reaching another table's cells --- table_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/table_test.go b/table_test.go index 3c049b5..eb16a3b 100644 --- a/table_test.go +++ b/table_test.go @@ -539,9 +539,18 @@ func TestColumnCellsAreAlternatives(t *testing.T) { if v := fake(t, f, "country[FI].money"); v != "€" { t.Fatalf("country[FI].money = %q", v) } - files["country.tsv"] = "alpha2\tname\tmoney\nFI\tFinland\t{/cur[EUR].sym}{/cur[SEK].sym}\nSE\tSweden\t{/cur[SEK].sym}\n" - if _, err := New(WithoutShippedData(), WithDataPath(writeFiles(t, files))); err == nil || !strings.Contains(err.Error(), "drawGroup") { - t.Fatalf("New = %v, want one cell selecting two rows refused", err) + rejected := map[string]map[string]string{ + "one cell selecting two rows": {"country.tsv": "alpha2\tname\tmoney\nFI\tFinland\t{/cur[EUR].sym}{/cur[SEK].sym}\nSE\tSweden\t{/cur[SEK].sym}\n"}, + "the format beside a cell": {"country.json": `{"format":"{money} {/cur[SEK].sym}","rows":"country.tsv","key":"alpha2"}`}, + "two columns of one row": {"country.json": `{"format":"{a} {b}","rows":"country.tsv","key":"alpha2"}`, "country.tsv": "alpha2\ta\tb\nFI\t{/cur[SEK].sym}\t{/cur[EUR].sym}\nSE\t{/cur[EUR].sym}\t{/cur[SEK].sym}\n"}, + "a whole read beside a path": {"country.json": `{"format":"{a} {b}","rows":"country.tsv","key":"alpha2"}`, "country.tsv": "alpha2\ta\tb\nFI\t{/cur}\t{/cur[EUR].sym}\nSE\t{/cur}\t{/cur[SEK].sym}\n"}, + "a cell reaching another's cells": {"y.json": `{"format":"{sym}","rows":"y.tsv","key":"k"}`, "y.tsv": "k\tsym\n1\t{/cur[SEK].sym}\n2\t{/cur[USD].sym}\n", "cur.tsv": "code\tsym\nEUR\t€\nSEK\tkr\nUSD\t$\n", "country.tsv": "alpha2\tname\tmoney\nFI\tFinland\t{/y[1].sym} {/cur[EUR].sym}\nSE\tSweden\t{/cur[SEK].sym}\n"}, + } + for name, more := range rejected { + _, err := New(WithoutShippedData(), WithDataPath(writeFiles(t, with(files, more)))) + if err == nil || !strings.Contains(err.Error(), "drawGroup") { + t.Errorf("%s: New = %v, want it refused", name, err) + } } }