• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang testutils.Equals函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/jpfielding/gotest/testutils.Equals函数的典型用法代码示例。如果您正苦于以下问题:Golang Equals函数的具体用法?Golang Equals怎么用?Golang Equals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Equals函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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))
}
开发者ID:jpfielding,项目名称:gorets,代码行数:7,代码来源:login_test.go


示例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))
}
开发者ID:jpfielding,项目名称:gorets,代码行数:31,代码来源:search_xml_test.go


示例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)
}
开发者ID:jpfielding,项目名称:gorets,代码行数:34,代码来源:syndication_test.go


示例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)))
}
开发者ID:jpfielding,项目名称:gorets,代码行数:10,代码来源:compact_test.go


示例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))
}
开发者ID:jpfielding,项目名称:gorets,代码行数:13,代码来源:meta_test.go


示例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]))
}
开发者ID:jpfielding,项目名称:gorets,代码行数:14,代码来源:metadata_compact_test.go


示例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))
}
开发者ID:jpfielding,项目名称:gorets,代码行数:15,代码来源:system_test.go


示例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()))
}
开发者ID:jpfielding,项目名称:gorets,代码行数:15,代码来源:compact_test.go


示例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))
}
开发者ID:jpfielding,项目名称:gorets,代码行数:16,代码来源:search_xml_test.go


示例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]))
}
开发者ID:jpfielding,项目名称:gorets,代码行数:16,代码来源:metadata_compact_test.go


示例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)
}
开发者ID:jpfielding,项目名称:gorets,代码行数:8,代码来源:search_compact_test.go


示例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)
}
开发者ID:jpfielding,项目名称:gorets,代码行数:8,代码来源:digest_test.go


示例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))
}
开发者ID:jpfielding,项目名称:gorets,代码行数:18,代码来源:system_test.go


示例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)
}
开发者ID:jpfielding,项目名称:gorets,代码行数:18,代码来源:compact_test.go


示例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))
}
开发者ID:jpfielding,项目名称:gorets,代码行数:18,代码来源:search_xml_test.go


示例16: TestCreateHa1Md5

func TestCreateHa1Md5(t *testing.T) {
	username := "user"
	password := "passwd"
	cnonce := "6ac2c2eee85f5c33"

	expected := "5c0da895491be93b455ebb56f7ae0a9f"
	actual := createNoQopDigest().createHa1(username, password, cnonce, md5.New())

	testutils.Equals(t, expected, actual)
}
开发者ID:jpfielding,项目名称:gorets,代码行数:10,代码来源:digest_test.go


示例17: TestSearchCompactParseSearchQuit

func TestSearchCompactParseSearchQuit(t *testing.T) {
	noEnd := strings.Split(compactDecoded, "<MAXROWS/>")[0]
	body := ioutil.NopCloser(strings.NewReader(noEnd))

	cr, err := NewCompactSearchResult(body)
	testutils.Ok(t, err)

	rowsFound := 0
	cr.ForEach(func(data Row, err error) error {
		if err != nil {
			testutils.Assert(t, strings.Contains(err.Error(), "EOF"), "found something not eof")
			return err
		}
		testutils.Equals(t, "1,2,3,4,,6", strings.Join(data, ","))
		rowsFound++
		return nil
	})
	testutils.Equals(t, 8, rowsFound)
}
开发者ID:jpfielding,项目名称:gorets,代码行数:19,代码来源:search_compact_test.go


示例18: TestSearchCompactEmbeddedRetsStatus

func TestSearchCompactEmbeddedRetsStatus(t *testing.T) {
	rets := `<?xml version="1.0" encoding="UTF-8" ?>
			<RETS ReplyCode="0" ReplyText="Operation Successful">
			<RETS-STATUS ReplyCode="20201" ReplyText="No matching records were found" />
			</RETS>`
	body := ioutil.NopCloser(strings.NewReader(rets))
	cr, err := NewCompactSearchResult(body)
	testutils.Ok(t, err)
	testutils.Equals(t, StatusNoRecords, cr.Response.Code)
}
开发者ID:jpfielding,项目名称:gorets,代码行数:10,代码来源:search_compact_test.go


示例19: TestCreateResponseQopAuth

func TestCreateResponseQopAuth(t *testing.T) {
	nc := "00000001"
	cnonce := "6ac2c2eee85f5c33"
	ha1 := "5c0da895491be93b455ebb56f7ae0a9f"
	ha2 := "1b11c4ebed4a67753078be8020ea9d19"

	expected := "28552064c4cde9a3af7610e7ae286d50"
	actual := createAuthDigest().createResponse(ha1, ha2, nc, cnonce, md5.New())

	testutils.Equals(t, expected, actual)
}
开发者ID:jpfielding,项目名称:gorets,代码行数:11,代码来源:digest_test.go


示例20: TestMetaInfoIDStruct

func TestMetaInfoIDStruct(t *testing.T) {
	type TestStruct struct {
		ResourceID      string
		LookupName      string
		MetadataEntryID string
		ClassName       string
		ColumnGroupName string
	}
	test := &TestStruct{
		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))
}
开发者ID:jpfielding,项目名称:gorets,代码行数:20,代码来源:meta_test.go



注:本文中的github.com/jpfielding/gotest/testutils.Equals函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang testutils.Ok函数代码示例发布时间:2022-05-23
下一篇:
Golang cloudapi.Client类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap