golang.org/x/exp@v0.0.0-20240506185415-9bf2ced13842/io/i2c/i2c_test.go (about) 1 // Copyright 2016 The Go 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 i2c 6 7 import ( 8 "testing" 9 ) 10 11 func TestTenBit(t *testing.T) { 12 tc := []struct { 13 masked int 14 addrWant int 15 tenbitWant bool 16 }{ 17 {TenBit(0x5), 0x5, true}, 18 {0x5, 0x5, false}, 19 {TenBit(0x200), 0x200, true}, 20 } 21 22 for _, tt := range tc { 23 unmasked, tenbit := resolveAddr(tt.masked) 24 if want, got := tt.tenbitWant, tenbit; got != want { 25 t.Errorf("want address %x as 10-bit; got non 10-bit", tt.masked) 26 } 27 if want, got := tt.addrWant, unmasked; got != want { 28 t.Errorf("want address %v; got %v", want, got) 29 } 30 } 31 }