package system

import "testing"

func TestExportQueryValueUsesDatabaseType(t *testing.T) {
	if value := exportQueryValue([]byte("42"), "VARCHAR"); value != "42" {
		t.Fatalf("text value = %#v, want string 42", value)
	}
	if value, ok := exportQueryValue([]byte("42"), "BIGINT").(int64); !ok || value != 42 {
		t.Fatalf("integer value = %#v", exportQueryValue([]byte("42"), "BIGINT"))
	}
	if value, ok := exportQueryValue([]byte("12.5"), "DECIMAL").(float64); !ok || value != 12.5 {
		t.Fatalf("decimal value = %#v", exportQueryValue([]byte("12.5"), "DECIMAL"))
	}
	if value, ok := exportQueryValue([]byte("1234567890123456.78"), "DECIMAL").(string); !ok || value != "1234567890123456.78" {
		t.Fatalf("high-precision decimal value = %#v", exportQueryValue([]byte("1234567890123456.78"), "DECIMAL"))
	}
}
