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

Golang assert.NotEqual函数代码示例

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

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



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

示例1: TestIPAM

func TestIPAM(t *testing.T) {
	reg := getNew(t)

	i, cap := reg.IPAM("default")
	assert.NotEqual(t, i, nil)
	assert.NotEqual(t, cap, nil)
}
开发者ID:CtrlZvi,项目名称:libnetwork,代码行数:7,代码来源:drvregistry_test.go


示例2: TestSystem

func TestSystem(t *testing.T) {
	tmpdir, err := ioutil.TempDir("", "")
	require.NoError(t, err)
	defer os.RemoveAll(tmpdir)

	sys := NewSystem(SystemConfig{BuildTempDir: tmpdir})
	{
		tmpFile1, err := sys.SmallTempFile()
		if assert.NoError(t, err) {
			defer os.Remove(tmpFile1.Name())
			defer tmpFile1.Close()
			tmpFile2, err := sys.SmallTempFile()
			if assert.NoError(t, err) {
				defer os.Remove(tmpFile2.Name())
				defer tmpFile2.Close()
				assert.NotEqual(t, tmpFile1.Name(), tmpFile2.Name())
			}
		}
	}
	{
		tmpDir1, err := sys.TempDirForBuild()
		if assert.NoError(t, err) {
			assert.True(t, strings.HasPrefix(tmpDir1, tmpdir))
			tmpDir2, err := sys.TempDirForBuild()
			if assert.NoError(t, err) {
				assert.True(t, strings.HasPrefix(tmpDir2, tmpdir))
				assert.NotEqual(t, tmpDir1, tmpDir2)
			}
		}
	}
}
开发者ID:bunsanorg,项目名称:pm,代码行数:31,代码来源:system_test.go


示例3: TestValidClaimsContext

func TestValidClaimsContext(t *testing.T) {
	userClaims := ClaimsContext{"user-id": "123456", "custom-time": 1453066866, "custom-time-f": 1631.083, "custom-date": time.Date(2016, time.January, 17, 19, 00, 00, 00, &time.Location{})}
	ctx, err := NewClaimsContext("fosite/auth", "Peter", "[email protected]", "", time.Now().Add(time.Hour), time.Now(), time.Now(), userClaims)
	assert.Nil(t, err)

	assert.Equal(t, "fosite/auth", ctx.GetIssuer())
	assert.NotEqual(t, "fosite/token", ctx.GetIssuer())
	assert.Equal(t, "Peter", ctx.GetSubject())
	assert.NotEqual(t, "Alex", ctx.GetSubject())
	assert.Equal(t, "[email protected]", ctx.GetAudience())
	assert.NotEqual(t, "[email protected]", ctx.GetAudience())

	assert.Equal(t, time.Now().Day(), ctx.GetNotBefore().Day())
	assert.Equal(t, time.Now().Day(), ctx.GetIssuedAt().Day())
	assert.Equal(t, time.Now().Add(time.Hour).Day(), ctx.GetExpiresAt().Day())

	assert.Equal(t, time.Now().Add(time.Hour).Day(), ctx.GetAsTime("exp").Day())
	assert.Equal(t, time.Date(2016, time.January, 17, 19, 00, 00, 00, &time.Location{}), ctx.GetAsTime("custom-date"))
	assert.NotNil(t, ctx.GetAsTime("custom-time"))
	assert.NotNil(t, ctx.GetAsTime("custom-time-f"))

	str, err := ctx.String()
	assert.NotNil(t, str)
	assert.Nil(t, err)

	assert.Empty(t, ctx.GetAsString("doesnotexist"))
	assert.Equal(t, time.Time{}, ctx.GetAsTime("doesnotexist"))
	stringRep, err := ctx.String()
	assert.Nil(t, err)
	assert.NotEmpty(t, stringRep)
}
开发者ID:jesseward,项目名称:fosite,代码行数:31,代码来源:claims_test.go


示例4: TestCreateGenesisBlock

