package eutils

import "testing"

func stringTestXtract(t *testing.T, name string, proc func(string, []string) string, commands []string, input, expected string) {

	actual := proc(input, commands)
	if actual != expected {
		t.Errorf("%s(%s) = %s, expected %s", name, input, actual, expected)
	}
}

func TestXMLtoData(t *testing.T) {

	stringTestXtract(t, "XMLtoData,",
		XMLtoData,
		[]string{"-pattern", "Rec", "-element", "ID", "-upper", "Data"},
		"<Rec><ID>5</ID><Data>blue</Data></Rec><Rec><ID>12</ID><Data>93</Data></Rec>",
		"5\tBLUE\n12\t93\n",
	)
}
