当前位置: 首页>>代码示例>>Golang>>正文


Golang assert.NotEqual函数代码示例

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


在下文中一共展示了NotEqual函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestPause

func TestPause(t *testing.T) {
	log.SetOutput(ioutil.Discard)
	defer log.SetOutput(os.Stdout)

	_, _, nsqd := mustStartNSQD(NewNSQDOptions())
	defer nsqd.Exit()

	topicName := "test_topic_pause" + strconv.Itoa(int(time.Now().Unix()))
	topic := nsqd.GetTopic(topicName)
	err := topic.Pause()
	assert.Equal(t, err, nil)

	channel := topic.GetChannel("ch1")
	assert.NotEqual(t, channel, nil)

	msg := nsq.NewMessage(<-nsqd.idChan, []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaa"))
	err = topic.PutMessage(msg)
	assert.Equal(t, err, nil)

	time.Sleep(15 * time.Millisecond)

	assert.Equal(t, topic.Depth(), int64(1))
	assert.Equal(t, channel.Depth(), int64(0))

	err = topic.UnPause()
	assert.Equal(t, err, nil)

	time.Sleep(15 * time.Millisecond)

	assert.Equal(t, topic.Depth(), int64(0))
	assert.Equal(t, channel.Depth(), int64(1))
}
开发者ID:jsocol,项目名称:nsq,代码行数:32,代码来源:topic_test.go

示例2: TestParseProjectFromURL

func TestParseProjectFromURL(t *testing.T) {
	project, err :=
		ParseProjectFromURL("https://github.com/jingweno/gh/pulls/21")
	assert.Equal(t, nil, err)
	assert.Equal(t, "jingweno", project.Owner)
	assert.Equal(t, "gh", project.Name)

	project, err =
		ParseProjectFromURL("https://github.com/jingweno/gh")
	assert.Equal(t, nil, err)
	assert.Equal(t, "jingweno", project.Owner)
	assert.Equal(t, "gh", project.Name)

	project, err =
		ParseProjectFromURL("https://github.com/jingweno/gh/")
	assert.Equal(t, nil, err)
	assert.Equal(t, "jingweno", project.Owner)
	assert.Equal(t, "gh", project.Name)

	project, err =
		ParseProjectFromURL("http://github.com/jingweno/gh/")
	assert.NotEqual(t, nil, err)

	project, err =
		ParseProjectFromURL("http://github.com/jingweno/")
	assert.NotEqual(t, nil, err)
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:27,代码来源:project_test.go

示例3: TestParseLineCount

func TestParseLineCount(t *testing.T) {
	d := []byte("gorets:2|c|@0.1")
	packet := parseLine(d)
	assert.NotEqual(t, packet, nil)
	assert.Equal(t, "gorets", packet.Bucket)
	assert.Equal(t, float64(2), packet.ValFlt)
	assert.Equal(t, "c", packet.Modifier)
	assert.Equal(t, float32(0.1), packet.Sampling)

	d = []byte("gorets:4|c")
	packet = parseLine(d)
	assert.NotEqual(t, packet, nil)
	assert.Equal(t, "gorets", packet.Bucket)
	assert.Equal(t, float64(4), packet.ValFlt)
	assert.Equal(t, "c", packet.Modifier)
	assert.Equal(t, float32(1), packet.Sampling)

	d = []byte("gorets:-4|c")
	packet = parseLine(d)
	assert.NotEqual(t, packet, nil)
	assert.Equal(t, "gorets", packet.Bucket)
	assert.Equal(t, float64(-4), packet.ValFlt)
	assert.Equal(t, "c", packet.Modifier)
	assert.Equal(t, float32(1), packet.Sampling)

	d = []byte("gorets:1.25|c")
	packet = parseLine(d)
	assert.NotEqual(t, packet, nil)
	assert.Equal(t, "gorets", packet.Bucket)
	assert.Equal(t, 1.25, packet.ValFlt)
	assert.Equal(t, "c", packet.Modifier)
	assert.Equal(t, float32(1), packet.Sampling)
}
开发者ID:bitly,项目名称:statsdaemon,代码行数:33,代码来源:statsdaemon_test.go

示例4: TestSessionStateSerialization

func TestSessionStateSerialization(t *testing.T) {
	c, err := cookie.NewCipher([]byte(secret))
	assert.Equal(t, nil, err)
	c2, err := cookie.NewCipher([]byte(altSecret))
	assert.Equal(t, nil, err)
	s := &SessionState{
		Email:        "[email protected]",
		AccessToken:  "token1234",
		ExpiresOn:    time.Now().Add(time.Duration(1) * time.Hour),
		RefreshToken: "refresh4321",
	}
	encoded, err := s.EncodeSessionState(c)
	assert.Equal(t, nil, err)
	assert.Equal(t, 3, strings.Count(encoded, "|"))

	ss, err := DecodeSessionState(encoded, c)
	t.Logf("%#v", ss)
	assert.Equal(t, nil, err)
	assert.Equal(t, s.Email, ss.Email)
	assert.Equal(t, s.AccessToken, ss.AccessToken)
	assert.Equal(t, s.ExpiresOn.Unix(), ss.ExpiresOn.Unix())
	assert.Equal(t, s.RefreshToken, ss.RefreshToken)

	// ensure a different cipher can't decode properly (ie: it gets gibberish)
	ss, err = DecodeSessionState(encoded, c2)
	t.Logf("%#v", ss)
	assert.Equal(t, nil, err)
	assert.Equal(t, s.Email, ss.Email)
	assert.Equal(t, s.ExpiresOn.Unix(), ss.ExpiresOn.Unix())
	assert.NotEqual(t, s.AccessToken, ss.AccessToken)
	assert.NotEqual(t, s.RefreshToken, ss.RefreshToken)
}
开发者ID:KasparBP,项目名称:oauth2_proxy,代码行数:32,代码来源:session_state_test.go

示例5: TestQuit

// Test the quit command works...
func TestQuit(t *testing.T) {
	testInit(t)

	const (
		Key1 = "fooz"
		Val1 = "barz"
	)

	_, err := cn.Set(Key1, Val1, 0, 0, 0)
	assert.Equalf(t, mcNil, err, "unexpected error: %v", err)

	v, _, _, err := cn.Get(Key1)
	assert.Equalf(t, mcNil, err, "unexpected error: %v", err)
	assert.Equalf(t, Val1, v, "wrong value: %s", v)

	err = cn.Quit()
	assert.Equalf(t, mcNil, err, "unexpected error: %v", err)

	_, _, _, err = cn.Get(Key1)
	assert.NotEqual(t, mcNil, err, "expected an error (closed connection)")

	err = cn.Quit()
	assert.NotEqual(t, mcNil, err, "expected an error (closed connection)")

	cn = nil
}
开发者ID:memcachier,项目名称:mc,代码行数:27,代码来源:mc_test.go

示例6: TestParseLineTimer

func TestParseLineTimer(t *testing.T) {
	d := []byte("glork:320|ms")
	packet := parseLine(d)
	assert.NotEqual(t, packet, nil)
	assert.Equal(t, "glork", packet.Bucket)
	assert.Equal(t, float64(320), packet.ValFlt)
	assert.Equal(t, "ms", packet.Modifier)
	assert.Equal(t, float32(1), packet.Sampling)

	d = []byte("glork:320|ms|@0.1")
	packet = parseLine(d)
	assert.NotEqual(t, packet, nil)
	assert.Equal(t, "glork", packet.Bucket)
	assert.Equal(t, float64(320), packet.ValFlt)
	assert.Equal(t, "ms", packet.Modifier)
	assert.Equal(t, float32(0.1), packet.Sampling)

	d = []byte("glork:3.7211|ms")
	packet = parseLine(d)
	assert.NotEqual(t, packet, nil)
	assert.Equal(t, "glork", packet.Bucket)
	assert.Equal(t, float64(3.7211), packet.ValFlt)
	assert.Equal(t, "ms", packet.Modifier)
	assert.Equal(t, float32(1), packet.Sampling)
}
开发者ID:bitly,项目名称:statsdaemon,代码行数:25,代码来源:statsdaemon_test.go

示例7: TestParseLineGauge

func TestParseLineGauge(t *testing.T) {
	d := []byte("gaugor:333|g")
	packet := parseLine(d)
	assert.NotEqual(t, packet, nil)
	assert.Equal(t, "gaugor", packet.Bucket)
	assert.Equal(t, GaugeData{false, false, 333}, packet.Value)
	assert.Equal(t, "g", packet.Modifier)
	assert.Equal(t, float32(1), packet.Sampling)

	d = []byte("gaugor:-10|g")
	packet = parseLine(d)
	assert.NotEqual(t, packet, nil)
	assert.Equal(t, "gaugor", packet.Bucket)
	assert.Equal(t, GaugeData{true, true, 10}, packet.Value)
	assert.Equal(t, "g", packet.Modifier)
	assert.Equal(t, float32(1), packet.Sampling)

	d = []byte("gaugor:+4|g")
	packet = parseLine(d)
	assert.NotEqual(t, packet, nil)
	assert.Equal(t, "gaugor", packet.Bucket)
	assert.Equal(t, GaugeData{true, false, 4}, packet.Value)
	assert.Equal(t, "g", packet.Modifier)
	assert.Equal(t, float32(1), packet.Sampling)

	// >max(int64) && <max(uint64)
	d = []byte("gaugor:18446744073709551606|g")
	packet = parseLine(d)
	assert.NotEqual(t, packet, nil)
	assert.Equal(t, "gaugor", packet.Bucket)
	assert.Equal(t, GaugeData{false, false, 18446744073709551606}, packet.Value)
	assert.Equal(t, "g", packet.Modifier)
	assert.Equal(t, float32(1), packet.Sampling)
}
开发者ID:wojtekzw,项目名称:statsdaemon,代码行数:34,代码来源:statsdaemon_test.go

示例8: TestDoozerWalk

func TestDoozerWalk(t *testing.T) {
	l := mustListen()
	defer l.Close()
	u := mustListenPacket(l.Addr().String())
	defer u.Close()

	go Main("a", "X", "", nil, u, l, nil, 1e9, 2e9, 3e9)

	cl := doozer.New("foo", l.Addr().String())

	cl.Set("/test/foo", store.Clobber, []byte("bar"))
	cl.Set("/test/fun", store.Clobber, []byte("house"))

	w, err := cl.Walk("/test/**", nil, nil, nil)
	assert.Equal(t, nil, err, err)

	ev := <-w.C
	assert.NotEqual(t, (*doozer.Event)(nil), ev)
	assert.Equal(t, "/test/foo", ev.Path)
	assert.Equal(t, "bar", string(ev.Body))
	assert.T(t, ev.IsSet())

	ev = <-w.C
	assert.NotEqual(t, (*doozer.Event)(nil), ev)
	assert.Equal(t, "/test/fun", ev.Path)
	assert.Equal(t, "house", string(ev.Body))
	assert.T(t, ev.IsSet())

	ev = <-w.C
	assert.Tf(t, closed(w.C), "got %v", ev)
}
开发者ID:chrismoos,项目名称:doozerd,代码行数:31,代码来源:peer_test.go

示例9: TestParseURL

func TestParseURL(t *testing.T) {
	url, err :=
		ParseURL("https://github.com/jingweno/gh/pulls/21")
	assert.Equal(t, nil, err)
	assert.Equal(t, "jingweno", url.Owner)
	assert.Equal(t, "gh", url.Name)
	assert.Equal(t, "pulls/21", url.ProjectPath())

	url, err =
		ParseURL("https://github.com/jingweno/gh")
	assert.Equal(t, nil, err)
	assert.Equal(t, "jingweno", url.Owner)
	assert.Equal(t, "gh", url.Name)
	assert.Equal(t, "", url.ProjectPath())

	url, err =
		ParseURL("https://github.com/jingweno/gh/")
	assert.Equal(t, nil, err)
	assert.Equal(t, "jingweno", url.Owner)
	assert.Equal(t, "gh", url.Name)
	assert.Equal(t, "", url.ProjectPath())

	url, err =
		ParseURL("http://github.com/jingweno/gh/")
	assert.NotEqual(t, nil, err)

	url, err =
		ParseURL("http://github.com/jingweno/")
	assert.NotEqual(t, nil, err)
}
开发者ID:johnbellone,项目名称:gh,代码行数:30,代码来源:url_test.go

示例10: TestDelete

func TestDelete(t *testing.T) {
	var didUnsub bool = false
	unsubf := func(channels ...string) error {
		assert.Equal(t, "bin_name", channels[0])
		didUnsub = true
		return nil
	}

	sm := NewSocketMap(unsubFunc(unsubf))
	err := sm.Delete("bin_name", "socket_uuid1")
	assert.NotEqual(t, nil, err)
	ms1 := &MockSocket{name: "mock_socket1"}
	ms2 := &MockSocket{name: "mock_socket2"}
	sm.Add("bin_name", "socket_uuid1", ms1)
	sm.Add("bin_name", "socket_uuid2", ms2)

	err = sm.Delete("bin_name", "unknown_uuid")
	assert.NotEqual(t, nil, err)
	err = sm.Delete("unknown_bin_name", "socket_uuid1")
	assert.NotEqual(t, nil, err)
	err = sm.Delete("bin_name", "socket_uuid1")
	assert.Equal(t, nil, err)
	assert.Equal(t, false, didUnsub)
	err = sm.Delete("bin_name", "socket_uuid2")
	assert.Equal(t, nil, err)
	assert.Equal(t, true, didUnsub)
}
开发者ID:jyaganeh,项目名称:geobin.io,代码行数:27,代码来源:socketmap_test.go

示例11: TestDepthFirstSearch

func TestDepthFirstSearch(t *testing.T) {
	G := NewAdjGraphForFile("./algs4-data/tinyG.txt")
	var search Search
	var slice []int
	// test 1
	search = NewDepthFirstSearch(G, 0)
	assert.NotEqual(t, search.Count(), G.V())
	slice = make([]int, 0)
	for v := 0; v < G.V(); v++ {
		if search.Marked(v) {
			slice = append(slice, v)
		}
	}
	sort.Ints(slice)
	assert.Equal(t, slice, []int{0, 1, 2, 3, 4, 5, 6})
	// test 2
	search = NewDepthFirstSearch(G, 9)
	assert.NotEqual(t, search.Count(), G.V())
	slice = make([]int, 0)
	for v := 0; v < G.V(); v++ {
		if search.Marked(v) {
			slice = append(slice, v)
		}
	}
	sort.Ints(slice)
	assert.Equal(t, slice, []int{9, 10, 11, 12})
}
开发者ID:samuelyao314,项目名称:mygo,代码行数:27,代码来源:DepthFirstSearch_test.go

示例12: TestSimplejson

func TestSimplejson(t *testing.T) {
	var ok bool
	var err error

	log.SetOutput(ioutil.Discard)

	js, err := NewJson([]byte(`{ 
		"test": { 
			"array": [1, "2", 3],
			"int": 10,
			"float": 5.150,
			"bignum": 9223372036854775807,
			"string": "simplejson"
		}
	}`))

	assert.NotEqual(t, nil, js)
	assert.Equal(t, nil, err)

	_, ok = js.CheckGet("test")
	assert.Equal(t, true, ok)

	_, ok = js.CheckGet("missing_key")
	assert.Equal(t, false, ok)

	arr, _ := js.Get("test").Get("array").Array()
	assert.NotEqual(t, nil, arr)
	for i, v := range arr {
		var iv int
		switch v.(type) {
		case float64:
			iv = int(v.(float64))
		case string:
			iv, _ = strconv.Atoi(v.(string))
		}
		assert.Equal(t, i+1, iv)
	}

	i, _ := js.Get("test").Get("int").Int()
	assert.Equal(t, 10, i)

	f, _ := js.Get("test").Get("float").Float64()
	assert.Equal(t, 5.150, f)

	s, _ := js.Get("test").Get("string").String()
	assert.Equal(t, "simplejson", s)

	mi := js.Get("test").Get("int").MustInt()
	assert.Equal(t, 10, mi)

	mi2 := js.Get("test").Get("missing_int").MustInt(5150)
	assert.Equal(t, 5150, mi2)

	ms := js.Get("test").Get("string").MustString()
	assert.Equal(t, "simplejson", ms)

	ms2 := js.Get("test").Get("missing_string").MustString("fyea")
	assert.Equal(t, "fyea", ms2)
}
开发者ID:danielhfrank,项目名称:go-simplejson,代码行数:59,代码来源:simplejson_test.go

示例13: TestGetOrCreateNode

// 18.4.2. Create Node with properties
func TestGetOrCreateNode(t *testing.T) {
	db := connectTest(t)
	defer cleanup(t, db)
	label, err := randutil.String(12, randutil.Alphabet)
	if err != nil {
		t.Fatal(err)
	}
	key, err := randutil.String(12, randutil.Alphabet)
	if err != nil {
		t.Fatal(err)
	}
	value, err := randutil.String(12, randutil.Alphabet)
	if err != nil {
		t.Fatal(err)
	}
	p0 := Props{key: value, "foo": "bar"}
	p1 := Props{key: value}
	p2 := Props{"foo": "bar"}
	//
	// Create unique node
	//
	n0, created, err := db.GetOrCreateNode(label, key, p0)
	if err != nil {
		t.Fatal(err)
	}
	if !created {
		t.Fatal("Failed to create unique node")
	}
	check0, err := n0.Properties()
	if err != nil {
		t.Fatal(err)
	}
	assert.Equal(t, p0, check0)
	//
	// Get unique node
	//
	n1, created, err := db.GetOrCreateNode(label, key, p1)
	if err != nil {
		t.Fatal(err)
	}
	if created {
		t.Fatal("Failed to retrieve unique node")
	}
	check1, err := n1.Properties()
	if err != nil {
		t.Fatal(err)
	}
	assert.Equal(t, p0, check1)
	//
	// No key in props
	//
	_, _, err = db.GetOrCreateNode(label, key, p2)
	assert.NotEqual(t, nil, err)
	//
	// Empty label
	//
	_, _, err = db.GetOrCreateNode("", key, p0)
	assert.NotEqual(t, nil, err)
}
开发者ID:gregzuro,项目名称:neoism,代码行数:60,代码来源:node_test.go

示例14: TestMultipleCloses

func TestMultipleCloses(t *testing.T) {
	c := NewMockClient()
	err := c.Close()
	assert.Equal(t, nil, err)
	err = c.Close()
	assert.NotEqual(t, nil, "This should be an error on subsequent closes")
	err = c.Close()
	assert.NotEqual(t, nil, "This should be an error on subsequent closes")
}
开发者ID:john-cai,项目名称:tools,代码行数:9,代码来源:statsd_test.go

示例15: TestJitter

// Tests that jitter adds randomness.
func TestJitter(t *testing.T) {
	defaultBacko := NewBacko(milliseconds(100), 2, 1, milliseconds(10*1000))
	jitterBacko := NewBacko(milliseconds(100), 2, 1, milliseconds(10*1000))

	// TODO: Check jittered durations are within a range.
	assert.NotEqual(t, jitterBacko.Duration(0), defaultBacko.Duration(0))
	assert.NotEqual(t, jitterBacko.Duration(1), defaultBacko.Duration(1))
	assert.NotEqual(t, jitterBacko.Duration(2), defaultBacko.Duration(2))
	assert.NotEqual(t, jitterBacko.Duration(3), defaultBacko.Duration(3))
}
开发者ID:Rudloff,项目名称:platform,代码行数:11,代码来源:backo_test.go


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