func TestCreateGenesisBlock(t *testing.T) {
	defer cleanupVisor()
	// Test as master, successful
	vc := newMasterVisorConfig(t)
	v := NewMinimalVisor(vc)
	assert.True(t, v.Config.IsMaster)
	assert.Equal(t, len(v.blockchain.Blocks), 0)
	assert.Equal(t, len(v.blockSigs.Sigs), 0)
	sb := v.CreateGenesisBlock()
	assert.NotEqual(t, sb.Block, coin.Block{})
	assert.NotEqual(t, sb.Sig, cipher.Sig{})
	assert.Equal(t, len(v.blockchain.Blocks), 1)
	assert.Equal(t, len(v.blockSigs.Sigs), 1)
	assert.Nil(t, v.blockSigs.Verify(vc.MasterKeys.Public, v.blockchain))

	// Test as not master, successful
	vc = newGenesisConfig(t)
	v = NewMinimalVisor(vc)
	assert.False(t, v.Config.IsMaster)
	assert.Equal(t, len(v.blockchain.Blocks), 0)
	assert.Equal(t, len(v.blockSigs.Sigs), 0)
	sb = v.CreateGenesisBlock()
	assert.NotEqual(t, sb.Block, coin.Block{})
	assert.NotEqual(t, sb.Sig, cipher.Sig{})
	assert.Equal(t, len(v.blockchain.Blocks), 1)
	assert.Equal(t, len(v.blockSigs.Sigs), 1)
	assert.Nil(t, v.blockSigs.Verify(vc.MasterKeys.Public, v.blockchain))
	assert.Equal(t, v.Config.GenesisSignature, sb.Sig)
	assert.Equal(t, v.blockchain.Blocks[0].Header.Time, v.Config.GenesisTimestamp)

	// Test as master, blockSigs invalid for pubkey
	vc = newMasterVisorConfig(t)
	vc.MasterKeys.Public = cipher.PubKey{}
	v = NewMinimalVisor(vc)
	assert.True(t, v.Config.IsMaster)
	assert.Equal(t, len(v.blockchain.Blocks), 0)
	assert.Equal(t, len(v.blockSigs.Sigs), 0)
	assert.Panics(t, func() { v.CreateGenesisBlock() })

	// Test as not master, blockSigs invalid for pubkey
	vc = newGenesisConfig(t)
	vc.MasterKeys.Public = cipher.PubKey{}
	v = NewMinimalVisor(vc)
	assert.False(t, v.Config.IsMaster)
	assert.Equal(t, len(v.blockchain.Blocks), 0)
	assert.Equal(t, len(v.blockSigs.Sigs), 0)
	assert.Panics(t, func() { v.CreateGenesisBlock() })

	// Test as master, signing failed
	vc = newMasterVisorConfig(t)
	vc.MasterKeys.Secret = cipher.SecKey{}
	assert.Equal(t, vc.MasterKeys.Secret, cipher.SecKey{})
	v = NewMinimalVisor(vc)
	assert.True(t, v.Config.IsMaster)
	assert.Equal(t, v.Config, vc)
	assert.Equal(t, v.Config.MasterKeys.Secret, cipher.SecKey{})
	assert.Equal(t, len(v.blockchain.Blocks), 0)
	assert.Equal(t, len(v.blockSigs.Sigs), 0)
	assert.Panics(t, func() { v.CreateGenesisBlock() })
}
开发者ID:keepwalking1234,项目名称:skycoin,代码行数:60,代码来源:blockchain_test.go


示例5: TestFileAttrOwnership

