...

Source file src/github.com/clbanning/mxj/v2/structvalue_test.go

Documentation: github.com/clbanning/mxj/v2

     1  package mxj
     2  
     3  import (
     4  	"encoding/xml"
     5  	"fmt"
     6  	"testing"
     7  )
     8  
     9  type result struct {
    10  	XMLName xml.Name `xml:"xml"`
    11  	Content string   `xml:"content"`
    12  }
    13  
    14  func TestStructValue(t *testing.T) {
    15  	fmt.Println("----------------- structvalue_test.go ...")
    16  
    17  	data, err := Map(map[string]interface{}{
    18  		"data": result{Content: "content"},
    19  	}).Xml()
    20  	if err != nil {
    21  		t.Fatal(err)
    22  	}
    23  
    24  	if string(data) != "<data><xml><content>content</content></xml></data>" {
    25  		t.Fatal("encoding error:", string(data))
    26  	}
    27  }
    28  

View as plain text