build_test.go 677 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package urlenc
  2. import "testing"
  3. import "log"
  4. import "fmt"
  5. func TestArray(t *testing.T) {
  6. log.Printf(
  7. "Array{...}: %s\n",
  8. Array[int]{
  9. Name: "id",
  10. Values: []int{123, 456, 789},
  11. },
  12. )
  13. }
  14. func TestJoin(t *testing.T) {
  15. log.Printf(
  16. "Join(...): %s",
  17. Join(
  18. Array[int]{
  19. "id",
  20. []int{123, 456, 789},
  21. },
  22. Value[string]{"somename", "value with '='"},
  23. ).Encode(),
  24. )
  25. }
  26. func TestFnArray(t *testing.T) {
  27. log.Printf(
  28. "FnArray{...}: %s",
  29. FnArray[int64]{
  30. []int64{
  31. 1, 2, 3, 11, 12, 13,
  32. },
  33. func(
  34. a []int64, i int,
  35. ) (string, string) {
  36. return fmt.Sprintf(
  37. "custom_field_%d_value_changed",
  38. a[i],
  39. ), ""
  40. },
  41. },
  42. )
  43. }