func (suite *FsTestSuite) TestFileAttrOwnership() {
	assert := suite.assert

	cases := []string{
		".clear_cache",
		".json/secret/hmac.key",
		".json/secrets",
		".running",
		".version",
		"hmac.key",
	}

	for _, filename := range cases {
		attr, status := suite.fs.GetAttr(filename, fuseContext)
		assert.Equal(fuse.OK, status, "Expected %v attr status to be fuse.OK", filename)
		assert.Equal(_SomeUID, attr.Uid, "Expected %v uid to be default", filename)
		assert.Equal(_SomeUID, attr.Gid, "Expected %v gid to be default", filename)
	}

	filename := "Nobody_PgPass"
	attr, status := suite.fs.GetAttr(filename, fuseContext)
	assert.Equal(fuse.OK, status, "Expected %v attr status to be fuse.OK", filename)
	assert.NotEqual(_SomeUID, attr.Uid, "Expected %v uid to not be default", filename)
	assert.NotEqual(0, attr.Uid, "Expected %v uid to be set", filename)
	assert.NotEqual(_SomeUID, attr.Gid, "Expected %v gid to not be default", filename)
	assert.NotEqual(0, attr.Gid, "Expected %v gid to be set", filename)
}
开发者ID:mcpherrinm,项目名称:keywhiz-fs,代码行数:27,代码来源:fs_test.go


示例6: TestTransactionSignInput

func TestTransactionSignInput(t *testing.T) {
	tx := &Transaction{}
	// Panics if too many inputs exist
	tx.In = append(tx.In, make([]SHA256, math.MaxUint16+2)...)
	_, s := GenerateKeyPair()
	assert.Panics(t, func() { tx.signInput(0, s, SHA256{}) })

	// Panics if idx too large for number of inputs
	tx = &Transaction{}
	ux, s := makeUxOutWithSecret(t)
	tx.PushInput(ux.Hash())
	assert.Panics(t, func() { tx.signInput(1, s, SHA256{}) })

	// Sigs should be extended if needed
	assert.Equal(t, len(tx.Head.Sigs), 0)
	ux2, s2 := makeUxOutWithSecret(t)
	tx.PushInput(ux2.Hash())
	tx.signInput(1, s2, tx.hashInner())
	assert.Equal(t, len(tx.Head.Sigs), 2)
	assert.Equal(t, tx.Head.Sigs[0], Sig{})
	assert.NotEqual(t, tx.Head.Sigs[1], Sig{})
	// Signing the earlier sig should be ok
	tx.signInput(0, s, tx.hashInner())
	assert.Equal(t, len(tx.Head.Sigs), 2)
	assert.NotEqual(t, tx.Head.Sigs[0], Sig{})
	assert.NotEqual(t, tx.Head.Sigs[1], Sig{})
}
开发者ID:up4k,项目名称:skycoin,代码行数:27,代码来源:transactions_test.go


示例7: TestTracingPropagates

func TestTracingPropagates(t *testing.T) {
	WithVerifiedServer(t, nil, func(ch *Channel, hostPort string) {
		handler := &traceHandler{t: t, ch: ch}
		json.Register(ch, json.Handlers{
			"call": handler.call,
		}, handler.onError)

		ctx, cancel := json.NewContext(time.Second)
		defer cancel()

		peer := ch.Peers().GetOrAdd(ch.PeerInfo().HostPort)
		var response TracingResponse
		require.NoError(t, json.CallPeer(ctx, peer, ch.PeerInfo().ServiceName, "call", &TracingRequest{
			ForwardCount: 1,
		}, &response))

		clientSpan := CurrentSpan(ctx)
		require.NotNil(t, clientSpan)
		assert.Equal(t, uint64(0), clientSpan.ParentID())

		assert.Equal(t, uint64(0), clientSpan.ParentID())
		assert.NotEqual(t, uint64(0), clientSpan.TraceID())
		assert.Equal(t, clientSpan.TraceID(), response.TraceID)
		assert.Equal(t, clientSpan.SpanID(), response.ParentID)
		assert.Equal(t, response.TraceID, response.SpanID, "traceID = spanID for root span")

		nestedResponse := response.Child
		require.NotNil(t, nestedResponse)
		assert.Equal(t, clientSpan.TraceID(), nestedResponse.TraceID)
		assert.Equal(t, response.SpanID, nestedResponse.ParentID)
		assert.NotEqual(t, response.SpanID, nestedResponse.SpanID)
	})
}
开发者ID:hustxiaoc,项目名称:tchannel,代码行数:33,代码来源:tracing_test.go


