wecisecode 3 周之前
父節點
當前提交
0e86e81e17
共有 3 個文件被更改,包括 57 次插入1 次删除
  1. 1 1
      file/test.txt
  2. 41 0
      func/func_test.go
  3. 15 0
      time/time_test.go

+ 1 - 1
file/test.txt

@@ -1 +1 @@
-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+ 41 - 0
func/func_test.go

@@ -1,6 +1,9 @@
 package func_test
 
 import (
+	"fmt"
+	"math"
+	"strings"
 	"testing"
 )
 
@@ -23,3 +26,41 @@ func BenchmarkCode(t *testing.B) {
 	}
 	t.StopTimer()
 }
+
+func TestXXX(t *testing.T) {
+	A := []float64{}
+	X := 0.0
+	Z := 1.0
+	for i := 1; i < 11; i++ {
+		if i%2 == 0 {
+			Z = Z * 2
+		} else {
+			Z = Z + 0.5
+		}
+		X = X + Z
+		println("Z=", Z, "     X=", X)
+		A = append(A, X)
+	}
+	for i := 0; i < 10; i++ {
+		Y := int(A[i])
+		println(strings.Repeat(".", Y))
+	}
+}
+
+func TestSIN(t *testing.T) {
+	A := []float64{}
+	X := 0.0
+	Z := 1.0
+	for i := 0; i <= 360; i++ {
+		Z = float64(i) / 360 * 2 * math.Pi
+		X = math.Sin(Z)*30 + 31
+		A = append(A, X)
+		println("i=   ", i, "Z=", Z, "     X=", X)
+	}
+	for i := 0; i <= 360; i++ {
+		if i%10 == 0 {
+			Y := int(A[i] + 0.5)
+			println(fmt.Sprintf("%3d", i), strings.Repeat(".", Y))
+		}
+	}
+}

+ 15 - 0
time/time_test.go

@@ -5,8 +5,23 @@ import (
 	"math"
 	"testing"
 	"time"
+
+	"github.com/stretchr/testify/assert"
 )
 
+func TestUTC(t *testing.T) {
+	tm, _ := time.ParseInLocation("2006-01-02 15:04:05.000000000", "1970-01-01 00:00:00.000000000", time.UTC)
+	fmt.Println(tm.Format("2006-01-02 15:04:05.000000000-07:00"), "=>", tm.UnixNano())
+	if !assert.Equal(t, tm.UnixNano(), int64(0)) {
+		return
+	}
+	tm, _ = time.ParseInLocation("2006-01-02 15:04:05.000000000", "1970-01-01 08:00:00.000000000", time.Local)
+	fmt.Println(tm.Format("2006-01-02 15:04:05.000000000-07:00"), "=>", tm.UnixNano())
+	if !assert.Equal(t, tm.UnixNano(), int64(0)) {
+		return
+	}
+}
+
 func TestRound(tx *testing.T) {
 	t, _ := time.Parse("2006-01-02 15:04:05.000000000", "2006-01-02 15:04:05.123456789")
 	fmt.Println(t.Format("2006-01-02 15:04:05.000000000"))