예제 #1
0
파일: bufbig_test.go 프로젝트: farces/dumb
//reset test
func TestBigAccumulatorReset(t *testing.T) {
	out := bufbig.NewBigAccumulator()

	v := bufbig.NewBigAccumulator()
	v.AddInt(10)
	v.Reset()

	if v.Value().String() != out.Value().String() {
		t.Errorf("Reset() = %v, want %v", v.Value().String(), out.Value().String())
	}
}
예제 #2
0
func main() {
	//x := new(bufbig.BigAccumulator)
	x := bufbig.NewBigAccumulator()
	for y := 0; y < 1000000; y++ {
		x.AddInt(1)
	}
	fmt.Println(x.Value())
}
예제 #3
0
파일: bufbig_test.go 프로젝트: farces/dumb
//setbigint test
func TestBigAccumulatorSetBigInt(t *testing.T) {
	out := big.NewInt(int64(12345))

	v := bufbig.NewBigAccumulator()
	v.SetBigInt(big.NewInt(int64(12345)))

	if v.Value().String() != out.String() {
		t.Errorf("SetBigInt big.NewInt(int64(12345)) = %v, want %v", v.Value().String(), out.String())
	}
}
예제 #4
0
파일: bufbig_test.go 프로젝트: farces/dumb
//setstring test
func TestBigAccumulatorSetString(t *testing.T) {
	out := big.NewInt(int64(12345654321))

	v := bufbig.NewBigAccumulator()
	v.SetString("12345654321", 10)

	if v.Value().String() != out.String() {
		t.Errorf("SetValue(\"12345654321\",10) = %v, want %v", v.Value().String(), out.String())
	}
}
예제 #5
0
파일: bufbig_test.go 프로젝트: farces/dumb
//int64 overflow test
func TestBigAccumulatorOverflow(t *testing.T) {
	out, _ := new(big.Int).SetString("9223372036854775808", 10)

	v := bufbig.NewBigAccumulator()
	v.SetString("9223372036854775807", 10)
	v.AddInt(1)

	if v.Value().String() != out.String() {
		t.Errorf("MaxInt64 + 1 = %v, want %v", v.Value().String(), out.String())
	}
}
예제 #6
0
파일: bufbig_test.go 프로젝트: farces/dumb
//subtraction test
func TestBigAccumulatorSub(t *testing.T) {
	out := big.NewInt(int64(-10))

	v := bufbig.NewBigAccumulator()
	v.AddInt(2)
	v.AddInt(-12)

	if v.Value().String() != out.String() {
		t.Errorf("Subtraction: 2 - 12 = %v, want %v", v.Value().String(), out.String())
	}
}
예제 #7
0
파일: bufbig_test.go 프로젝트: farces/dumb
//addition test
func TestBigAccumulatorAdd(t *testing.T) {
	out := big.NewInt(int64(10))

	v := bufbig.NewBigAccumulator()
	v.AddInt(2)
	v.AddInt(8)

	if v.Value().String() != out.String() {
		t.Errorf("Addition: 2 + 8 = %v, want %v", v.Value().String(), out.String())
	}
}
예제 #8
0
파일: bufbig_test.go 프로젝트: farces/dumb
//setstring invalid value test
func TestBigAccumulatorSetStringInvalid(t *testing.T) {
	out := big.NewInt(int64(1))

	v := bufbig.NewBigAccumulator()
	v.AddInt(1)
	res := v.SetString("boobs", 10)

	//expecting SetValue to pass SetString success result back
	if res != false {
		t.Errorf("SetValue Invalid = true, want false")
	}

	//checking to make sure original value persists
	if v.Value().String() != out.String() {
		t.Errorf("SetValue(\"boobs\",10) = %v, want %v", v.Value().String(), out.String())
	}
}