示例8: TestNewV5

func TestNewV5(t *testing.T) {
	u := NewV5(NamespaceURL, goLang)

	assert.Equal(t, 5, u.Version(), "Expected correct version")
	assert.Equal(t, ReservedRFC4122, u.Variant(), "Expected correct variant")
	assert.True(t, parseUUIDRegex.MatchString(u.String()), "Expected string representation to be valid")

	ur, _ := url.Parse(string(goLang))

	// Same NS same name MUST be equal
	u2 := NewV5(NamespaceURL, ur)
	assert.Equal(t, u, u2, "Expected UUIDs generated with same namespace and name to equal")

	// Different NS same name MUST NOT be equal
	u3 := NewV5(NamespaceDNS, ur)
	assert.NotEqual(t, u, u3, "Expected UUIDs generated with different namespace and same name to be different")

	// Same NS different name MUST NOT be equal
	u4 := NewV5(NamespaceURL, u)
	assert.NotEqual(t, u, u4, "Expected UUIDs generated with the same namespace and different names to be different")

	ids := []UUID{
		u, u2, u3, u4,
	}

	for j, id := range ids {
		i := NewV5(NamespaceURL, NewName(string(j), id))
		assert.NotEqual(t, i, id, "Expected UUIDs generated with the same namespace and different names to be different")

	}
}
开发者ID:wutaizeng,项目名称:kapacitor,代码行数:31,代码来源:rfc4122_test.go


示例9: TestChecksumFlagSet_Differs

func TestChecksumFlagSet_Differs(t *testing.T) {
	set := flag.NewFlagSet("foobar", flag.ContinueOnError)
	flagz.DynDuration(set, "some_duration_1", 5*time.Second, "Use it or lose it")
	flagz.DynInt64(set, "some_int_1", 13371337, "Use it or lose it")
	set.String("static_string_1", "foobar", "meh")

	preInitChecksum := flagz.ChecksumFlagSet(set, nil)
	t.Logf("pre init checksum:  %x", preInitChecksum)

	set.Parse([]string{"--some_duration_1", "3s", "--static_string_1", "goodbar"})
	postInitChecksum := flagz.ChecksumFlagSet(set, nil)
	t.Logf("post init checksum: %x", postInitChecksum)
	assert.NotEqual(t, preInitChecksum, postInitChecksum, "checksum must be different init changed 2 flags")

	require.NoError(t, set.Set("some_int_1", "1337"))
	postSet1Checksum := flagz.ChecksumFlagSet(set, nil)
	t.Logf("post set1 checksum: %x", postSet1Checksum)
	assert.NotEqual(t, postInitChecksum, postSet1Checksum, "checksum must be different after a internal flag change")

	require.NoError(t, set.Set("some_duration_1", "4s"))
	postSet2Checksum := flagz.ChecksumFlagSet(set, nil)
	t.Logf("post set2 checksum: %x", postSet2Checksum)
	assert.NotEqual(t, postSet1Checksum, postSet2Checksum, "checksum must be different after a internal flag change")

	require.NoError(t, set.Set("some_duration_1", "3s"))
	postSet3Checksum := flagz.ChecksumFlagSet(set, nil)
	t.Logf("post set3 checksum: %x", postSet3Checksum)
	assert.EqualValues(t, postSet1Checksum, postSet3Checksum, "flipping back duration flag to state at set1 should make it equal")
}
开发者ID:mwitkow,项目名称:go-flagz,代码行数:29,代码来源:checksum_test.go


示例10: TestLoad

