go-hep.org/x/hep@v0.38.1/groot/rbase/object_test.go (about) 1 // Copyright ©2019 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package rbase_test 6 7 import ( 8 "testing" 9 10 "go-hep.org/x/hep/groot/rbase" 11 "go-hep.org/x/hep/groot/rbytes" 12 ) 13 14 func TestObject(t *testing.T) { 15 obj := rbase.NewObject() 16 if got, want := obj.ID, uint32(0x0); got != want { 17 t.Fatalf("invalid ID. got=0x%x, want=0x%x", got, want) 18 } 19 obj.SetID(0x2) 20 if got, want := obj.ID, uint32(0x2); got != want { 21 t.Fatalf("invalid ID. got=0x%x, want=0x%x", got, want) 22 } 23 24 if got, want := obj.Bits, uint32(0x3000000); got != want { 25 t.Fatalf("invalid bits. got=0x%x, want=0x%x", got, want) 26 } 27 28 if got, want := obj.TestBits(rbytes.BypassStreamer), false; got != want { 29 t.Fatalf("invalid BypassStreamer-bit-test. got=%v, want=%v", got, want) 30 } 31 obj.SetBit(rbytes.BypassStreamer) 32 if got, want := obj.TestBits(rbytes.BypassStreamer), true; got != want { 33 t.Fatalf("invalid BypassStreamer-bit-test. got=%v, want=%v", got, want) 34 } 35 obj.ResetBit(rbytes.BypassStreamer) 36 if got, want := obj.TestBits(rbytes.BypassStreamer), false; got != want { 37 t.Fatalf("invalid BypassStreamer-bit-test. got=%v, want=%v", got, want) 38 } 39 40 obj.SetBits(rbytes.BypassStreamer) 41 if got, want := obj.Bits, uint32(rbytes.BypassStreamer); got != want { 42 t.Fatalf("invalid bits. got=0x%x, want=0x%x", got, want) 43 } 44 if got, want := obj.TestBits(rbytes.BypassStreamer), true; got != want { 45 t.Fatalf("invalid BypassStreamer-bit-test. got=%v, want=%v", got, want) 46 } 47 }