From 38ee83e45b4de7edf89bf9f0ef629eb4c6ad0fa8 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Thu, 12 May 2016 23:56:07 -0400 Subject: Moving to glide --- vendor/golang.org/x/image/math/fixed/fixed.go | 2 +- vendor/golang.org/x/image/math/fixed/fixed_test.go | 110 +++++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 vendor/golang.org/x/image/math/fixed/fixed_test.go (limited to 'vendor/golang.org/x/image/math/fixed') diff --git a/vendor/golang.org/x/image/math/fixed/fixed.go b/vendor/golang.org/x/image/math/fixed/fixed.go index cc7bac79e..df3540a3a 100644 --- a/vendor/golang.org/x/image/math/fixed/fixed.go +++ b/vendor/golang.org/x/image/math/fixed/fixed.go @@ -3,7 +3,7 @@ // license that can be found in the LICENSE file. // Package fixed implements fixed-point integer types. -package fixed +package fixed // import "golang.org/x/image/math/fixed" import ( "fmt" diff --git a/vendor/golang.org/x/image/math/fixed/fixed_test.go b/vendor/golang.org/x/image/math/fixed/fixed_test.go new file mode 100644 index 000000000..065ab00b0 --- /dev/null +++ b/vendor/golang.org/x/image/math/fixed/fixed_test.go @@ -0,0 +1,110 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package fixed + +import ( + "testing" +) + +var testCases = []struct { + x float64 + s26_6 string + s52_12 string + floor int + round int + ceil int +}{{ + x: 0, + s26_6: "0:00", + s52_12: "0:0000", + floor: 0, + round: 0, + ceil: 0, +}, { + x: 1, + s26_6: "1:00", + s52_12: "1:0000", + floor: 1, + round: 1, + ceil: 1, +}, { + x: 1.25, + s26_6: "1:16", + s52_12: "1:1024", + floor: 1, + round: 1, + ceil: 2, +}, { + x: 2.5, + s26_6: "2:32", + s52_12: "2:2048", + floor: 2, + round: 3, + ceil: 3, +}, { + x: 63 / 64.0, + s26_6: "0:63", + s52_12: "0:4032", + floor: 0, + round: 1, + ceil: 1, +}, { + x: -0.5, + s26_6: "-0:32", + s52_12: "-0:2048", + floor: -1, + round: +0, + ceil: +0, +}, { + x: -4.125, + s26_6: "-4:08", + s52_12: "-4:0512", + floor: -5, + round: -4, + ceil: -4, +}, { + x: -7.75, + s26_6: "-7:48", + s52_12: "-7:3072", + floor: -8, + round: -8, + ceil: -7, +}} + +func TestInt26_6(t *testing.T) { + for _, tc := range testCases { + x := Int26_6(tc.x * (1 << 6)) + if got, want := x.String(), tc.s26_6; got != want { + t.Errorf("tc.x=%v: String: got %q, want %q", tc.x, got, want) + } + if got, want := x.Floor(), tc.floor; got != want { + t.Errorf("tc.x=%v: Floor: got %v, want %v", tc.x, got, want) + } + if got, want := x.Round(), tc.round; got != want { + t.Errorf("tc.x=%v: Round: got %v, want %v", tc.x, got, want) + } + if got, want := x.Ceil(), tc.ceil; got != want { + t.Errorf("tc.x=%v: Ceil: got %v, want %v", tc.x, got, want) + } + } +} + +func TestInt52_12(t *testing.T) { + for _, tc := range testCases { + x := Int52_12(tc.x * (1 << 12)) + if got, want := x.String(), tc.s52_12; got != want { + t.Errorf("tc.x=%v: String: got %q, want %q", tc.x, got, want) + } + if got, want := x.Floor(), tc.floor; got != want { + t.Errorf("tc.x=%v: Floor: got %v, want %v", tc.x, got, want) + } + if got, want := x.Round(), tc.round; got != want { + t.Errorf("tc.x=%v: Round: got %v, want %v", tc.x, got, want) + } + if got, want := x.Ceil(), tc.ceil; got != want { + t.Errorf("tc.x=%v: Ceil: got %v, want %v", tc.x, got, want) + } + } +} -- cgit v1.2.3-1-g7c22