func TestLoad(t *testing.T) {
	_, err := Load("../foo.bar")
	assert.NotNil(t, err, "should return an error when file does not exist")

	_, err = Load("../uchiwa.go")
	assert.NotNil(t, err, "should return an error when it cannot parse a file")

	conf, err := Load("../../fixtures/config_test.json")
	assert.Nil(t, err, "got unexpected error: %s", err)

	// private config
	assert.NotEqual(t, "*****", conf.Uchiwa.User, "Uchiwa user in private config shouldn't be masked")
	assert.NotEqual(t, "*****", conf.Uchiwa.Pass, "Uchiwa pass in private config shouldn't be masked")
	for i := range conf.Sensu {
		assert.NotEqual(t, "*****", conf.Sensu[i].User, "Sensu APIs user in private config shouldn't be masked")
		assert.NotEqual(t, "*****", conf.Sensu[i].Pass, "Sensu APIs pass in private config shouldn't be masked")
	}
	assert.Equal(t, 1, len(conf.Uchiwa.Users))

	// public config
	public := conf.GetPublic()
	assert.Equal(t, "*****", public.Uchiwa.User, "Uchiwa user in public config should be masked")
	assert.Equal(t, "*****", public.Uchiwa.Pass, "Uchiwa pass in public config should be masked")
	for i := range public.Sensu {
		assert.Equal(t, "*****", public.Sensu[i].User, "Sensu APIs user in public config should be masked")
		assert.Equal(t, "*****", public.Sensu[i].Pass, "Sensu APIs pass in public config should be masked")
	}
	assert.Equal(t, 0, len(public.Uchiwa.Users))

}
开发者ID:RiRa12621,项目名称:uchiwa,代码行数:30,代码来源:config_test.go


示例11: TestSccStack

// This func tests the correctness of inSccStack() pushSccStack() and  popSccStack()
func TestSccStack(t *testing.T) {
	i := commonTestlibExampleCommittedInstance()
	iClone := commonTestlibCloneInstance(i)
	iClone.ballot = iClone.ballot.IncNumClone()
	r := i.replica

	// push two items
	r.pushSccStack(i)
	r.pushSccStack(iClone)

	// test if they are valid in the stack
	assert.True(t, r.inSccStack(i))
	assert.True(t, r.inSccStack(iClone))

	// pop out one item and test if it's valid
	iPop := r.popSccStack()
	assert.Equal(t, iClone, iPop)
	assert.NotEqual(t, i, iPop)

	// test the content in the stack
	assert.False(t, r.inSccStack(iClone))
	assert.True(t, r.inSccStack(i))

	// pop out another one and test if it's valid
	iPop = r.popSccStack()
	assert.Equal(t, i, iPop)
	assert.NotEqual(t, iClone, iPop)

	// test the content of the stack
	assert.False(t, r.inSccStack(i))
}
开发者ID:sargun,项目名称:epaxos,代码行数:32,代码来源:replica_test.go


示例12: TestPropagateIdsToChildren

func TestPropagateIdsToChildren(t *testing.T) {
	// Make a generic file with 6 events and 2 checksums
	gf := testutil.MakeGenericFile(6, 2, "test.edu/test_bag/file.txt")
	assert.Equal(t, 6, len(gf.PremisEvents))
	assert.Equal(t, 2, len(gf.Checksums))

	// Check pre-condition before actual test.
	for _, event := range gf.PremisEvents {
		assert.NotEqual(t, gf.Id, event.GenericFileId)
		assert.NotEqual(t, gf.Identifier, event.GenericFileIdentifier)
		assert.NotEqual(t, gf.IntellectualObjectId, event.IntellectualObjectId)
		assert.NotEqual(t, gf.IntellectualObjectIdentifier, event.IntellectualObjectIdentifier)
	}
	for _, checksum := range gf.Checksums {
		assert.NotEqual(t, gf.Id, checksum.GenericFileId)
	}

	gf.PropagateIdsToChildren()
	for _, event := range gf.PremisEvents {
		assert.Equal(t, gf.Id, event.GenericFileId)
		assert.Equal(t, gf.Identifier, event.GenericFileIdentifier)
		assert.Equal(t, gf.IntellectualObjectId, event.IntellectualObjectId)
		assert.Equal(t, gf.IntellectualObjectIdentifier, event.IntellectualObjectIdentifier)
	}
	for _, checksum := range gf.Checksums {
		assert.Equal(t, gf.Id, checksum.GenericFileId)
	}
}
开发者ID:APTrust,项目名称:exchange,代码行数:28,代码来源:generic_file_test.go


