本文整理汇总了Golang中testing.T.Fail方法的典型用法代码示例。如果您正苦于以下问题:Golang T.Fail方法的具体用法?Golang T.Fail怎么用?Golang T.Fail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testing.T
的用法示例。
在下文中一共展示了T.Fail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestInterfaceEquality
func TestInterfaceEquality(t *testing.T) {
o := js.Global.Get("Object").New()
var i interface{} = o
if i != o {
t.Fail()
}
}
示例2: Test_Statement_ActualCommand
func Test_Statement_ActualCommand(t *testing.T) {
withStatement(t, "SELECT id FROM table1 WHERE strreq = '@id' OR id = @id;", []*Parameter{idParameter(3)}, func(stmt *Statement) {
if stmt.ActualCommand() != "SELECT id FROM table1 WHERE strreq = '@id' OR id = $1;" {
t.Fail()
}
})
}
示例3: TestVersion
func TestVersion(t *testing.T) {
v := new(Version)
v.Version = uint16(1)
v.Timestamp = time.Unix(0, 0)
v.IpAddress = net.ParseIP("1.2.3.4")
v.Port = uint16(4444)
v.UserAgent = "Hello World!"
verBytes := v.GetBytes()
if len(verBytes) != verLen+12 {
fmt.Println("Incorrect Byte Length: ", verBytes)
t.Fail()
}
v2 := new(Version)
err := v2.FromBytes(verBytes)
if err != nil {
fmt.Println("Error Decoding: ", err)
t.FailNow()
}
if v2.Version != 1 || v2.Timestamp != time.Unix(0, 0) || v2.IpAddress.String() != "1.2.3.4" || v2.Port != 4444 || v2.UserAgent != "Hello World!" {
fmt.Println("Incorrect decoded version: ", v2)
t.Fail()
}
}
示例4: TestToModulePath
func TestToModulePath(t *testing.T) {
cwd, _ := os.Getwd()
if strings.Compare(ToModuleName(cwd), "github.com/fredjeck/gobot") != 0 {
t.Fail()
}
}
示例5: TestIndexesAsync_ClientWaitScenario
func TestIndexesAsync_ClientWaitScenario(t *testing.T) {
testDBWrapper.CreateFreshDB(t)
testBlockchainWrapper := newTestBlockchainWrapper(t)
chain := testBlockchainWrapper.blockchain
if chain.indexer.isSynchronous() {
t.Skip("Skipping because blockchain is configured to index block data synchronously")
}
blocks, _, err := testBlockchainWrapper.populateBlockChainWithSampleData()
if err != nil {
t.Logf("Error populating block chain with sample data: %s", err)
t.Fail()
}
t.Log("Increasing size of blockchain by one artificially so as to make client wait")
chain.size = chain.size + 1
t.Log("Resetting size of blockchain to original and adding one block in a separate go routine so as to wake up the client")
go func() {
time.Sleep(2 * time.Second)
chain.size = chain.size - 1
blk, err := buildTestBlock(t)
if err != nil {
t.Logf("Error building test block: %s", err)
t.Fail()
}
testBlockchainWrapper.addNewBlock(blk, []byte("stateHash"))
}()
t.Log("Executing client query. The client would wait and will be woken up")
blockHash, _ := blocks[0].GetHash()
block := testBlockchainWrapper.getBlockByHash(blockHash)
testutil.AssertEquals(t, block, blocks[0])
}
示例6: TestGetWhenKeyIsEmptyString
func TestGetWhenKeyIsEmptyString(t *testing.T) {
bs := NewBlockstore(ds_sync.MutexWrap(ds.NewMapDatastore()))
_, err := bs.Get(key.Key(""))
if err != ErrNotFound {
t.Fail()
}
}
示例7: TestParsing
func TestParsing(t *testing.T) {
addresses := []string{
"1DgxRTofdbau7kpf3pQeRydcoTPG2L5NUX",
"17Nt7rWiRZKDgcNp421zZ1FHGPWSnnT1bk",
}
var decoder *json.Decoder
if true {
response, err := http.Get(url)
if err != nil {
t.SkipNow()
// log.Fatal(err)
}
defer response.Body.Close()
decoder = json.NewDecoder(response.Body)
}
r := new(OverviewReport)
err := decoder.Decode(&r)
if err != nil {
t.Fail()
// log.Fatal(err)
}
total := new(AddressReport)
for _, address := range addresses {
report, ok := r.Report[address]
if !ok {
t.Fail()
}
total.Add(report)
}
}
示例8: TestNilAtLhs
func TestNilAtLhs(t *testing.T) {
type F func(string) string
var f F
if nil != f {
t.Fail()
}
}
示例9: TestAddAssignOnPackageVar
func TestAddAssignOnPackageVar(t *testing.T) {
otherpkg.Test = 0
otherpkg.Test += 42
if otherpkg.Test != 42 {
t.Fail()
}
}
示例10: TestEncodeSeveral
func TestEncodeSeveral(t *testing.T) {
tests := map[string][]string{
"a": []string{"a"},
"axe": []string{"axe"},
"a/b/c/d/e/f/h/g/i/j": []string{"a", "b", "c", "d", "e",
"f", "h", "g", "i", "j"},
}
for p, a := range tests {
m := &Message{Type: Confirmable, Code: GET, MessageID: 12345}
m.SetPathString(p)
b, err := (*m).encode()
if err != nil {
t.Errorf("Error encoding %#v", p)
t.Fail()
continue
}
m2, err := parseMessage(b)
if err != nil {
t.Fatalf("Can't parse my own message at %#v: %v", p, err)
}
if !reflect.DeepEqual(m2.Path(), a) {
t.Errorf("Expected %#v, got %#v", a, m2.Path())
t.Fail()
}
}
}
示例11: TestPointerEquality
func TestPointerEquality(t *testing.T) {
a := 1
b := 1
if &a != &a || &a == &b {
t.Fail()
}
m := make(map[*int]int)
m[&a] = 2
m[&b] = 3
if m[&a] != 2 || m[&b] != 3 {
t.Fail()
}
for {
c := 1
d := 1
if &c != &c || &c == &d {
t.Fail()
}
break
}
s := struct {
e int
f int
}{1, 1}
if &s.e != &s.e || &s.e == &s.f {
t.Fail()
}
g := [3]int{1, 2, 3}
if &g[0] != &g[0] || &g[:][0] != &g[0] || &g[:][0] != &g[:][0] {
t.Fail()
}
}
示例12: TestDereference
func TestDereference(t *testing.T) {
s := *dummys
p := &s
if p != dummys {
t.Fail()
}
}
示例13: TestNewArrayBuffer
func TestNewArrayBuffer(t *testing.T) {
b := []byte("abcd")
a := js.NewArrayBuffer(b[1:3])
if a.Get("byteLength").Int() != 2 {
t.Fail()
}
}
示例14: TestReflection
func TestReflection(t *testing.T) {
o := js.Global.Call("eval", "({ answer: 42 })")
if reflect.ValueOf(o).Interface().(*js.Object) != o {
t.Fail()
}
type S struct {
Field *js.Object
}
s := S{o}
v := reflect.ValueOf(&s).Elem()
if v.Field(0).Interface().(*js.Object).Get("answer").Int() != 42 {
t.Fail()
}
if v.Field(0).MethodByName("Get").Call([]reflect.Value{reflect.ValueOf("answer")})[0].Interface().(*js.Object).Int() != 42 {
t.Fail()
}
v.Field(0).Set(reflect.ValueOf(js.Global.Call("eval", "({ answer: 100 })")))
if s.Field.Get("answer").Int() != 100 {
t.Fail()
}
if fmt.Sprintf("%+v", s) != "{Field:[object Object]}" {
t.Fail()
}
}
示例15: TestCycleTime
func TestCycleTime(t *testing.T) {
const MeasureTolerance int64 = 1000000
var d Duration
d.FromSec(0.01)
r := CycleTime(d)
if !r.actualCycleTime.IsZero() {
t.Fail()
}
if r.expectedCycleTime.ToSec() != 0.01 {
t.Fail()
}
start := time.Now().UnixNano()
r.Sleep()
end := time.Now().UnixNano()
actual := r.CycleTime()
elapsed := end - start
delta := int64(actual.ToNSec()) - elapsed
if delta < 0 {
delta = -delta
}
if delta > MeasureTolerance {
t.Error(delta)
}
}