xkcd-go

Golang tool to read latest, random, or a specific xkcd comic (and download it too).
git clone http://git.hanabi.in/repos/xkcd-go.git
Log | Files | Refs | README | LICENSE

specific-api_test.go (1095B)


      1 package xkcd
      2 
      3 import (
      4 	"fmt"
      5 	"testing"
      6 )
      7 
      8 func Test1(t *testing.T) {
      9 	expected := "https://xkcd.com/1000/info.0.json"
     10 	received := specificAPI(1000)
     11 	if expected != received {
     12 		msg := fmt.Sprintf("Expected `%s', received: `%s'.\n", expected, received)
     13 		t.Error(msg)
     14 	}
     15 }
     16 
     17 func Test2(t *testing.T) {
     18 	expected := "https://xkcd.com/404/info.0.json"
     19 	received := specificAPI(404)
     20 	if expected != received {
     21 		msg := fmt.Sprintf("Expected `%s', received: `%s'.\n", expected, received)
     22 		t.Error(msg)
     23 	}
     24 }
     25 
     26 func Test3(t *testing.T) {
     27 	expected := "https://xkcd.com/0/info.0.json"
     28 	received := specificAPI(0) // specificAPI does not care about number, it just expects number.
     29 	if expected != received {
     30 		msg := fmt.Sprintf("Expected `%s', received: `%s'.\n", expected, received)
     31 		t.Error(msg)
     32 	}
     33 }
     34 
     35 func Test4(t *testing.T) {
     36 	expected := "https://xkcd.com/-30/info.0.json"
     37 	received := specificAPI(-30) // specificAPI does not care about number, it just expects number.
     38 	if expected != received {
     39 		msg := fmt.Sprintf("Expected `%s', received: `%s'.\n", expected, received)
     40 		t.Error(msg)
     41 	}
     42 }