示例13: TestRemoveInternalNetwork

func TestRemoveInternalNetwork(t *testing.T) {
	ts := newTestServer(t)
	defer ts.Stop()

	name := "testnet3"
	spec := createNetworkSpec(name)
	// add label denoting internal network
	spec.Annotations.Labels = map[string]string{"com.docker.swarm.internal": "true"}
	nr, err := ts.Server.createInternalNetwork(context.Background(), &api.CreateNetworkRequest{
		Spec: spec,
	})
	assert.NoError(t, err)
	assert.NotEqual(t, nr.Network, nil)
	assert.NotEqual(t, nr.Network.ID, "")

	_, err = ts.Client.RemoveNetwork(context.Background(), &api.RemoveNetworkRequest{NetworkID: nr.Network.ID})
	// this SHOULD fail, because the internal network cannot be removed
	assert.Error(t, err)
	assert.Equal(t, grpc.Code(err), codes.PermissionDenied)
	assert.Contains(t, err.Error(), fmt.Sprintf("%s (%s) is a pre-defined network and cannot be removed", name, nr.Network.ID))

	// then, check to make sure network is still there
	ng, err := ts.Client.GetNetwork(context.Background(), &api.GetNetworkRequest{NetworkID: nr.Network.ID})
	assert.NoError(t, err)
	assert.NotEqual(t, ng.Network, nil)
	assert.NotEqual(t, ng.Network.ID, "")
}
开发者ID:docker,项目名称:swarmkit,代码行数:27,代码来源:network_test.go


示例14: TestContext

// TestContext runs
func TestContext(t *testing.T) {
	assert := assert.New(t)

	{
		var (
			ctx1    *gin.Context = SharedContext()
			ctx2    *gin.Context = SharedContext()
			ctx3    *gin.Context = SharedContext()
			ctxptr1 string       = fmt.Sprintf("%p", ctx1)
			ctxptr2 string       = fmt.Sprintf("%p", ctx2)
			ctxptr3 string       = fmt.Sprintf("%p", ctx3)
		)
		if assert.NotNil(ctx1) {
			assert.Nil(ctx1.Request)
		}
		if assert.NotNil(ctx2) {
			assert.Nil(ctx2.Request)
		}
		if assert.NotNil(ctx3) {
			assert.Nil(ctx3.Request)
		}

		assert.NotEqual(ctxptr1, ctxptr2)
		assert.NotEqual(ctxptr2, ctxptr3)
		assert.NotEqual(ctxptr3, ctxptr1)
	}

	Init()

	{
		var (
			ctx1    *gin.Context = SharedContext()
			ctx2    *gin.Context = SharedContext()
			ctx3    *gin.Context = SharedContext()
			ctxptr1 string       = fmt.Sprintf("%p", ctx1)
			ctxptr2 string       = fmt.Sprintf("%p", ctx2)
			ctxptr3 string       = fmt.Sprintf("%p", ctx3)
			ptr1    string       = fmt.Sprintf("%p", ctx1.Request)
			ptr2    string       = fmt.Sprintf("%p", ctx2.Request)
			ptr3    string       = fmt.Sprintf("%p", ctx3.Request)
		)
		if assert.NotNil(ctx1) {
			assert.NotNil(ctx1.Request)
		}
		if assert.NotNil(ctx2) {
			assert.NotNil(ctx2.Request)
		}
		if assert.NotNil(ctx3) {
			assert.NotNil(ctx3.Request)
		}

		assert.Equal(ctxptr1, ctxptr2)
		assert.Equal(ctxptr2, ctxptr3)
		assert.Equal(ctxptr3, ctxptr1)

		assert.Equal(ptr1, ptr2)
		assert.Equal(ptr2, ptr3)
		assert.Equal(ptr3, ptr1)
	}
}
开发者ID:gophergala2016,项目名称:source,代码行数:61,代码来源:context_test.go


