本文整理匯總了Golang中github.com/funkygao/assert.Equal函數的典型用法代碼示例。如果您正苦於以下問題:Golang Equal函數的具體用法?Golang Equal怎麽用?Golang Equal使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Equal函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestMkdirIfNotExist
func TestMkdirIfNotExist(t *testing.T) {
dir := "xxx"
defer os.Remove(dir)
assert.Equal(t, nil, mkdirIfNotExist(dir))
assert.Equal(t, nil, mkdirIfNotExist(dir))
}
示例2: TestPatternMatched
func TestPatternMatched(t *testing.T) {
assert.Equal(t, true, patternMatched("orderstatus", "order"))
assert.Equal(t, false, patternMatched("orderstatus", "~order"))
assert.Equal(t, true, patternMatched("flashtrade_web", "~svc_hippo"))
assert.Equal(t, false, patternMatched("34.StrollSearchRuleMsg.v1", "laxinRiskControl"))
assert.Equal(t, true, patternMatched("34.laxinRiskControl.v1", "laxinRiskControl"))
}
示例3: TestConsumerZnode
func TestConsumerZnode(t *testing.T) {
c := newConsumerZnode("cloudparkingGroup_orderMsg_BJS0-D134-018-1447657979158-fa9d1dc8")
assert.Equal(t, "BJS0-D134-018", c.Host())
c = newConsumerZnode("[email protected]:33f3a781-1dd5-488d-84fa-f8d3febce170")
assert.Equal(t, "192.168.10.134", c.ClientRealIP())
}
示例4: TestValidateGroupName
func TestValidateGroupName(t *testing.T) {
type fixture struct {
ok bool
group string
}
fixtures := []fixture{
fixture{false, ""}, // group cannot be empty
fixture{true, "testA"},
fixture{true, "te_stA"},
fixture{true, "a"},
fixture{true, "111111"},
fixture{true, "Zb44444444"},
fixture{false, "a b"},
fixture{false, "a.adsf"},
fixture{false, "a.a.bbb3"},
fixture{false, "(xxx)"},
fixture{false, "[asdf"},
fixture{false, "'asdfasdf"},
fixture{false, "&asdf"},
fixture{false, ">adsf"},
fixture{false, "adf/asdf"},
fixture{false, "a+b4"},
fixture{true, "4-2323"},
fixture{false, "__smoketest__"},
}
m := mysqlStore{}
for _, f := range fixtures {
assert.Equal(t, f.ok, m.ValidateGroupName(nil, f.group), f.group)
}
var h = make(http.Header)
h.Set("X-Origin", "smoketest")
assert.Equal(t, true, m.ValidateGroupName(h, "__smoketest__"))
}
示例5: TestPickServer
func TestPickServer(t *testing.T) {
cf := setupConfig()
picker := NewStandardServerSelector(1000)
picker.SetServers(cf.Servers)
addr, err := picker.PickServer("db", 23)
assert.Equal(t, "mongodb://127.0.0.1:27017/qa_royal_1/", addr)
assert.Equal(t, nil, err)
addr, err = picker.PickServer("invalid", 23)
assert.Equal(t, "", addr)
assert.Equal(t, ErrServerNotFound, err)
addr, err = picker.PickServer("db", 2300) // too big for 1000
assert.Equal(t, "", addr)
assert.Equal(t, ErrServerNotFound, err)
addr, err = picker.PickServer("default", 1<<30) // too big for 1000
assert.Equal(t, "mongodb://127.0.0.1:27017/qa_royal_0/", addr)
assert.Equal(t, nil, err)
addr, err = picker.PickServer("log", 1<<30) // too big for 1000
assert.Equal(t, "mongodb://127.0.0.1:27017/qa_royal_log/", addr)
assert.Equal(t, nil, err)
}
示例6: TestComplexDataType
func TestComplexDataType(t *testing.T) {
s := server.NewServer("test")
s.LoadConfig("../../etc/faed.cf.sample")
section, _ := s.Conf.Section("servants.redis")
cf := &config.ConfigRedis{}
cf.LoadConfig(section)
var (
pool = "default"
//val interface{}
err error
)
c := New(cf)
name := "funky.gao"
data := customType{X: 12, Y: 87, Name: name}
encodedData, err := msgpack.Marshal(data)
assert.Equal(t, nil, err)
key := "custome_complex_data_type"
err = c.Set(pool, key, encodedData)
assert.Equal(t, nil, err)
val, err := c.Get(pool, key)
assert.Equal(t, nil, err)
var val1 customType
msgpack.Unmarshal(val.([]byte), &val1)
assert.Equal(t, name, val1.Name)
}
示例7: TestSyslogStatsParser
func TestSyslogStatsParser(t *testing.T) {
msg := "Jan 26 21:30:37 ip-172-31-13-40 syslog-ng[2156]: Log statistics; dropped='program(/mnt/htdocs/als/forward.php)=0', dropped='program(/mnt/htdocs/als/bigdata_forward.php)=0', processed='center(queued)=1699039', processed='center(received)=1699039', processed='destination(d_als_prog)=1697379', processed='destination(d_boot)=0', processed='destination(d_auth)=0', processed='destination(d_cron)=1426', processed='destination(d_mlal)=0', processed='destination(d_als_file)=0', processed='destination(d_mesg)=229', processed='destination(d_bigdata_prog)=0', processed='destination(d_haproxy)=0', processed='destination(d_cons)=0', processed='destination(d_spol)=0', processed='destination(d_mail)=5', processed='source(s_udp)=0', processed='source(s_bigdata)=0', processed='source(s_sys)=1660', processed='source(s_als)=1697379', suppressed='program(/mnt/htdocs/als/forward.php)=0', suppressed='program(/mnt/htdocs/als/bigdata_forward.php)=0'"
assert.Equal(t, "", parseSyslogNgStats(msg))
msg = "Jan 26 21:30:37 ip-172-31-13-40 syslog-ng[2156]: Log statistics; dropped='program(/mnt/htdocs/als/forward.php)=56', dropped='program(/mnt/htdocs/als/bigdata_forward.php)=20', processed='center(queued)=1699039', processed='center(received)=1699039', processed='destination(d_als_prog)=1697379', processed='destination(d_boot)=0', processed='destination(d_auth)=0', processed='destination(d_cron)=1426', processed='destination(d_mlal)=0', processed='destination(d_als_file)=0', processed='destination(d_mesg)=229', processed='destination(d_bigdata_prog)=0', processed='destination(d_haproxy)=0', processed='destination(d_cons)=0', processed='destination(d_spol)=0', processed='destination(d_mail)=5', processed='source(s_udp)=0', processed='source(s_bigdata)=0', processed='source(s_sys)=1660', processed='source(s_als)=1697379', suppressed='program(/mnt/htdocs/als/forward.php)=0', suppressed='program(/mnt/htdocs/als/bigdata_forward.php)=0'"
assert.Equal(t, " [/mnt/htdocs/als/forward.php]dropped:56 [/mnt/htdocs/als/bigdata_forward.php]dropped:20", parseSyslogNgStats(msg))
}
示例8: TestLegacyServerSelector
func TestLegacyServerSelector(t *testing.T) {
cf := setupConfig()
picker := NewLegacyServerSelector(1000)
picker.SetServers(cf.Servers)
addr, err := picker.PickServer("db", 23)
assert.Equal(t, ErrServerNotFound, err)
addr, err = picker.PickServer("invalid", 23)
assert.Equal(t, ErrServerNotFound, err)
addr, err = picker.PickServer("db1", 2300)
assert.Equal(t, "mongodb://127.0.0.1:27017/qa_royal_1/", addr.Uri())
assert.Equal(t, nil, err)
addr, err = picker.PickServer("db1", 1<<30) // has nothing to do with shardId
assert.Equal(t, "mongodb://127.0.0.1:27017/qa_royal_1/", addr.Uri())
assert.Equal(t, nil, err)
addr, err = picker.PickServer("default", 1<<30) // too big for 1000
assert.Equal(t, "mongodb://127.0.0.1:27017/qa_royal_0/", addr.Uri())
assert.Equal(t, nil, err)
addr, err = picker.PickServer("log", 1<<30) // too big for 1000
assert.Equal(t, "mongodb://127.0.0.1:27017/qa_royal_log/", addr.Uri())
assert.Equal(t, nil, err)
}
示例9: TestDecodeMessageSetMultiMessage
func TestDecodeMessageSetMultiMessage(t *testing.T) {
w := bytes.NewBuffer(make([]byte, 0))
partition1, offset1, msg1 := int32(1), int64(9087), []byte("hello world")
partition2, offset2, msg2 := int32(0), int64(1298), []byte("good morning")
buf := make([]byte, 8)
// msg1
writeI32(w, buf, partition1)
writeI64(w, buf, offset1)
writeI32(w, buf, int32(len(msg1)))
w.Write(msg1)
// msg2
writeI32(w, buf, partition2)
writeI64(w, buf, offset2)
writeI32(w, buf, int32(len(msg2)))
w.Write(msg2)
msgSet := DecodeMessageSet(w.Bytes())
assert.Equal(t, 2, len(msgSet))
assert.Equal(t, partition1, msgSet[0].Partition)
assert.Equal(t, offset2, msgSet[1].Offset)
assert.Equal(t, msg2, msgSet[1].Value)
}
示例10: TestMessageUsage
func TestMessageUsage(t *testing.T) {
m := NewMessage(1029)
msg := "hello world"
m.Body = m.Body[:len(msg)]
copy(m.Body, msg)
assert.Equal(t, msg, string(m.Body))
assert.Equal(t, len(msg), len(m.Body))
}
示例11: TestIndexName
func TestIndexName(t *testing.T) {
date, _ := time.Parse("2006-01-02 15:04", "2011-01-19 22:15")
p := &engine.ConfProject{IndexPrefix: "rs"}
assert.Equal(t, "fun_rs_2011_01", indexName(p, "@ym", date))
assert.Equal(t, "fun_rs_2011_01_19", indexName(p, "@ymd", date))
assert.Equal(t, "fun_rs_2011_w03", indexName(p, "@ymw", date))
assert.Equal(t, "fun_foo", indexName(p, "foo", date))
}
示例12: TestLruCacheLenAndPurge
func TestLruCacheLenAndPurge(t *testing.T) {
lru := NewLruCache(0)
assert.Equal(t, 0, lru.Len())
lru.Set("myKey", 1234)
assert.Equal(t, 1, lru.Len())
lru.Purge()
assert.Equal(t, 0, lru.Len())
}
示例13: TestRealTopicsDumb
func TestRealTopicsDumb(t *testing.T) {
cf := DefaultConfig()
topics := []string{"t1", "t2", "__consumer_offsets"}
assert.Equal(t, []string{"t1", "t2"}, cf.realTopics(topics))
topics = []string{}
assert.Equal(t, topics, cf.realTopics(topics))
}
示例14: TestAssignResourcesToActors_ActorMoreThanJobQueues
func TestAssignResourcesToActors_ActorMoreThanJobQueues(t *testing.T) {
jobs := zk.ResourceList([]string{"job1"})
actors := zk.ActorList([]string{"1", "2"})
decision := assignResourcesToActors(actors, jobs)
t.Logf("%+v", decision)
assert.Equal(t, 0, len(decision["2"]))
assert.Equal(t, 1, len(decision["1"]))
}
示例15: TestNormalize
func TestNormalize(t *testing.T) {
msg := "batch token error! pre: leuw53.1e2t2j; current: 2m2w1z.1e2sz5 (1)"
b := normalizers["batch_token"].ReplaceAll([]byte(msg), []byte("?"))
assert.Equal(t, "batch token error! ?", string(b))
msg = "user id: 34343434 adfasf"
m := normalizers["digit"].ReplaceAll([]byte(msg), []byte("?"))
assert.Equal(t, "user id: ? adfasf", string(m))
}