github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/accounts/abi/numbers_test.go (about)

     1  // This file is part of the go-sberex library. The go-sberex library is 
     2  // free software: you can redistribute it and/or modify it under the terms 
     3  // of the GNU Lesser General Public License as published by the Free 
     4  // Software Foundation, either version 3 of the License, or (at your option)
     5  // any later version.
     6  //
     7  // The go-sberex library is distributed in the hope that it will be useful, 
     8  // but WITHOUT ANY WARRANTY; without even the implied warranty of
     9  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 
    10  // General Public License <http://www.gnu.org/licenses/> for more details.
    11  
    12  package abi
    13  
    14  import (
    15  	"bytes"
    16  	"math/big"
    17  	"reflect"
    18  	"testing"
    19  )
    20  
    21  func TestNumberTypes(t *testing.T) {
    22  	ubytes := make([]byte, 32)
    23  	ubytes[31] = 1
    24  
    25  	unsigned := U256(big.NewInt(1))
    26  	if !bytes.Equal(unsigned, ubytes) {
    27  		t.Errorf("expected %x got %x", ubytes, unsigned)
    28  	}
    29  }
    30  
    31  func TestSigned(t *testing.T) {
    32  	if isSigned(reflect.ValueOf(uint(10))) {
    33  		t.Error("signed")
    34  	}
    35  
    36  	if !isSigned(reflect.ValueOf(int(10))) {
    37  		t.Error("not signed")
    38  	}
    39  }