示例15: TestEnv

func TestEnv(t *testing.T) {
	assert := assert.New(t)

	assert.NotEqual(Username(), "unknown_user")
	assert.NotEqual(Hostname(), "unknown_host")
	assert.NotEqual(ExecPath(), "unknown_exec")
}
开发者ID:enova,项目名称:tokyo,代码行数:7,代码来源:lax_test.go


示例16: Test_PerMinute_Hash

func Test_PerMinute_Hash(t *testing.T) {
	mock := clock.NewMock()
	hasher := PerMinuteHasher{
		Clock: mock,
	}

	resultOne := hasher.Hash("127.0.0.1")

	mock.Add(time.Minute)

	resultTwo := hasher.Hash("127.0.0.1")

	assert.NotEqual(t, resultOne, resultTwo)

	resultThree := hasher.Hash("127.0.0.1")
	resultFour := hasher.Hash("127.0.0.1")
	resultFive := hasher.Hash("127.0.0.2")

	assert.Equal(t, resultThree, resultFour)
	assert.NotEqual(t, resultFour, resultFive)

	// Test that it can create a new clock
	hasher = PerMinuteHasher{}
	hasher.Hash("127.0.0.1")
}
开发者ID:vially,项目名称:speedbump,代码行数:25,代码来源:hashers_test.go


示例17: TestTransactionHashInner

func TestTransactionHashInner(t *testing.T) {
	tx := makeTransaction(t)

	h := tx.hashInner()
	assert.NotEqual(t, h, SHA256{})

	// If tx.In is changed, hash should change
	tx2 := copyTransaction(tx)
	ux := makeUxOut(t)
	tx2.In[0] = ux.Hash()
	assert.NotEqual(t, tx, tx2)
	assert.Equal(t, tx2.In[0], ux.Hash())
	assert.NotEqual(t, tx.hashInner(), tx2.hashInner())

	// If tx.Out is changed, hash should change
	tx2 = copyTransaction(tx)
	a := makeAddress()
	tx2.Out[0].Address = a
	assert.NotEqual(t, tx, tx2)
	assert.Equal(t, tx2.Out[0].Address, a)
	assert.NotEqual(t, tx.hashInner(), tx2.hashInner())

	// If tx.Head is changed, hash should not change
	tx2 = copyTransaction(tx)
	tx.Head.Sigs = append(tx.Head.Sigs, Sig{})
	assert.Equal(t, tx.hashInner(), tx2.hashInner())
}
开发者ID:up4k,项目名称:skycoin,代码行数:27,代码来源:transactions_test.go


示例18: TestCopy

func TestCopy(t *testing.T) {
	request := buildApiRequest("/_ah/api/foo?bar=baz", `{"test": "body"}`, nil)
	copied, err := request.copy()
	assert.NoError(t, err)
	assert.Equal(t, request.Header, copied.Header)
	body, err := ioutil.ReadAll(request.Body)
	assert.NoError(t, err)
	body_copy, err2 := ioutil.ReadAll(copied.Body)
	assert.NoError(t, err2)
	assert.Equal(t, string(body), string(body_copy))
	assert.Equal(t, request.bodyJson, copied.bodyJson)
	assert.Equal(t, request.URL.Path, copied.URL.Path)

	copied.Header.Set("Content-Type", "text/plain")
	copied.Body = ioutil.NopCloser(bytes.NewBufferString("Got a whole new body!"))
	copied.bodyJson = map[string]interface{}{"new": "body"}
	copied.URL.Path = "And/a/new/path/"

	assert.NotEqual(t, request.Header, copied.Header)
	body, err = ioutil.ReadAll(request.Body)
	assert.NoError(t, err)
	body_copy, err2 = ioutil.ReadAll(copied.Body)
	assert.NoError(t, err2)
	assert.NotEqual(t, string(body), string(body_copy))
	assert.NotEqual(t, request.bodyJson, copied.bodyJson)
	assert.NotEqual(t, request.URL.Path, copied.URL.Path)
}
开发者ID:rwl,项目名称:endpoints,代码行数:27,代码来源:api_request_test.go


