Skip to content

Instantly share code, notes, and snippets.

@meson10
Created May 14, 2016 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meson10/22d02310cd463d0c8cb8c306a6bc0de9 to your computer and use it in GitHub Desktop.
Save meson10/22d02310cd463d0c8cb8c306a6bc0de9 to your computer and use it in GitHub Desktop.
quick_testing.go
package main
import (
"log"
"math"
"testing"
"testing/quick"
)
func myMin(a, b float64) float64 {
log.Println(a, b)
if a < b {
return a
} else {
return b
}
}
func TestEquivalence(t *testing.T) {
var g = math.Min
config := quick.Config{
MaxCount: 4,
}
if err := quick.CheckEqual(myMin, g, &config); err != nil {
t.Error(err)
}
}
type A struct {
Map map[int]float64
Val int
}
func toTest(a A) bool {
log.Println(a)
return false
}
func TestCheck(t *testing.T) {
config := quick.Config{
MaxCount: 4,
}
if err := quick.Check(toTest, &config); err != nil {
t.Error(err)
}
}
@meson10
Copy link
Author

meson10 commented May 14, 2016

Output

=== RUN   TestEquivalence
2016/05/14 19:17:35 /Users/piyush/gilmour-libs/goli/goli_test.go:11: 1.6991726286843295e+308 1.1792080747117044e+308
2016/05/14 19:17:35 /Users/piyush/gilmour-libs/goli/goli_test.go:11: -6.608089978263862e+307 3.459455674950743e+307
2016/05/14 19:17:35 /Users/piyush/gilmour-libs/goli/goli_test.go:11: 1.6128358341357903e+308 5.187884450704332e+307
2016/05/14 19:17:35 /Users/piyush/gilmour-libs/goli/goli_test.go:11: 1.5276441786664819e+308 -1.0949392797216843e+308
--- PASS: TestEquivalence (0.00s)
=== RUN   TestCheck
2016/05/14 19:17:35 /Users/piyush/gilmour-libs/goli/goli_test.go:37: {map[2631062049844636834:1.5046213633533974e+308 -1940655818325682128:-6.839189720481966e+307 -46862904637620763:-2.334989422502301e+307 -2093273755080502606:-1.0949392797216843e+308 -652406174326059718:1.7350637114683511e+308 -4204982866718888976:-9.269949987103055e+307 124531218906382005:-4.413262657624169e+307 -1697390983611128730:-2.719794775124946e+307 -1714004388561149787:-6.624044392902066e+307 -1294562040593998269:9.749130687946344e+307 2727042567806946092:1.0510330631099498e+308 -2352281900722994752:1.1792080747117044e+308 -1221292455668011702:-5.203969873625763e+307 -1949953187327444488:-1.6226065356339422e+308 1780756845054258976:-7.224890824073084e+307 2533238229511593671:-3.1425046121165766e+306 2761419461769776844:6.407131886477583e+307 167004063577870810:2.0651155596688173e+307 3903164248339793089:-1.6924593980752724e+308 3087705905663375507:7.570940794363661e+306 1432686216250034552:1.6128358341357903e+308 94468846694902125:4.3222278193927413e+307 1691534932087626756:7.865576457387185e+307 946551327025798398:1.5291883729854203e+308] -627963631942575162}
--- FAIL: TestCheck (0.00s)
    goli_test.go:47: #1: failed on input main.A{Map:map[int]float64{2533238229511593671:-3.1425046121165766e+306, 2761419461769776844:6.407131886477583e+307, 167004063577870810:2.0651155596688173e+307, 3087705905663375507:7.570940794363661e+306, 1432686216250034552:1.6128358341357903e+308, 94468846694902125:4.3222278193927413e+307, 1691534932087626756:7.865576457387185e+307, 946551327025798398:1.5291883729854203e+308, 3903164248339793089:-1.6924593980752724e+308, -1940655818325682128:-6.839189720481966e+307, -46862904637620763:-2.334989422502301e+307, -2093273755080502606:-1.0949392797216843e+308, -652406174326059718:1.7350637114683511e+308, -4204982866718888976:-9.269949987103055e+307, 124531218906382005:-4.413262657624169e+307, 2631062049844636834:1.5046213633533974e+308, -1714004388561149787:-6.624044392902066e+307, -1294562040593998269:9.749130687946344e+307, 2727042567806946092:1.0510330631099498e+308, -2352281900722994752:1.1792080747117044e+308, -1221292455668011702:-5.203969873625763e+307, -1949953187327444488:-1.6226065356339422e+308, 1780756845054258976:-7.224890824073084e+307, -1697390983611128730:-2.719794775124946e+307}, Val:-627963631942575162}
FAIL
exit status 1
FAIL    _/Users/piyush/gilmour-libs/goli    0.025s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment