本文整理汇总了Golang中github.com/jpfielding/gotest/testutils.Equals函数的典型用法代码示例。如果您正苦于以下问题:Golang Equals函数的具体用法?Golang Equals怎么用?Golang Equals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Equals函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestPrependHost
func TestPrependHost(t *testing.T) {
login := "http://server.com:6103/platinum/login"
abs := "http://server.com:6103/platinum/search"
rel := "/platinum/search"
testutils.Equals(t, abs, prependHost(login, abs))
testutils.Equals(t, abs, prependHost(login, rel))
}
示例2: TestSearchXMLComplex
func TestSearchXMLComplex(t *testing.T) {
type Listing struct {
Business string `xml:"Business>RESIOWNS"`
Approved bool `xml:"Listing>Approved"`
MLS string `xml:"Listing>MLS"`
Disclaimer string `xml:"Listing>Disclaimer"`
Status string `xml:"Listing>Status"`
ListingPrice float64 `xml:"Listing>Price>ListingPrice"`
OriginalPrice float64 `xml:"Listing>Price>OriginalPrice"`
SellPrice float64 `xml:"Listing>Price>SellingPrice"`
}
body := ioutil.NopCloser(strings.NewReader(standardXML))
cr, err := NewStandardXMLSearchResult(body)
testutils.Ok(t, err)
var listings []Listing
count, maxRows, err := cr.ForEach(minidom.ByName("PropertyListing"), func(elem io.ReadCloser, err error) error {
if err != nil {
return err
}
listing := Listing{}
xml.NewDecoder(elem).Decode(&listing)
listings = append(listings, listing)
return err
})
testutils.Ok(t, err)
testutils.Equals(t, true, maxRows)
testutils.Equals(t, 10, count)
testutils.Equals(t, 2, len(listings))
}
示例3: TestSimple
func TestSimple(t *testing.T) {
doms := ioutil.NopCloser(strings.NewReader(example))
parser := xml.NewDecoder(doms)
listings := Listings{}
// minidom isnt necessary but its crazy useful for massive streams
md := minidom.MiniDom{
StartFunc: func(start xml.StartElement) {
switch start.Name.Local {
case "Listings":
attrs := map[string]string{}
for _, v := range start.Attr {
attrs[v.Name.Local] = v.Value
}
listings.ListingsKey = attrs["listingsKey"]
listings.Version = attrs["version"]
listings.VersionTimestamp = attrs["versionTimestamp"]
listings.Language = attrs["lang"]
case "Disclaimer":
parser.DecodeElement(listings.Disclaimer, &start)
}
},
// quit on the the xml tag
EndFunc: minidom.QuitAt("Listings"),
}
err := md.Walk(parser, minidom.ByName("Listing"), ToListing(func(l Listing, err error) error {
listings.Listings = append(listings.Listings, l)
return err
}))
testutils.Ok(t, err)
testutils.Equals(t, 1, len(listings.Listings))
testutils.Equals(t, "http://www.somemls.com/lisings/1234567890", listings.Listings[0].ListingURL)
testutils.Equals(t, "New Light Fixtures", *listings.Listings[0].Photos[1].Caption)
testutils.Equals(t, "1100.0", listings.Listings[0].Expenses[2].Value.Value)
}
示例4: TestCompactRowParsing
func TestCompactRowParsing(t *testing.T) {
var col = ` A B C D E F `
var row = ` 1 2 3 4 6 `
var delim = ` `
headers := CompactRow(col).Parse(delim)
values := CompactRow(row).Parse(delim)
testutils.Equals(t, 6, int(len(headers)))
testutils.Equals(t, 6, int(len(values)))
}
示例5: TestMetaInfoIDMap
func TestMetaInfoIDMap(t *testing.T) {
test := map[string]string{
"ResourceID": "rid",
"LookupName": "ln",
"MetadataEntryID": "mid",
"ClassName": "cn",
"ColumnGroupName": "cgn",
}
testutils.Equals(t, "rid", MIResource.ID(test))
testutils.Equals(t, "ln", MILookup.ID(test))
testutils.Equals(t, "cn", MIClass.ID(test))
testutils.Equals(t, "cgn", MIColumnGroup.ID(test))
}
示例6: verifyParseResources
func verifyParseResources(t *testing.T, cm CompactMetadata) {
resource := cm.Elements["METADATA-RESOURCE"][0]
testutils.Equals(t, "1.12.30", resource.Attr["Version"])
testutils.Equals(t, len(resource.CompactRows), 2)
indexer := resource.Indexer()
var rows []Row
resource.Rows(func(i int, r Row) {
rows = append(rows, r)
})
testutils.Equals(t, "ActiveAgent", indexer("ResourceID", rows[0]))
testutils.Equals(t, "Tue, 3 Sep 2013 00:00:00 GMT", indexer("ValidationExternalDate", rows[1]))
}
示例7: TestLoad
func TestLoad(t *testing.T) {
body := ioutil.NopCloser(strings.NewReader(raw))
defer body.Close()
parser := xml.NewDecoder(body)
xml := RETSResponseWrapper{}
err := parser.Decode(&xml)
if err != io.EOF {
testutils.Ok(t, err)
}
testutils.Equals(t, "Operation Successful", xml.ReplyText)
testutils.Equals(t, "ABBA", xml.Metadata.MSystem.System.ID)
testutils.Equals(t, "Property", string(xml.Metadata.MSystem.System.MResource.Resource[0].ResourceID))
}
示例8: TestParseCompactData
func TestParseCompactData(t *testing.T) {
body := ioutil.NopCloser(strings.NewReader(compact))
decoder := DefaultXMLDecoder(body, false)
token, err := decoder.Token()
testutils.Ok(t, err)
start, ok := token.(xml.StartElement)
testutils.Assert(t, ok, "should be a start element")
testutils.Equals(t, "METADATA-ELEMENT", start.Name.Local)
cm, err := NewCompactData(start, decoder, " ")
testutils.Ok(t, err)
testutils.Equals(t, "METADATA-ELEMENT", cm.Element)
testutils.Equals(t, "Dog", cm.Attr["Cat"])
testutils.Equals(t, 2, len(cm.CompactRows))
testutils.Equals(t, 2, len(cm.Columns()))
}
示例9: TestSearchXML
func TestSearchXML(t *testing.T) {
body := ioutil.NopCloser(strings.NewReader(standardXML))
cr, err := NewStandardXMLSearchResult(body)
testutils.Ok(t, err)
var listings []io.ReadCloser
count, maxRows, err := cr.ForEach(minidom.ByName("PropertyListing"), func(elem io.ReadCloser, err error) error {
listings = append(listings, elem)
return err
})
testutils.Ok(t, err)
testutils.Equals(t, true, maxRows)
testutils.Equals(t, 10, count)
testutils.Equals(t, 2, len(listings))
}
示例10: verifyParseLookup
func verifyParseLookup(t *testing.T, cm CompactMetadata) {
mdata := cm.Elements["METADATA-LOOKUP"][0]
testutils.Equals(t, "TaxHistoricalDesignation", mdata.Attr["Resource"])
testutils.Equals(t, "1.12.29", mdata.Attr["Version"])
testutils.Equals(t, len(mdata.CompactRows), 4)
indexer := mdata.Indexer()
var row []Row
mdata.Rows(func(i int, r Row) {
row = append(row, r)
})
testutils.Equals(t, "COUNTIES_OR_REGIONS", indexer("LookupName", row[0]))
testutils.Equals(t, "Tue, 3 Sep 2013 00:00:00 GMT", indexer("Date", row[3]))
}
示例11: TestSearchCompactNoEof
func TestSearchCompactNoEof(t *testing.T) {
rets := `<RETS ReplyCode="20201" ReplyText="No Records Found." ></RETS>`
body := ioutil.NopCloser(strings.NewReader(rets))
cr, err := NewCompactSearchResult(body)
testutils.Ok(t, err)
testutils.Equals(t, StatusNoRecords, cr.Response.Code)
}
示例12: TestCreateHa2
func TestCreateHa2(t *testing.T) {
method, uri := "GET", "/platinum/login"
expected := "1b11c4ebed4a67753078be8020ea9d19"
actual := createNoQopDigest().createHa2(method, uri, md5.New())
testutils.Equals(t, expected, actual)
}
示例13: TestSystem
func TestSystem(t *testing.T) {
body := ioutil.NopCloser(strings.NewReader(raw))
defer body.Close()
extractor := &Extractor{Body: body}
response, err := extractor.Open()
testutils.Ok(t, err)
testutils.Equals(t, "Operation Successful", response.ReplyText)
xml := MSystem{}
err = extractor.DecodeNext("METADATA-SYSTEM", &xml)
if err != io.EOF {
testutils.Ok(t, err)
}
testutils.Equals(t, "ABBA", xml.System.ID)
testutils.Equals(t, "Property", string(xml.System.MResource.Resource[0].ResourceID))
}
示例14: TestCompactEntry
func TestCompactEntry(t *testing.T) {
body := ioutil.NopCloser(strings.NewReader(compact))
decoder := DefaultXMLDecoder(body, false)
token, err := decoder.Token()
testutils.Ok(t, err)
start, ok := token.(xml.StartElement)
testutils.Assert(t, ok, "should be a start element")
cm, err := NewCompactData(start, decoder, " ")
testutils.Ok(t, err)
type Test struct {
ResourceID, Standardname string
}
row1 := Test{}
maps := cm.Entries()
maps[0].SetFields(&row1)
testutils.Equals(t, "ActiveAgent", row1.ResourceID)
testutils.Equals(t, "ActiveAgent", row1.Standardname)
}
示例15: TestSearchXMLParseSearchQuit
func TestSearchXMLParseSearchQuit(t *testing.T) {
noEnd := strings.Split(standardXML, "Commercial")[0]
body := ioutil.NopCloser(strings.NewReader(noEnd))
cr, err := NewStandardXMLSearchResult(body)
testutils.Ok(t, err)
var listings [][]byte
count, maxRows, err := cr.ForEach(minidom.ByName("PropertyListing"), func(elem io.ReadCloser, err error) error {
tmp, _ := ioutil.ReadAll(elem)
listings = append(listings, tmp)
return err
})
testutils.NotOk(t, err)
testutils.Equals(t, false, maxRows)
testutils.Equals(t, 10, count)
testutils.Equals(t, 1, len(listings))
}