示例19: TestBuys_exist_false

// For the case when exist = false
// Tests that a new TemplateDTO_CommBoughtProviderProp struct is created
// with it Key variable = this.currentProvider
// Tests that the new TemplateDTO_CommBoughtProviderProp struct is appended
// to this.entityTemplate.CommodityBought
// Tests that the TemplateCommodity passed to the Buys() method is appended to the
// member array named Value in the newly created TemplateDTO_CommBoughtProviderProp
func TestBuys_exist_false(t *testing.T) {
	assert := assert.New(t)
	eTemplate := new(TemplateDTO)
	provider := new(Provider)
	scnbuilder := &SupplyChainNodeBuilder{
		entityTemplate:  eTemplate,
		currentProvider: provider,
	}
	templateCommodity := new(TemplateCommodity)
	scnb := scnbuilder.Buys(*templateCommodity)
	var providerProp *TemplateDTO_CommBoughtProviderProp
	var commoditiesBought []*TemplateDTO_CommBoughtProviderProp
	if assert.NotEqual(([]*TemplateDTO_CommBoughtProviderProp)(nil), scnb.entityTemplate.CommodityBought) {
		assert.Equal(1, len(scnb.entityTemplate.CommodityBought))
		commoditiesBought = scnb.entityTemplate.CommodityBought
		for _, pp := range commoditiesBought {
			if pp.GetKey() == provider {
				providerProp = pp
			}
		}
	}
	// provideProp is the  *TemplateDTO_CommBoughtProviderProp
	// containing the []*TemplateCommodity to which Buys appended templateCommodity
	if assert.NotEqual(([]*TemplateCommodity)(nil), commoditiesBought[0].Value) {
		assert.Equal(1, len(providerProp.Value))
		assert.Equal(templateCommodity, providerProp.Value[0])
	}
}
开发者ID:enlinxu,项目名称:vmturbo-go-sdk,代码行数:35,代码来源:supplychainnodebuilder_test.go


示例20: TestNewCarbonDatapoint

func TestNewCarbonDatapoint(t *testing.T) {
	identityParser, _ := metricdeconstructor.Load("", "")
	dp, err := NewCarbonDatapoint("hello 3 3", identityParser)
	assert.Equal(t, nil, err, "Should be a valid carbon line")
	assert.Equal(t, "hello", dp.Metric, "Should get metric back")

	_, err = NewCarbonDatapoint("INVALIDLINE", identityParser)
	assert.NotEqual(t, nil, err, "Line should be invalid")

	_, err = NewCarbonDatapoint("hello 3 bob", identityParser)
	assert.NotEqual(t, nil, err, "Line should be invalid")

	_, err = NewCarbonDatapoint("hello bob 3", identityParser)
	assert.NotEqual(t, nil, err, "Line should be invalid")

	dp, _ = NewCarbonDatapoint("hello 3.3 3", identityParser)
	f := dp.Value.(datapoint.FloatValue).Float()
	assert.Equal(t, 3.3, f, "Should get value back")

	carbonDp, _ := NativeCarbonLine(dp)
	assert.Equal(t, "hello 3.3 3", carbonDp, "Should get the carbon line back")

	dp, err = NewCarbonDatapoint("hello 3 3", &errorDeconstructor{})
	assert.NotEqual(t, nil, err, "Should NOT be a valid carbon line")
}
开发者ID:baris,项目名称:metricproxy,代码行数:25,代码来源:carbon_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang assert.NotNil函数代码示例发布时间:2022-05-28
下一篇:
Golang assert.NotEmpty函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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