<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                編寫測試代碼時,一個較好的辦法是把測試的輸入數據和期望的結果寫在一起組成一個數據表:表中的每條記錄都是一個含有輸入和期望值的完整測試用例,有時還可以結合像測試名字這樣的額外信息來讓測試輸出更多的信息。 實際測試時簡單迭代表中的每條記錄,并執行必要的測試。這在練習?[13.4](https://github.com/Unknwon/the-way-to-go_ZH_CN/blob/master/eBook/exercises/chapter_13/string_reverse_test.go)?中有具體的應用。 可以抽象為下面的代碼段: ~~~ var tests = []struct{ // Test table in string out string }{ {“in1”, “exp1”}, {“in2”, “exp2”}, {“in3”, “exp3”}, ... } func TestFunction(t *testing.T) { for i, tt := range tests { s := FuncToBeTested(tt.in) if s != tt.out { t.Errorf(“%d. %q => %q, wanted: %q”, i, tt.in, s, tt.out) } } } ~~~ 如果大部分函數都可以寫成這種形式,那么寫一個幫助函數 verify 對實際測試會很有幫助: ~~~ func verify(t *testing.T, testnum int, testcase, input, output, expected string) { if input != output { t.Errorf(“%d. %s with input = %s: output %s != %s”, testnum, testcase, input, output, expected) } } ~~~ TestFunction 則變為: ~~~ func TestFunction(t *testing.T) { for i, tt := range tests { s := FuncToBeTested(tt.in) verify(t, i, “FuncToBeTested: “, tt.in, s, tt.out) } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看