docs: consolidate runnable examples and publish v0.1.1 guides

This commit is contained in:
2026-09-24 21:27:25 +08:00
parent e29dec717f
commit 81e56bd633
124 changed files with 1430 additions and 281 deletions

View File

@@ -0,0 +1,25 @@
package main
import "testing"
func TestConvertCSV(t *testing.T) {
out, err := convert(conversionInput{FileName: "records.csv", Content: "name,amount\nalpha,2\nbeta,3\n", TargetFormat: "json"})
if err != nil {
t.Fatal(err)
}
if out.FileName != "records.json" || out.Format != "json" || out.Rows != 2 || out.Content != `[{"amount":"2","name":"alpha"},{"amount":"3","name":"beta"}]` {
t.Fatalf("unexpected output: %+v", out)
}
}
func TestConvertRejectsMalformedCSV(t *testing.T) {
for _, in := range []conversionInput{
{FileName: "records.csv", Content: "name,amount\nalpha\n", TargetFormat: "json"},
{FileName: "records.csv", Content: "name,name\nalpha,beta\n", TargetFormat: "json"},
{FileName: "records.csv", Content: "name,amount\nalpha,2\n", TargetFormat: "xml"},
} {
if _, err := convert(in); err == nil {
t.Fatalf("malformed input accepted: %+v", in)
}
}
}